Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2008, 3:08:39 AM (16 years ago)
Author:
landauf
Message:

CommandExecutor seems to work very well right now. yet to come: autocompletion lists

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/CommandEvaluation.cc

    r1424 r1427  
    5757        this->functionclass_ = 0;
    5858        this->function_ = 0;
     59        this->possibleArgument_ = "";
     60        this->argument_ = "";
    5961
    6062        this->errorMessage_ = "";
     
    9799        if (!this->bNewCommand_)
    98100        {
    99 std::cout << "ASDF" << std::endl;
     101std::cout << "not new" << std::endl;
    100102            switch (this->state_)
    101103            {
     
    106108                case CS_ShortcutOrIdentifier:
    107109                    if (this->function_)
    108                         return CommandExecutor::complete(this->function_->getName() + " ");
     110                    {
     111                        if (this->function_->getParamCount() == 0)
     112                            return /*CommandExecutor::complete*/(this->command_ = this->function_->getName());
     113                        else
     114                            return /*CommandExecutor::complete*/(this->command_ = this->function_->getName() + " ");
     115                    }
    109116                    else if (this->functionclass_)
    110                         return CommandExecutor::complete(this->functionclass_->getName() + " ");
     117                        return /*CommandExecutor::complete*/(this->command_ = this->functionclass_->getName() + " ");
    111118                    break;
    112119                case CS_Function:
    113120                    if (this->function_)
    114                         return CommandExecutor::complete(this->functionclass_->getName() + " " + this->function_->getName() + " ");
    115                     break;
     121                    {
     122                        if (this->function_->getParamCount() == 0)
     123                            return /*CommandExecutor::complete*/(this->command_ = this->functionclass_->getName() + " " + this->function_->getName());
     124                        else
     125                            return /*CommandExecutor::complete*/(this->command_ = this->functionclass_->getName() + " " + this->function_->getName() + " ");
     126                    }
     127                    break;
     128                case CS_ParamPreparation:
    116129                case CS_Params:
    117                     break;
     130                {
     131                    unsigned int maxIndex = this->commandTokens_.size();
     132                    if (this->command_[this->command_.size() - 1] != ' ')
     133                        maxIndex -= 1;
     134                    std::string whitespace = "";
     135                    if (this->function_->getParamCount() > (maxIndex + 1 - this->getStartindex()))
     136                        whitespace = " ";
     137
     138                    if (this->possibleArgument_ != "")
     139                    {
     140                        maxIndex -= 1;
     141                        this->argument_ = this->possibleArgument_;
     142                    }
     143
     144                    return /*CommandExecutor::complete*/(this->command_ = this->commandTokens_.subSet(0, maxIndex).join() + " " + this->argument_ + whitespace);
     145                    break;
     146                }
    118147                case CS_Finished:
    119148                    break;
     
    144173                return CommandEvaluation::dump(this->listOfPossibleFunctions_);
    145174                break;
     175            case CS_ParamPreparation:
    146176            case CS_Params:
    147177                if (this->listOfPossibleArguments_.size() > 0)
     
    241271    std::string CommandEvaluation::dump(const ConsoleCommand* command)
    242272    {
    243         std::string output = command->getName() + ": ";
     273        std::string output = command->getName();
     274        if (command->getParamCount() > 0)
     275            output += ": ";
     276
    244277        for (unsigned int i = 0; i < command->getParamCount(); i++)
    245278        {
Note: See TracChangeset for help on using the changeset viewer.