add getEntries() to the CommandHistory API

so we can export them to lua
also bump the default history size to 5000 from the paltry 100 we had
develop
myk002 2022-07-15 09:07:14 -07:00
parent 193b9a4004
commit dd6fbd53b6
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 8 additions and 1 deletions

@ -32,6 +32,7 @@ distribution.
#include <assert.h> #include <assert.h>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
namespace tthread namespace tthread
{ {
class mutex; class mutex;
@ -44,7 +45,7 @@ namespace DFHack
class CommandHistory class CommandHistory
{ {
public: public:
CommandHistory(std::size_t capacity = 100) CommandHistory(std::size_t capacity = 5000)
{ {
this->capacity = capacity; this->capacity = capacity;
} }
@ -114,6 +115,12 @@ namespace DFHack
{ {
history.pop_front(); history.pop_front();
} }
/// adds the current list of entries to the given vector
void getEntries(std::vector<std::string> &entries)
{
for (auto &entry : history)
entries.push_back(entry);
}
private: private:
std::size_t capacity; std::size_t capacity;
std::deque <std::string> history; std::deque <std::string> history;