Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 948


Ignore:
Timestamp:
Mar 28, 2008, 11:06:22 PM (16 years ago)
Author:
landauf
Message:
  • added autocompletion function to CommandExecutor
  • set default debug level of DebugLevel to 2
Location:
code/branches/core2/src/orxonox/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/core/CommandExecutor.cc

    r947 r948  
    109109            CommandExecutor::parse(command);
    110110
     111        CommandExecutor::tokens_s.split(command, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     112
    111113        switch (CommandExecutor::state_s)
    112114        {
     
    166168            CommandExecutor::parse(command);
    167169
     170        CommandExecutor::tokens_s.split(command, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     171
     172        std::list<const std::string*> temp;
     173        if (CommandExecutor::state_s == CS_Empty)
     174        {
     175            temp.insert(temp.end(), CommandExecutor::listOfPossibleShortcuts_s.begin(), CommandExecutor::listOfPossibleShortcuts_s.end());
     176            temp.insert(temp.end(), CommandExecutor::listOfPossibleFunctionClasses_s.begin(), CommandExecutor::listOfPossibleFunctionClasses_s.end());
     177        }
     178
    168179        switch (CommandExecutor::state_s)
    169180        {
    170181            case CS_Empty:
     182                return (CommandExecutor::tokens_s.subSet(0, CommandExecutor::tokens_s.size() - 1).join() + " " + CommandExecutor::getCommonBegin(temp));
    171183                break;
    172184            case CS_FunctionClass_Or_Shortcut_Or_Keyword:
    173185                break;
    174186            case CS_Shortcut_Params:
     187                if (command[command.size() - 1] != ' ')
     188                    return (command + " ");
    175189                break;
    176190            case CS_Shortcut_Finished:
    177191                break;
    178192            case CS_Function:
     193                return (CommandExecutor::tokens_s.subSet(0, CommandExecutor::tokens_s.size() - 1).join() + " " + CommandExecutor::getCommonBegin(CommandExecutor::listOfPossibleFunctions_s));
    179194                break;
    180195            case CS_Function_Params:
     196                if (command[command.size() - 1] != ' ')
     197                    return (command + " ");
    181198                break;
    182199            case CS_Function_Finished:
    183200                break;
    184201            case CS_ConfigValueClass:
     202                return (CommandExecutor::tokens_s.subSet(0, CommandExecutor::tokens_s.size() - 1).join() + " " + CommandExecutor::getCommonBegin(CommandExecutor::listOfPossibleConfigValueClasses_s));
    185203                break;
    186204            case CS_ConfigValue:
     205                return (CommandExecutor::tokens_s.subSet(0, CommandExecutor::tokens_s.size() - 1).join() + " " + CommandExecutor::getCommonBegin(CommandExecutor::listOfPossibleConfigValues_s));
    187206                break;
    188207            case CS_ConfigValueType:
     208                if (command[command.size() - 1] != ' ')
     209                    return (command + " ");
    189210                break;
    190211            case CS_ConfigValueFinished:
    191212                break;
    192213            case CS_KeybindKey:
     214                return (CommandExecutor::tokens_s.subSet(0, CommandExecutor::tokens_s.size() - 1).join() + " " + CommandExecutor::getCommonBegin(CommandExecutor::listOfPossibleKeys_s));
    193215                break;
    194216            case CS_KeybindCommand:
     217                if (command[command.size() - 1] != ' ')
     218                    return (command + " ");
    195219                break;
    196220            case CS_KeybindFinished:
     
    207231        if (CommandExecutor::lastProcessedCommand_s != command)
    208232            CommandExecutor::parse(command);
     233
     234        CommandExecutor::tokens_s.split(command, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
    209235
    210236        switch (CommandExecutor::state_s)
     
    849875        return container->getTypename();
    850876    }
     877
     878    std::string CommandExecutor::getCommonBegin(const std::list<const std::string*>& list)
     879    {
     880        if (list.size() == 0)
     881        {
     882            return "";
     883        }
     884        else if (list.size() == 1)
     885        {
     886            return ((**list.begin()) + " ");
     887        }
     888        else
     889        {
     890            std::string output = "";
     891            for (unsigned int i = 0; true; i++)
     892            {
     893                char temp = 0;
     894                for (std::list<const std::string*>::const_iterator it = list.begin(); it != list.end(); ++it)
     895                {
     896                    if ((**it).size() > i)
     897                    {
     898                        if (it == list.begin())
     899                        {
     900                            temp = (**it)[i];
     901                        }
     902                        else
     903                        {
     904                            if (temp != (**it)[i])
     905                                return output;
     906                        }
     907                    }
     908                    else
     909                    {
     910                        return output;
     911                    }
     912                }
     913                output += temp;
     914            }
     915            return output;
     916        }
     917    }
    851918}
  • code/branches/core2/src/orxonox/core/CommandExecutor.h

    r947 r948  
    107107            static std::string dump(const ConfigValueContainer* container);
    108108
     109            static std::string getCommonBegin(const std::list<const std::string*>& list);
     110
    109111            static Identifier* getIdentifierOfPossibleFunctionClass(const std::string& name);
    110112            static ExecutorStatic* getExecutorOfPossibleShortcut(const std::string& name);
  • code/branches/core2/src/orxonox/core/DebugLevel.cc

    r947 r948  
    9595
    9696        // Return a constant value while we're creating the object
    97         return 5;
     97        return 2;
    9898    }
    9999}
Note: See TracChangeset for help on using the changeset viewer.