Tab-completion for :commands
This commit is contained in:
parent
3a19893efe
commit
3c7c1880d1
3 changed files with 20 additions and 1 deletions
|
@ -1945,6 +1945,16 @@ class map_command_handler
|
|||
"for a list of available commands.", symbols));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> get_commands_list() const
|
||||
{
|
||||
std::vector<std::string> res;
|
||||
foreach(typename command_map::value_type i, command_map_) {
|
||||
res.push_back(i.first);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
protected:
|
||||
void init_map_default()
|
||||
{
|
||||
|
@ -2315,6 +2325,7 @@ class console_handler : public map_command_handler<console_handler>, private cha
|
|||
: chmap(), chat_command_handler(menu_handler, true), menu_handler_(menu_handler), team_num_(resources::controller->current_side())
|
||||
{}
|
||||
using chmap::dispatch; //disambiguate
|
||||
using chmap::get_commands_list;
|
||||
|
||||
protected:
|
||||
//chat_command_handler's init_map() and hanlers will end up calling these.
|
||||
|
@ -3004,6 +3015,12 @@ void menu_handler::do_command(const std::string& str)
|
|||
ch.dispatch(str);
|
||||
}
|
||||
|
||||
std::vector<std::string> menu_handler::get_commands_list()
|
||||
{
|
||||
console_handler ch(*this);
|
||||
return ch.get_commands_list();
|
||||
}
|
||||
|
||||
void console_handler::do_refresh() {
|
||||
image::flush_cache();
|
||||
menu_handler_.gui_->redraw_everything();
|
||||
|
|
|
@ -87,6 +87,7 @@ public:
|
|||
void user_command_2();
|
||||
void user_command_3();
|
||||
#endif
|
||||
std::vector<std::string> get_commands_list();
|
||||
|
||||
unit_map::iterator current_unit();
|
||||
unit_map::const_iterator current_unit() const
|
||||
|
|
|
@ -846,7 +846,8 @@ void play_controller::tab()
|
|||
switch(mode) {
|
||||
case gui::TEXTBOX_COMMAND:
|
||||
{
|
||||
//TODO List commands
|
||||
std::vector<std::string> commands = menu_handler_.get_commands_list();
|
||||
dictionary.insert(commands.begin(), commands.end());
|
||||
break;
|
||||
}
|
||||
case gui::TEXTBOX_SEARCH:
|
||||
|
|
Loading…
Add table
Reference in a new issue