Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7234


Ignore:
Timestamp:
Aug 28, 2010, 12:37:38 AM (14 years ago)
Author:
landauf
Message:

the unhide command now also supports auto-completion for the hidden commands

Location:
code/branches/consolecommands3/src/libraries/core/command
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc

    r7233 r7234  
    123123        }
    124124
    125         ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(hiddengroupsandcommands)()
    126         {
    127             return detail::_groupsandcommands(true);
    128         }
    129 
    130         ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(hiddensubcommands)(const std::string& fragment, const std::string& group)
    131         {
    132             return detail::_subcommands(fragment, group, true);
    133         }
    134 
    135125        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI(command)(const std::string& fragment)
    136126        {
     
    148138                return list;
    149139            }
     140        }
     141
     142        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI(hiddencommand)(const std::string& fragment)
     143        {
     144            SubString tokens(fragment, " ", SubString::WhiteSpaces, false, '\\', true, '"', true, '(', ')', true, '\0');
     145
     146            if (tokens.size() == 0)
     147                return detail::_groupsandcommands(true);
     148
     149            if (_ConsoleCommand::getCommandLC(getLowercase(tokens[0])))
     150                return ARGUMENT_COMPLETION_FUNCTION_CALL(command)(fragment);
     151
     152            if (tokens.size() == 1)
     153            {
     154                std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = _ConsoleCommand::getCommands().find(tokens[0]);
     155                if (it_group != _ConsoleCommand::getCommands().end())
     156                    return detail::_subcommands(fragment, tokens[0], true);
     157                else
     158                    return detail::_groupsandcommands(true);
     159            }
     160
     161            if (_ConsoleCommand::getCommandLC(getLowercase(tokens[0]), getLowercase(tokens[1])))
     162                return ARGUMENT_COMPLETION_FUNCTION_CALL(command)(fragment);
     163
     164            return ArgumentCompletionList();
    150165        }
    151166
  • code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.h

    r7233 r7234  
    5252    ArgumentCompletionList acf_##functionname
    5353
     54#define ARGUMENT_COMPLETION_FUNCTION_CALL(functionname) acf_##functionname
     55
    5456
    5557namespace orxonox
     
    6062        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(groupsandcommands)();
    6163        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(subcommands)(const std::string& fragment, const std::string& group);
    62         ARGUMENT_COMPLETION_FUNCTION_DECLARATION(hiddengroupsandcommands)();
    63         ARGUMENT_COMPLETION_FUNCTION_DECLARATION(hiddensubcommands)(const std::string& fragment, const std::string& group);
    6464        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(command)(const std::string& fragment);
     65        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(hiddencommand)(const std::string& fragment);
    6566        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(files)(const std::string& fragment);
    6667        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingssections)();
  • code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.cc

    r7233 r7234  
    4444
    4545    _SetConsoleCommand("unhide", &CommandExecutor::unhide)
    46         .argumentCompleter(0, autocompletion::hiddengroupsandcommands())
    47         .argumentCompleter(1, autocompletion::hiddensubcommands())
    48         .defaultValue(1, "")
    49         .defaultValue(2, "");
     46        .argumentCompleter(0, autocompletion::hiddencommand());
    5047
    5148    /* static */ CommandExecutor& CommandExecutor::getInstance()
     
    156153    }
    157154
    158     /* static */ MultiType CommandExecutor::unhide(const std::string& group, const std::string& name, const std::string& arguments)
     155    /* static */ MultiType CommandExecutor::unhide(const std::string& command)
    159156    {
    160         return CommandExecutor::queryMT(group + " " + name + " " + arguments);
     157        return CommandExecutor::queryMT(command);
    161158    }
    162159}
  • code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.h

    r7233 r7234  
    5959            static const int Denied = 4;
    6060
    61             static MultiType unhide(const std::string& group, const std::string& name, const std::string& arguments);
     61            static MultiType unhide(const std::string& command);
    6262            static void _autocomplete(const std::string& group, const std::string& name) {}
    6363
Note: See TracChangeset for help on using the changeset viewer.