Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5194 in orxonox.OLD


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

orxonox/trunk: shell now also autocompletes Commands

Location:
trunk/src/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/lang/class_list.cc

    r5140 r5194  
    289289 * @return a String containing the name of the Class, NULL if the Class was not found
    290290 */
    291 const char* ClassList::IDToString(ClassID classID)
     291const char* ClassList::IDToString(long classID)
    292292{
    293293  if(likely(ClassList::first != NULL))
  • trunk/src/lib/lang/class_list.h

    r5113 r5194  
    4646    static void                     whatIs(const BaseObject* object);
    4747
    48     static const char*              IDToString(ClassID classID = CL_NULL);
     48    static const char*              IDToString(long classID = CL_NULL);
    4949    static long                     StringToID(const char* className);
    5050    static void                     debug(unsigned int debugLevel = 0, long classID = CL_NULL);
  • trunk/src/lib/shell/shell_completion.cc

    r5193 r5194  
    1919
    2020#include "shell_input.h"
     21#include "shell_command.h"
    2122
    2223#include "substring.h"
     
    6465bool ShellCompletion::autoComplete(ShellInput* input)
    6566{
    66   const char* completionLine;
     67  const char* completionLine;      //< the inputLine we complete.
    6768
    6869  long classID;                    //< the classID retrieved from the Class.
    6970  tList<BaseObject>* objectList;   //< the list of Objects stored in classID
    7071  bool emptyComplete = false;      //< if the completion input is empty string. e.g ""
    71   SHELLC_TYPE firstType = SHELLC_NONE;
    72   SHELLC_TYPE secondType = SHELLC_NONE;
    73   long completeType = SHELLC_NONE;
    74   const char* completeString;
     72  long completeType = SHELLC_NONE; //< the Type we'd like to complete.
     73  const char* completeString;      //< the string to complete.
    7574
    7675
     
    123122  {
    124123    classID = ClassList::StringToID(inputSplits.getString(0));
     124    objectList = ClassList::getList(classID);
    125125    if (classID == CL_NULL)
    126     {
    127126      return false;
    128     }
    129127    else
    130128    {
     129      if (objectList != NULL && objectList->getSize() == 1)
     130        completeType |= SHELLC_FUNCTION;
    131131      completeType |= SHELLC_OBJECT;
    132132    }
     133  }
     134  else if ((inputSplits.getCount() == 2 && emptyComplete == true) ||
     135            (inputSplits.getCount() == 3 && emptyComplete == false))
     136  {
     137    classID = ClassList::StringToID(inputSplits.getString(0));
     138    if (classID == CL_NULL)
     139      return false;
     140    else
     141     completeType |= SHELLC_FUNCTION;
    133142  }
    134143
     
    137146  if (completeType & SHELLC_OBJECT)
    138147    this->objectComplete(completeString, classID);
    139 
    140   if (emptyComplete == false)
    141     this->generalComplete(inputSplits.getString(inputSplits.getCount()-1));
    142   else
    143     this->generalComplete("");
     148  if (completeType & SHELLC_FUNCTION)
     149    this->functionComplete(completeString, classID);
     150
     151
     152  this->generalComplete(completeString);
     153  return true;
    144154}
    145155
     
    190200 * @param functionBegin the beginning of the function String
    191201 */
    192 bool ShellCompletion::functionComplete(const char* functionBegin)
    193 {
     202bool ShellCompletion::functionComplete(const char* functionBegin, long classID)
     203{
     204  if (unlikely(functionBegin == NULL))
     205    return false;
     206  tList<const char> fktList;
     207  ShellCommandClass::getCommandListOfClass(ClassList::IDToString(classID), &fktList);
     208  //printf("%s\n", boList->firstElement()->getName());
     209  if (!this->addToCompleteList(&fktList, functionBegin))
     210    return false;
     211  return true;
    194212}
    195213
  • trunk/src/lib/shell/shell_completion.h

    r5193 r5194  
    4040  bool objectComplete(const char* objectBegin, long classID);
    4141  bool objectMatch(const char* objectBegin, long classID, unsigned int* length);
    42   bool functionComplete(const char* functionBegin);
     42  bool functionComplete(const char* functionBegin, long classID);
    4343  bool functionMatch(const char* functionBegin, long classID, unsigned int* length);
    4444
Note: See TracChangeset for help on using the changeset viewer.