Changeset 5182 in orxonox.OLD
- Timestamp:
- Sep 14, 2005, 12:45:17 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/defs/class_id.h
r5141 r5182 111 111 CL_NULL_ELEMENT_2D = 0x00000f22, 112 112 CL_SHELL = 0x00000f31, 113 CL_SHELL_BUFFER = 0x00000f32, 113 114 114 115 … … 194 195 CL_NUMBER = 0x00000b0c, 195 196 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, 198 200 199 201 // Spatial Data Separation -
trunk/src/lib/shell/shell_completion.cc
r5181 r5182 33 33 * @todo this constructor is not jet implemented - do it 34 34 */ 35 ShellCompletion::ShellCompletion ()35 ShellCompletion::ShellCompletion(ShellInput* input) 36 36 { 37 37 this->completionList = NULL; 38 this->input = input; 38 39 } 39 40 … … 61 62 bool ShellCompletion::autoComplete(ShellInput* input) 62 63 { 64 if (input != NULL) 65 this->input = input; 63 66 //PRINTF(3)("AutoCompletion not implemented yet\n"); 64 67 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()); 67 70 68 71 char* commandBegin = strrchr(completionLine, ' '); … … 191 194 adder[addLength] = '\0'; 192 195 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 } 199 205 } 200 206 return true; -
trunk/src/lib/shell/shell_completion.h
r5181 r5182 19 19 20 20 public: 21 ShellCompletion( );21 ShellCompletion(ShellInput* input = NULL); 22 22 virtual ~ShellCompletion(); 23 23 … … 36 36 private: 37 37 tList<const char>* completionList; //!< A list of completions, that are io. 38 ShellInput* input; 38 39 }; 39 40 -
trunk/src/lib/shell/shell_input.cc
r5181 r5182 64 64 delete[] this->inputLine; 65 65 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; 66 76 } 67 77 … … 75 85 this->repeatDelay = repeatDelay; 76 86 this->repeatRate = repeatRate; 77 78 87 } 79 88 … … 98 107 void ShellInput::addCharacter(char character) 99 108 { 100 char* addCharLine = new char[strlen( inputLine)+2];109 char* addCharLine = new char[strlen(this->inputLine)+2]; 101 110 102 111 sprintf(addCharLine, "%s%c", this->inputLine, character); 103 delete this->inputLine;112 delete[] this->inputLine; 104 113 this->inputLine = addCharLine; 105 this->setText( inputLine, true);114 this->setText(this->inputLine, true); 106 115 } 107 116 … … 112 121 void ShellInput::addCharacters(const char* characters) 113 122 { 114 char* addCharLine = new char[strlen( inputLine)+strlen(characters)+1];123 char* addCharLine = new char[strlen(this->inputLine)+strlen(characters)+1]; 115 124 116 125 sprintf(addCharLine, "%s%s", this->inputLine, characters); 117 delete this->inputLine;126 delete[] this->inputLine; 118 127 this->inputLine = addCharLine; 119 this->setText( inputLine, true);128 this->setText(this->inputLine, true); 120 129 } 121 130 … … 132 141 characterCount = strlen(this->inputLine); 133 142 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; 139 148 this->inputLine = removeCharLine; 140 this->setText( inputLine, true);149 this->setText(this->inputLine, true); 141 150 } 142 151 -
trunk/src/lib/shell/shell_input.h
r5181 r5182 31 31 bool executeCommand(); 32 32 void help() const; 33 const char* getInputString() const { return this->inputLine; };34 35 33 36 34 virtual void tick(float dt); … … 48 46 49 47 tList<char>* inputHistory; //!< The history of given commands. 50 51 48 }; 52 49
Note: See TracChangeset
for help on using the changeset viewer.