Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7421 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Apr 28, 2006, 2:31:13 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: more completion work

Location:
trunk/src/lib/shell
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/shell/shell_command.cc

    r7420 r7421  
    298298    }
    299299    return false;
    300 
    301 
    302     /*
    303     long classID = CL_NULL;                      //< the classID retrieved from the Class.
    304     ShellCommandClass* commandClass = NULL;      //< the command class this command applies to.
    305     const std::list<BaseObject*>* objectList = NULL;   //< the list of Objects stored in classID
    306     BaseObject* objectPointer = NULL;            //< a pointer to th Object to Execute the command on
    307     //    bool emptyComplete = false;                  //< if the completion input is empty string. e.g ""
    308     //  long completeType = SHELLC_NONE;           //< the Type we'd like to complete.
    309 
    310 
    311 
    312     // if we only have one input (!MUST BE AN ALIAS)
    313     // CHECK FOR ALIAS
    314     std::vector<ShellCommandAlias*>::const_iterator alias;
    315     for (alias = ShellCommandAlias::getAliases().begin(); alias != ShellCommandAlias::getAliases().end(); alias++ )
    316     {
    317       if (inputSplits.getString(0) == (*alias)->getName() && (*alias)->getCommand() != NULL &&
    318           (*alias)->getCommand()->shellClass != NULL )
    319       {
    320         objectList = ClassList::getList((*alias)->getCommand()->shellClass->getName());
    321         if (objectList != NULL)
    322         {
    323           (*(*alias)->getCommand()->executor)(objectList->front(), inputSplits.getSubSet(1).join());
    324           return true;
    325         }
    326       }
    327     }
    328 
    329     // looking for a Matching Class (in the First Argument)
    330     std::vector<ShellCommandClass*>::iterator commandClassIT;
    331     for (commandClassIT = ShellCommandClass::commandClassList.begin(); commandClassIT != ShellCommandClass::commandClassList.end(); commandClassIT++)
    332     {
    333       if (inputSplits[0] == (*commandClassIT)->getName())
    334       {
    335         //elemCL->getName();
    336         classID = ClassList::StringToID((*commandClassIT)->getName());
    337         commandClass = (*commandClassIT);
    338         objectList = ClassList::getList((ClassID)classID);
    339         break;
    340       }
    341     }
    342 
    343     // Second Agument. (either Object, or Function)
    344     if (commandClass != NULL && inputSplits.size() >= 2)
    345     {
    346       int fktPos = 1; // The position of the Function (either at pos 1(if object given), or 2)
    347       // If we have an ObjectList.
    348       if (objectList != NULL)
    349       {
    350         // Checking for a Match in the Objects of classID (else take the first)
    351         std::list<BaseObject*>::const_iterator object;
    352         for (object = objectList->begin(); object != objectList->end(); object++)
    353         {
    354           if ((*object)->getName() != NULL && inputSplits[1] == (*object)->getName())
    355           {
    356             /// TODO make this work for multiple Objects at once.
    357             objectPointer = (*object);
    358             fktPos = 2;
    359             break;
    360           }
    361         }
    362 
    363         // if we did not find an Object with matching name, take the first.
    364         if (objectPointer == NULL)
    365           objectPointer = objectList->front();
    366       }
    367 
    368       // match a function.
    369       if (commandClass != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits.size() >= 3)))
    370       {
    371         std::vector<ShellCommand*>::iterator cmdIT;
    372         for (cmdIT = commandClass->commandList.begin(); cmdIT != commandClass->commandList.end(); cmdIT++)
    373         {
    374           if (inputSplits[fktPos] == (*cmdIT)->getName())
    375           {
    376             if (objectPointer == NULL && (*cmdIT)->executor->getType() & Executor_Objective)
    377               return false;
    378             else
    379             {
    380               (*(*cmdIT)->executor)(objectPointer, inputSplits.getSubSet(fktPos+1).join()); /// TODO CHECK IF OK
    381               return true;
    382             }
    383           }
    384         }
    385       }
    386     }
    387     return false;
    388     */
    389300  }
    390301
  • trunk/src/lib/shell/shell_completion.cc

    r7415 r7421  
    100100
    101101    // Looking for ParameterCompletions.
    102     if (completeType == NullCompletion)
    103     {
    104       unsigned int parameterBegin = parameterBegin;
     102    {
     103      unsigned int parameterBegin;
    105104      if ((command = ShellCommand::getCommandFromInput(inputSplits, parameterBegin)) != NULL)
     105      {
    106106        completeType |= ParamCompletion;
    107       if (emptyComplete)
    108         completeParam = inputSplits.size() - parameterBegin;
    109       else
    110         completeParam = inputSplits.size() - parameterBegin - 1;
     107        if (emptyComplete)
     108          completeParam = inputSplits.size() - parameterBegin;
     109        else
     110          completeParam = inputSplits.size() - parameterBegin - 1;
     111      }
    111112    }
    112113
     
    315316    switch (type)
    316317    {
    317       default:// SHELLC_NONE
     318        default:// SHELLC_NONE
    318319        return typeNames[0];
    319       case  ClassCompletion:
     320        case  ClassCompletion:
    320321        return typeNames[1];
    321       case ObjectCompletion:
     322        case ObjectCompletion:
    322323        return typeNames[2];
    323       case FunctionCompletion:
     324        case FunctionCompletion:
    324325        return typeNames[3];
    325       case AliasCompletion:
     326        case AliasCompletion:
    326327        return typeNames[4];
    327       case ParamCompletion:
     328        case ParamCompletion:
    328329        return typeNames[5];
    329330    }
Note: See TracChangeset for help on using the changeset viewer.