Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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

oroxnox/trunk: way better algorithm for the completion… more with logic and stuff

File:
1 edited

Legend:

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

    r5190 r5191  
    7171
    7272
    73   PRINTF(4)("AutoComplete on input\n");
     73  PRINTF(5)("AutoComplete on input\n");
    7474  this->emptyCompletionList();
    7575
     
    8383
    8484  // 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))
     85  if (this->input->getInput() != NULL &&
     86      strrchr(this->input->getInput(), ' ') >= this->input->getInput() + strlen(this->input->getInput())-1)
    8887  {
    8988    emptyComplete = true;
     
    9190
    9291  if (this->input->getInput() == NULL)
    93   {
    94     return this->objectComplete("", CL_SHELL_COMMAND_CLASS);
    95   }
    96 
    97   completionLine = this->input->getInput() + strspn(this->input->getInput(), " \t\n");
     92    completionLine = "";
     93  else
     94    completionLine = this->input->getInput() + strspn(this->input->getInput(), " \t\n");
    9895
    9996  SubString inputSplits(completionLine, true);
    100 
    10197
    10298  // CLASS COMPLETION
     
    107103    return false;
    108104  }
    109   else if (inputSplits.getCount() == 1 && strlen(inputSplits.getString(0)) == strlen(completionLine))
     105  else if (inputSplits.getCount() == 1 && emptyComplete == false)
    110106  {
    111107    printf("trying to complete a Class with '%s'\n", inputSplits.getString(0));
     
    113109  }
    114110
    115   // OBJECT COMPLETIONS
    116   else if ( inputSplits.getCount() <= 2 && strlen(inputSplits.getString(0)) < strlen(completionLine))
     111  // OBJECT/FUNCTION COMPLETIONS
     112  else if ( (inputSplits.getCount() == 1 && emptyComplete == true ) ||
     113             (inputSplits.getCount() == 2 && emptyComplete == false))
    117114  {
    118115    classID = ClassList::StringToID(inputSplits.getString(0));
Note: See TracChangeset for help on using the changeset viewer.