Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Apr 27, 2006, 5:49:12 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: more exists functions to ClassList, and improved shellcompletion

File:
1 edited

Legend:

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

    r7393 r7403  
    5151  bool ShellCompletion::autoComplete(std::string& input)
    5252  {
    53     long classID;                               //< the classID retrieved from the Class.
    54     const std::list<BaseObject*>* objectList;   //< the list of Objects stored in classID
     53    long classID = CL_NULL;                     //< the classID retrieved from the Class.
     54    const std::list<BaseObject*>* objectList;   //< the list of Objects stored in classID's ClassList
    5555    bool emptyComplete = false;                 //< if the completion input is empty string. e.g ""
    5656    long completeType = NullCompletion;         //< the Type we'd like to complete.
    57     std::string completeString;                 //< the string to complete.
     57    std::string completeString = "";            //< the string to complete.
    5858
    5959
     
    6262
    6363    // Check if we are in a input. eg. the supplied string "class " and now we complete either function or object
    64     if (input[input.size()-1] == ' ')
     64    if (input.empty() || input[input.size()-1] == ' ')
    6565      emptyComplete = true;
    6666
     
    6969
    7070    // What String will be completed
    71     if (emptyComplete == true)
    72       completeString = "";
    73     else
     71    if (!emptyComplete && inputSplits.size() >= 1)
    7472      completeString = inputSplits.getString(inputSplits.size()-1);
    7573
    76     // CLASS COMPLETION
    77     if (inputSplits.size() == 0)
     74    // CLASS/ALIAS COMPLETION (on first argument)
     75    if (inputSplits.size() == 0 || (!emptyComplete && inputSplits.size() == 1))
    7876    {
    7977      completeType |= ClassCompletion;
    8078      completeType |= AliasCompletion;
    8179    }
    82     else if (inputSplits.size() == 1 && emptyComplete == false)
    83     {
    84       completeType |= ClassCompletion;
    85       completeType |= AliasCompletion;
    86     }
    8780
    8881    // OBJECT/FUNCTION COMPLETIONS
    89     else if ((inputSplits.size() == 1 && emptyComplete == true) ||
    90              (inputSplits.size() == 2 && emptyComplete == false))
     82    else if ((emptyComplete && inputSplits.size() == 1) ||
     83              (!emptyComplete && inputSplits.size() == 2))
    9184    {
    9285      classID = ClassList::StringToID(inputSplits.getString(0));
     
    9487      if (classID != CL_NULL)
    9588        completeType |= ObjectCompletion;
    96       //if (objectList != NULL && objectList->getSize() == 1)
    9789      completeType |= FunctionCompletion;
    9890    }
    99     else if ((inputSplits.size() == 2 && emptyComplete == true) ||
    100              (inputSplits.size() == 3 && emptyComplete == false))
    101     {
    102       classID = ClassList::StringToID(inputSplits.getString(0));
    103       if (classID == CL_NULL)
    104         return false;
    105       else
     91    else if ((emptyComplete && inputSplits.size() == 2 ) ||
     92             (!emptyComplete && inputSplits.size() == 3))
     93    {
     94      if (ClassList::exists(inputSplits[0], inputSplits[1]))
    10695        completeType |= FunctionCompletion;
    10796    }
Note: See TracChangeset for help on using the changeset viewer.