[Orxonox-commit 2529] r7234 - code/branches/consolecommands3/src/libraries/core/command
landauf at orxonox.net
landauf at orxonox.net
Sat Aug 28 00:37:38 CEST 2010
Author: landauf
Date: 2010-08-28 00:37:38 +0200 (Sat, 28 Aug 2010)
New Revision: 7234
Modified:
code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc
code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.h
code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.cc
code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.h
Log:
the unhide command now also supports auto-completion for the hidden commands
Modified: code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc 2010-08-27 22:02:03 UTC (rev 7233)
+++ code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc 2010-08-27 22:37:38 UTC (rev 7234)
@@ -122,16 +122,6 @@
return detail::_subcommands(fragment, group, false);
}
- ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(hiddengroupsandcommands)()
- {
- return detail::_groupsandcommands(true);
- }
-
- ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(hiddensubcommands)(const std::string& fragment, const std::string& group)
- {
- return detail::_subcommands(fragment, group, true);
- }
-
ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI(command)(const std::string& fragment)
{
CommandEvaluation evaluation = CommandExecutor::evaluate(fragment);
@@ -149,6 +139,31 @@
}
}
+ ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI(hiddencommand)(const std::string& fragment)
+ {
+ SubString tokens(fragment, " ", SubString::WhiteSpaces, false, '\\', true, '"', true, '(', ')', true, '\0');
+
+ if (tokens.size() == 0)
+ return detail::_groupsandcommands(true);
+
+ if (_ConsoleCommand::getCommandLC(getLowercase(tokens[0])))
+ return ARGUMENT_COMPLETION_FUNCTION_CALL(command)(fragment);
+
+ if (tokens.size() == 1)
+ {
+ std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = _ConsoleCommand::getCommands().find(tokens[0]);
+ if (it_group != _ConsoleCommand::getCommands().end())
+ return detail::_subcommands(fragment, tokens[0], true);
+ else
+ return detail::_groupsandcommands(true);
+ }
+
+ if (_ConsoleCommand::getCommandLC(getLowercase(tokens[0]), getLowercase(tokens[1])))
+ return ARGUMENT_COMPLETION_FUNCTION_CALL(command)(fragment);
+
+ return ArgumentCompletionList();
+ }
+
ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(files)(const std::string& fragment)
{
ArgumentCompletionList dirlist;
Modified: code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.h 2010-08-27 22:02:03 UTC (rev 7233)
+++ code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.h 2010-08-27 22:37:38 UTC (rev 7234)
@@ -51,7 +51,9 @@
\
ArgumentCompletionList acf_##functionname
+#define ARGUMENT_COMPLETION_FUNCTION_CALL(functionname) acf_##functionname
+
namespace orxonox
{
namespace autocompletion
@@ -59,9 +61,8 @@
ARGUMENT_COMPLETION_FUNCTION_DECLARATION(fallback)();
ARGUMENT_COMPLETION_FUNCTION_DECLARATION(groupsandcommands)();
ARGUMENT_COMPLETION_FUNCTION_DECLARATION(subcommands)(const std::string& fragment, const std::string& group);
- ARGUMENT_COMPLETION_FUNCTION_DECLARATION(hiddengroupsandcommands)();
- ARGUMENT_COMPLETION_FUNCTION_DECLARATION(hiddensubcommands)(const std::string& fragment, const std::string& group);
ARGUMENT_COMPLETION_FUNCTION_DECLARATION(command)(const std::string& fragment);
+ ARGUMENT_COMPLETION_FUNCTION_DECLARATION(hiddencommand)(const std::string& fragment);
ARGUMENT_COMPLETION_FUNCTION_DECLARATION(files)(const std::string& fragment);
ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingssections)();
ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingsentries)(const std::string& fragment, const std::string& section);
Modified: code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.cc 2010-08-27 22:02:03 UTC (rev 7233)
+++ code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.cc 2010-08-27 22:37:38 UTC (rev 7234)
@@ -43,10 +43,7 @@
.argumentCompleter(1, autocompletion::subcommands());
_SetConsoleCommand("unhide", &CommandExecutor::unhide)
- .argumentCompleter(0, autocompletion::hiddengroupsandcommands())
- .argumentCompleter(1, autocompletion::hiddensubcommands())
- .defaultValue(1, "")
- .defaultValue(2, "");
+ .argumentCompleter(0, autocompletion::hiddencommand());
/* static */ CommandExecutor& CommandExecutor::getInstance()
{
@@ -155,8 +152,8 @@
}
}
- /* static */ MultiType CommandExecutor::unhide(const std::string& group, const std::string& name, const std::string& arguments)
+ /* static */ MultiType CommandExecutor::unhide(const std::string& command)
{
- return CommandExecutor::queryMT(group + " " + name + " " + arguments);
+ return CommandExecutor::queryMT(command);
}
}
Modified: code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.h 2010-08-27 22:02:03 UTC (rev 7233)
+++ code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.h 2010-08-27 22:37:38 UTC (rev 7234)
@@ -58,7 +58,7 @@
static const int Deactivated = 3;
static const int Denied = 4;
- static MultiType unhide(const std::string& group, const std::string& name, const std::string& arguments);
+ static MultiType unhide(const std::string& command);
static void _autocomplete(const std::string& group, const std::string& name) {}
private:
More information about the Orxonox-commit
mailing list