Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5182 in orxonox.OLD for trunk


Ignore:
Timestamp:
Sep 14, 2005, 12:45:17 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: completion works again :)
now it is time to go to bed again

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r5141 r5182  
    111111  CL_NULL_ELEMENT_2D            =    0x00000f22,
    112112  CL_SHELL                      =    0x00000f31,
     113  CL_SHELL_BUFFER               =    0x00000f32,
    113114
    114115
     
    194195  CL_NUMBER                     =    0x00000b0c,
    195196  CL_FAST_FACTORY               =    0x00000c01,
    196   CL_SHELL_COMMAND              =    0x00000c02,
    197 
     197  CL_SHELL_COMMAND              =    0x00000c11,
     198  CL_SHELL_INPUT                =    0x00000c12,
     199  CL_SHELL_COMPLETION           =    0x00000c13,
    198200
    199201  // Spatial Data Separation
  • trunk/src/lib/shell/shell_completion.cc

    r5181 r5182  
    3333 * @todo this constructor is not jet implemented - do it
    3434*/
    35 ShellCompletion::ShellCompletion ()
     35ShellCompletion::ShellCompletion(ShellInput* input)
    3636{
    3737  this->completionList = NULL;
     38  this->input = input;
    3839}
    3940
     
    6162bool ShellCompletion::autoComplete(ShellInput* input)
    6263{
     64  if (input != NULL)
     65    this->input = input;
    6366  //PRINTF(3)("AutoCompletion not implemented yet\n");
    6467
    65   char* completionLine = new char[strlen(input->getText())+1];
    66   strcpy(completionLine, input->getText());
     68  char* completionLine = new char[strlen(this->input->getText())+1];
     69  strcpy(completionLine, this->input->getText());
    6770
    6871  char* commandBegin = strrchr(completionLine, ' ');
     
    191194    adder[addLength] = '\0';
    192195
    193 
    194 /*    this->removeCharacters(inputLenght);
    195     this->addCharacters(adder);
    196     if (addBack != NULL && stringList->getSize() == 1)
    197       this->addCharacters("::");
    198     delete[] adder;*/
     196    if (this->input)
     197    {
     198     this->input->removeCharacters(inputLenght);
     199     this->input->addCharacters(adder);
     200
     201      if (addBack != NULL && stringList->getSize() == 1)
     202       this->input->addCharacters("::");
     203     delete[] adder;
     204    }
    199205  }
    200206  return true;
  • trunk/src/lib/shell/shell_completion.h

    r5181 r5182  
    1919
    2020 public:
    21   ShellCompletion();
     21  ShellCompletion(ShellInput* input = NULL);
    2222  virtual ~ShellCompletion();
    2323
     
    3636 private:
    3737   tList<const char>*       completionList;          //!< A list of completions, that are io.
     38   ShellInput*              input;
    3839};
    3940
  • trunk/src/lib/shell/shell_input.cc

    r5181 r5182  
    6464  delete[] this->inputLine;
    6565  delete this->completion;
     66
     67  tIterator<char>* itH = this->inputHistory->getIterator();
     68  char* histEl = itH->firstElement();
     69  while (histEl != NULL)
     70  {
     71    delete[] histEl;
     72    histEl = itH->nextElement();
     73  }
     74  delete itH;
     75  delete this->inputHistory;
    6676}
    6777
     
    7585  this->repeatDelay = repeatDelay;
    7686  this->repeatRate = repeatRate;
    77 
    7887}
    7988
     
    98107void ShellInput::addCharacter(char character)
    99108{
    100   char* addCharLine = new char[strlen(inputLine)+2];
     109  char* addCharLine = new char[strlen(this->inputLine)+2];
    101110
    102111  sprintf(addCharLine, "%s%c", this->inputLine, character);
    103   delete this->inputLine;
     112  delete[] this->inputLine;
    104113  this->inputLine = addCharLine;
    105   this->setText(inputLine, true);
     114  this->setText(this->inputLine, true);
    106115}
    107116
     
    112121void ShellInput::addCharacters(const char* characters)
    113122{
    114   char* addCharLine = new char[strlen(inputLine)+strlen(characters)+1];
     123  char* addCharLine = new char[strlen(this->inputLine)+strlen(characters)+1];
    115124
    116125  sprintf(addCharLine, "%s%s", this->inputLine, characters);
    117   delete this->inputLine;
     126  delete[] this->inputLine;
    118127  this->inputLine = addCharLine;
    119   this->setText(inputLine, true);
     128  this->setText(this->inputLine, true);
    120129}
    121130
     
    132141    characterCount = strlen(this->inputLine);
    133142
    134   char* removeCharLine = new char[strlen(inputLine)-characterCount+1];
    135 
    136   strncpy(removeCharLine, this->inputLine, strlen(inputLine)-characterCount);
    137   removeCharLine[strlen(inputLine)-characterCount] = '\0';
    138   delete this->inputLine;
     143  char* removeCharLine = new char[strlen(this->inputLine)-characterCount+1];
     144
     145  strncpy(removeCharLine, this->inputLine, strlen(this->inputLine)-characterCount);
     146  removeCharLine[strlen(this->inputLine)-characterCount] = '\0';
     147  delete[] this->inputLine;
    139148  this->inputLine = removeCharLine;
    140   this->setText(inputLine, true);
     149  this->setText(this->inputLine, true);
    141150}
    142151
  • trunk/src/lib/shell/shell_input.h

    r5181 r5182  
    3131  bool executeCommand();
    3232  void help() const;
    33   const char* getInputString() const { return this->inputLine; };
    34 
    3533
    3634  virtual void tick(float dt);
     
    4846
    4947   tList<char>*             inputHistory;           //!< The history of given commands.
    50 
    5148};
    5249
Note: See TracChangeset for help on using the changeset viewer.