Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5193 in orxonox.OLD for trunk/src/lib/shell


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

orxonox/trunk: better algorithms

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

Legend:

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

    r5192 r5193  
    7171  SHELLC_TYPE firstType = SHELLC_NONE;
    7272  SHELLC_TYPE secondType = SHELLC_NONE;
     73  long completeType = SHELLC_NONE;
     74  const char* completeString;
    7375
    7476
     
    9193  }
    9294
     95  // CREATE INPUTS
    9396  if (this->input->getInput() == NULL)
    9497    completionLine = "";
    9598  else
    9699    completionLine = this->input->getInput() + strspn(this->input->getInput(), " \t\n");
    97 
    98100  SubString inputSplits(completionLine, true);
     101
     102  // What String will be completed
     103  if (emptyComplete == true)
     104    completeString = "";
     105  else
     106    completeString = inputSplits.getString(inputSplits.getCount()-1);
    99107
    100108  // CLASS COMPLETION
     
    102110  {
    103111    PRINTF(5)("Listing all Classes\n");
    104     this->objectComplete("", CL_SHELL_COMMAND_CLASS);
     112    completeType |= SHELLC_CLASS;
    105113  }
    106114  else if (inputSplits.getCount() == 1 && emptyComplete == false)
    107115  {
    108116    printf("trying to complete a Class with '%s'\n", inputSplits.getString(0));
    109     this->objectComplete(inputSplits.getString(0), CL_SHELL_COMMAND_CLASS);
     117    completeType |= SHELLC_CLASS;
    110118  }
    111119
     
    121129    else
    122130    {
    123       firstType = SHELLC_CLASS;
    124       if (inputSplits.getCount() == 2)
    125       {
    126         if  (completionLine[strlen(completionLine)-1] != ' ')
    127           this->objectComplete(inputSplits.getString(1), classID);
    128       }
    129       else
    130         this->objectComplete("", classID);
    131     }
    132   }
     131      completeType |= SHELLC_OBJECT;
     132    }
     133  }
     134
     135  if (completeType & SHELLC_CLASS)
     136    this->objectComplete(completeString, CL_SHELL_COMMAND_CLASS);
     137  if (completeType & SHELLC_OBJECT)
     138    this->objectComplete(completeString, classID);
    133139
    134140  if (emptyComplete == false)
     
    168174  if (unlikely(objectBegin == NULL))
    169175    return false;
    170   tList<BaseObject>* boList = ClassList::getList(classID);
     176  const tList<BaseObject>* boList = ClassList::getList(classID);
    171177  if (boList != NULL)
    172178  {
  • trunk/src/lib/shell/shell_completion.h

    r5192 r5193  
    1616
    1717typedef enum {
    18   SHELLC_NONE,
    19   SHELLC_CLASS,
    20   SHELLC_OBJECT,
    21   SHELLC_FUNCTION,
    22   SHELLC_ALIAS,
     18  SHELLC_NONE        = 0,
     19  SHELLC_CLASS       = 1,
     20  SHELLC_OBJECT      = 2,
     21  SHELLC_FUNCTION    = 4,
     22  SHELLC_ALIAS       = 8,
    2323} SHELLC_TYPE;
    2424
Note: See TracChangeset for help on using the changeset viewer.