Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5185 in orxonox.OLD


Ignore:
Timestamp:
Sep 15, 2005, 5:16:14 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: half-faulty object Completion…. fixing

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

Legend:

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

    r5184 r5185  
    7373  char* functionEnd;    //< the end of the function string
    7474
     75  PRINTF(4)("AutoComplete on input\n");
     76
    7577  if (input != NULL)
    7678    this->input = input;
    7779  if (this->input == NULL)
    78     return false;
    79   if (this->input->getText() == NULL)
     80  {
     81    PRINTF(2)("No ShellInput supplied\n");
     82    return false;
     83  }
     84  if (this->input->getInput() == NULL)
    8085    return this->classComplete("");
    8186
    82   completionLine = this->input->getText() + strspn(this->input->getText(), " \t\n");
     87
     88  completionLine = this->input->getInput() + strspn(this->input->getInput(), " \t\n");
    8389
    8490  SubString inputSplits(completionLine, true);
    8591
     92
     93  // CLASS COMPLETION
    8694  if (inputSplits.getCount() == 0)
    8795  {
    88 //    this->classComplete("");
     96    PRINTF(5)("Listing all Classes\n");
     97    this->classComplete("");
    8998    return false;
    9099  }
    91100  else if (inputSplits.getCount() == 1 && strlen(inputSplits.getString(0)) == strlen(completionLine))
    92101  {
    93 //    this->classComplete(inputSplits.getString(0));
    94 
    95   }
    96 
    97   if (inputSplits.getCount() > 1)
    98   {
    99 
     102    printf("trying to complete a Class with %d\n", inputSplits.getString(0));
     103    this->classComplete(inputSplits.getString(0));
     104  }
     105
     106  // OBJECT COMPLETIONS
     107  else if ( inputSplits.getCount() <= 2 && strlen(inputSplits.getString(0)) < strlen(completionLine))
     108  {
     109    classID = ClassList::StringToID(inputSplits.getString(0));
     110    if (classID == CL_NULL)
     111      return false;
     112    if (inputSplits.getCount()==2)
     113      this->objectComplete(inputSplits.getString(1), classID);
     114    else
     115      this->objectComplete("", classID);
    100116  }
    101117
     
    143159    const tList<const char>* classList = this->createCompleteList(clList, classBegin);
    144160    if (classList != NULL)
    145       this->generalComplete(classList, classBegin, "%s::", "::");
     161      this->generalComplete(classList, classBegin, "CL: %s ");
    146162    else
    147163      return false;
     
    170186    const tList<const char>* objectList = this->createCompleteList(boList, objectBegin);
    171187    if (objectList != NULL)
    172       this->generalComplete(objectList, objectBegin, "%s");
     188      this->generalComplete(objectList, objectBegin, "%s", " ");
    173189    else
    174190      return false;
     
    198214bool ShellCompletion::generalComplete(const tList<const char>* stringList, const char* begin, const char* displayAs, const char* addBack, const char* addFront)
    199215{
     216  if (stringList == NULL || this->input == NULL )
     217    return false;
    200218  if (stringList->getSize() == 0)
    201219    return false;
     
    214232    for (unsigned int i = inputLenght; i < addLength; i++)
    215233      if (addString[i] != charElem[i])
    216     {
    217       addLength = i;
    218       break;
    219     }
     234      {
     235       addLength = i;
     236       break;
     237      }
    220238    charElem = charIterator->nextElement();
    221239  }
     
    233251     this->input->addCharacters(adder);
    234252
    235       if (addBack != NULL && stringList->getSize() == 1)
    236        this->input->addCharacters("::");
     253      if (stringList->getSize() == 1)
     254      {
     255        if ( addBack != NULL )
     256         this->input->addCharacters(addBack);
     257        this->input->addCharacter(' ');
     258      }
    237259     delete[] adder;
    238260    }
     
    263285  while (enumString != NULL)
    264286  {
    265     if (strlen(enumString)>searchLength+1 &&
     287    if (strlen(enumString) >= searchLength &&
    266288        !strncasecmp(enumString, classNameBegin, searchLength))
    267289    {
     290      printf("%s\n", enumString);
    268291      this->completionList->add(enumString);
    269292    }
     
    296319  {
    297320    if (enumBO->getName() != NULL &&
    298         strlen(enumBO->getName())>searchLength+1 &&
     321        strlen(enumBO->getName()) >= searchLength &&
    299322        !strncasecmp(enumBO->getName(), classNameBegin, searchLength))
    300323    {
  • trunk/src/lib/shell/shell_input.h

    r5182 r5185  
    2222  virtual ~ShellInput();
    2323
     24  /** @returns the inputLine */
     25  const char* getInput() const { return this->inputLine; };
    2426
    2527  // InputLine
Note: See TracChangeset for help on using the changeset viewer.