Construct on first use for completion_commands

This commit is contained in:
Jethro Grassie 2017-08-16 09:34:32 -04:00
parent 67dd4933e6
commit 1249a2a550
No known key found for this signature in database
GPG key ID: DE8ED755616565BB
2 changed files with 23 additions and 15 deletions

View file

@ -21,23 +21,15 @@ namespace rdln
}
void get_line(std::string& line) const;
void set_prompt(const std::string& prompt);
static void add_completion(const std::string& command)
{
if(std::find(completion_commands.begin(), completion_commands.end(), command) != completion_commands.end())
return;
completion_commands.push_back(command);
}
static const std::vector<std::string>& get_completions()
{
return completion_commands;
}
static void add_completion(const std::string& command);
static const std::vector<std::string>& get_completions();
protected:
virtual int sync();
private:
std::streambuf* m_cout_buf;
static std::vector<std::string> completion_commands;
static std::vector<std::string>& completion_commands();
};
class suspend_readline