Fixup autocomplete built ins per IRC

develop
Phillip Spiess 2017-11-27 13:45:58 -08:00
parent 7e55efa3f7
commit bbdf157a52
2 changed files with 26 additions and 27 deletions

@ -429,14 +429,37 @@ command_result Core::runCommand(color_ostream &out, const std::string &command)
return CR_NOT_IMPLEMENTED; return CR_NOT_IMPLEMENTED;
} }
// List of built in commands
static const std::set<std::string> built_in_commands = {
"ls" ,
"help" ,
"type" ,
"load" ,
"unload" ,
"reload" ,
"enable" ,
"disable" ,
"plug" ,
"keybinding" ,
"alias" ,
"fpause" ,
"cls" ,
"die" ,
"kill-lua" ,
"script" ,
"hide" ,
"show" ,
"sc-script"
};
static bool try_autocomplete(color_ostream &con, const std::string &first, std::string &completed) static bool try_autocomplete(color_ostream &con, const std::string &first, std::string &completed)
{ {
std::vector<std::string> possible; std::vector<std::string> possible;
// Check for possible built in commands to autocomplete first // Check for possible built in commands to autocomplete first
for (auto iter = built_in_commands.begin(); iter != built_in_commands.end(); ++iter) for (auto const &command : built_in_commands)
if (iter->substr(0, first.size()) == first) if (command.substr(0, first.size()) == first)
possible.push_back(*iter); possible.push_back(command);
auto plug_mgr = Core::getInstance().getPluginManager(); auto plug_mgr = Core::getInstance().getPluginManager();
for (auto it = plug_mgr->begin(); it != plug_mgr->end(); ++it) for (auto it = plug_mgr->begin(); it != plug_mgr->end(); ++it)

@ -30,7 +30,6 @@ distribution.
#include <vector> #include <vector>
#include <stack> #include <stack>
#include <map> #include <map>
#include <set>
#include <stdint.h> #include <stdint.h>
#include "Console.h" #include "Console.h"
#include "modules/Graphic.h" #include "modules/Graphic.h"
@ -85,29 +84,6 @@ namespace DFHack
SC_UNPAUSED = 8 SC_UNPAUSED = 8
}; };
// List of built in commands
const std::set<std::string> built_in_commands = {
"ls" ,
"help" ,
"type" ,
"load" ,
"unload" ,
"reload" ,
"enable" ,
"disable" ,
"plug" ,
"keybinding" ,
"alias" ,
"fpause" ,
"cls" ,
"die" ,
"kill-lua" ,
"script" ,
"hide" ,
"show" ,
"sc-script"
};
class DFHACK_EXPORT StateChangeScript class DFHACK_EXPORT StateChangeScript
{ {
public: public: