Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5190 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Sep 18, 2005, 12:09:36 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: construct for ShellCommandAlias… have to work some more on this :/

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

Legend:

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

    r5189 r5190  
    6161}
    6262
    63 tList<const char>* ShellCommandClass::getCommandListOfClass(const char* className)
    64 {
    65   tList<const char>* retList;
     63bool ShellCommandClass::getCommandListOfClass(const char* className, tList<const char>* stringList)
     64{
     65  if (stringList == NULL)
     66    return false;
     67
    6668  tIterator<ShellCommandClass>* iterator = ShellCommandClass::commandClassList->getIterator();
    6769  ShellCommandClass* elem = iterator->firstElement();
     
    7476      while (command != NULL)
    7577      {
    76         retList->add(command->getName());
     78        stringList->add(command->getName());
    7779        command = itFkt->nextElement();
    7880      }
     
    8385  }
    8486  delete iterator;
    85   return retList;
     87  return true;
    8688}
    8789
  • trunk/src/lib/shell/shell_command.h

    r5189 r5190  
    4343////////////////
    4444class ShellCommandBase;
     45class ShellCommandAlias;
    4546
    4647//! A class to hold all Classes that have (once) registered Commands.
     
    5152  public:
    5253    static const tList<ShellCommandClass>* getCommandClassList() { return ShellCommandClass::commandClassList; };
    53     static tList<const char>* getCommandListOfClass(const char* className);
     54    static bool ShellCommandClass::getCommandListOfClass(const char* className, tList<const char>* stringList);
     55
    5456    static ShellCommandClass* getCommandClass(const char* className);
    5557    static void unregisterAllCommands();
     
    6769    tList<ShellCommandBase>*         commandList;               //!< A list of Commands from this Class
    6870    static tList<ShellCommandClass>* commandClassList;          //!< A list of Classes
     71    static tList<ShellCommandAlias>* aliasesList;               //!< An Alias to A Command. (only for classes with one Instance)
    6972};
    7073
     
    7881
    7982    ShellCommandBase* describe(const char* description);
     83    ShellCommandBase* setAlias(const char* alias);
    8084
    8185    /** @returns the CommandList of the Shell */
     
    312316};
    313317
     318class ShellCommandAlias
     319{
     320  public:
     321    ShellCommandAlias(const char* aliasName, ShellCommandBase* command) { this->aliasName = aliasName; this->command = command; };
     322  private:
     323    const char*         aliasName;
     324    ShellCommandBase*   command;
     325};
     326
     327
    314328#endif /* _SHELL_COMMAND_H */
  • trunk/src/lib/shell/shell_completion.cc

    r5188 r5190  
    6868  long classID;                    //< the classID retrieved from the Class.
    6969  tList<BaseObject>* objectList;   //< the list of Objects stored in classID
    70   char* classBegin;                //< the beginn of the slass string
    71   char* classEnd;                  //< the end of the class string
    72   char* objectBegin;               //< the begin of the object string
    73   char* objectEnd;                 //< the end of the object string
    74   char* functionBegin;             //< the begin of the function string
    75   char* functionEnd;               //< the end of the function string
     70  bool emptyComplete = false;      //< if the completion input is empty string. e.g ""
     71
    7672
    7773  PRINTF(4)("AutoComplete on input\n");
     
    8581    return false;
    8682  }
     83
     84  // Check if we are in a input. eg. the supplied string "class " and now we complete either function or object
     85  if (this->input->getInput() == NULL || strlen(this->input->getInput()) == 0 ||
     86      (this->input->getInput() != NULL &&
     87      strrchr(this->input->getInput(), ' ') >= this->input->getInput() + strlen(this->input->getInput())-1))
     88  {
     89    emptyComplete = true;
     90  }
     91
    8792  if (this->input->getInput() == NULL)
     93  {
    8894    return this->objectComplete("", CL_SHELL_COMMAND_CLASS);
    89 
     95  }
    9096
    9197  completionLine = this->input->getInput() + strspn(this->input->getInput(), " \t\n");
     
    169175    else
    170176      return false;
     177    delete classList;
    171178  }
    172179  else
     
    333340}
    334341
     342
    335343void ShellCompletion::emptyCompletionList()
    336344{
Note: See TracChangeset for help on using the changeset viewer.