Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7371 in orxonox.OLD for trunk/src/lib/shell/shell_completion.cc


Ignore:
Timestamp:
Apr 26, 2006, 2:12:45 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: better completion-algos

File:
1 edited

Legend:

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

    r7344 r7371  
    6363
    6464  PRINTF(5)("AutoComplete on input\n");
    65   this->emptyCompletionList();
     65  this->clearCompletionList();
    6666
    6767  // Check if we are in a input. eg. the supplied string "class " and now we complete either function or object
     
    135135  if (clList != NULL)
    136136  {
    137     if (!this->addToCompleteList(clList, classBegin, SHELLC_CLASS))
     137    if (!this->addToCompleteList(*clList, classBegin, SHELLC_CLASS))
    138138      return false;
    139139  }
     
    157157    if (classID == CL_SHELL_COMMAND_CLASS)
    158158      type = SHELLC_CLASS;
    159     if (!this->addToCompleteList(boList, objectBegin, type))
     159    if (!this->addToCompleteList(*boList, objectBegin, type))
    160160      return false;
    161161  }
     
    175175  ShellCommandClass::getCommandListOfClass(className, &fktList);
    176176  //printf("%s\n", boList->firstElement()->getName());
    177   if (!this->addToCompleteList(&fktList, functionBegin, SHELLC_FUNCTION))
     177  if (!this->addToCompleteList(fktList, functionBegin, SHELLC_FUNCTION))
    178178    return false;
    179179  return true;
     
    190190  ShellCommandClass::getCommandListOfAlias(&aliasList);
    191191  //printf("%s\n", boList->firstElement()->getName());
    192   if (!this->addToCompleteList(&aliasList, aliasBegin, SHELLC_ALIAS))
     192  if (!this->addToCompleteList(aliasList, aliasBegin, SHELLC_ALIAS))
    193193    return false;
    194194  return true;
     
    265265 * !! The strings MUST NOT be deleted !!
    266266 */
    267 bool ShellCompletion::addToCompleteList(const std::list<std::string>* inputList, const std::string& completionBegin, SHELLC_TYPE type)
    268 {
    269   if (inputList == NULL)
    270     return false;
     267bool ShellCompletion::addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, SHELLC_TYPE type)
     268{
    271269  unsigned int searchLength = completionBegin.size();
    272270
    273   list<std::string>::const_iterator string;
    274   for (string = inputList->begin(); string != inputList->end(); string++)
     271  std::list<std::string>::const_iterator string;
     272  for (string = inputList.begin(); string != inputList.end(); string++)
    275273  {
    276274    if ((*string).size() >= searchLength &&
    277           !strncasecmp((*string).c_str(), completionBegin.c_str(), searchLength))
     275          !nocaseCmp(*string, completionBegin, searchLength))
    278276    {
     277      printf ("%s\n", (*string).c_str());
    279278      ShellC_Element newElem;
    280       newElem.name = (*string).c_str();
     279      newElem.name = (*string);
    281280      newElem.type = type;
    282281      this->completionList.push_back(newElem);
     
    292291 * !! The strings MUST NOT be deleted !!
    293292 */
    294 bool ShellCompletion::addToCompleteList(const std::list<BaseObject*>* inputList, const std::string& completionBegin, SHELLC_TYPE type)
    295 {
    296   if (inputList == NULL)
    297     return false;
     293bool ShellCompletion::addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, SHELLC_TYPE type)
     294{
    298295  unsigned int searchLength = completionBegin.size();
    299296
    300   list<BaseObject*>::const_iterator bo;
    301   for(bo = inputList->begin(); bo != inputList->end(); bo++)
     297  std::list<BaseObject*>::const_iterator bo;
     298  for(bo = inputList.begin(); bo != inputList.end(); bo++)
    302299  {
    303300    if ((*bo)->getName() != NULL &&
    304301        strlen((*bo)->getName()) >= searchLength &&
    305           !strncasecmp((*bo)->getName(), completionBegin.c_str(), searchLength))
     302          !nocaseCmp((*bo)->getName(), completionBegin, searchLength))
    306303    {
    307304      ShellC_Element newElem;
     
    320317 * This is done at the beginning of each completion-run
    321318 */
    322 void ShellCompletion::emptyCompletionList()
     319void ShellCompletion::clearCompletionList()
    323320{
    324321  this->completionList.clear();
Note: See TracChangeset for help on using the changeset viewer.