Changeset 5244 in orxonox.OLD for trunk/src/lib/shell
- Timestamp:
- Sep 24, 2005, 8:06:05 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_input.cc
r5243 r5244 108 108 109 109 /** 110 * sets the entire text of the InputLine to text 111 * @param text the new Text to set as InputLine 112 */ 113 void ShellInput::setInputText(const char* text) 114 { 115 delete[] this->inputLine; 116 if (text == NULL) 117 { 118 this->inputLine = new char[1]; 119 this->inputLine[0] = '\0'; 120 } 121 else 122 { 123 this->inputLine = new char[strlen(text)+1]; 124 strcpy(this->inputLine, text); 125 } 126 this->setText(this->inputLine, true); 127 } 128 129 130 /** 110 131 * adds one character to the inputLine 111 132 * @param character the character to add to the inputLine … … 113 134 void ShellInput::addCharacter(char character) 114 135 { 136 if (this->historyScrolling) 137 { 138 delete[] this->history->lastElement(); 139 this->history->remove(this->history->lastElement()); 140 this->historyScrolling = false; 141 } 142 115 143 char* addCharLine = new char[strlen(this->inputLine)+2]; 116 144 … … 127 155 void ShellInput::addCharacters(const char* characters) 128 156 { 157 if (this->historyScrolling) 158 { 159 delete[] this->history->lastElement(); 160 this->history->remove(this->history->lastElement()); 161 this->historyScrolling = false; 162 } 163 129 164 char* addCharLine = new char[strlen(this->inputLine)+strlen(characters)+1]; 130 165 … … 141 176 void ShellInput::removeCharacters(unsigned int characterCount) 142 177 { 178 if (this->historyScrolling) 179 { 180 delete[] this->history->lastElement(); 181 this->history->remove(this->history->lastElement()); 182 this->historyScrolling = false; 183 } 184 143 185 if (strlen(this->inputLine) == 0) 144 186 return; … … 171 213 { 172 214 delete[] this->history->lastElement(); 215 this->history->remove(this->history->lastElement()); 173 216 this->historyScrolling = false; 174 217 } … … 197 240 if (!this->historyScrolling) 198 241 { 199 char* newCommand= new char[strlen(this->inputLine)+1];200 strcpy( newCommand, this->inputLine);201 this->history->add( newCommand);242 char* currentText = new char[strlen(this->inputLine)+1]; 243 strcpy(currentText, this->inputLine); 244 this->history->add(currentText); 202 245 this->historyScrolling = true; 203 246 this->historyIT->lastElement(); … … 210 253 { 211 254 this->flush(); 212 this->addCharacters(prevElem); 213 } 214 255 this->setInputText(prevElem); 256 } 215 257 } 216 258 … … 228 270 { 229 271 this->flush(); 230 this-> addCharacters(nextElem);272 this->setInputText(nextElem); 231 273 } 232 274 } … … 301 343 else if (event.type == SDLK_RETURN) 302 344 this->executeCommand(); 303 /* 304 else if (event.type == SDLK_UP) 305 { 306 // this->flushInputLine(); 307 tIterator<char>* iterator = this->commandList->getIterator(); 308 char* command = iterator->lastElement(); 309 while (command) 310 { 311 if (!strcmp (command, inputLine)) 312 { 313 inputLine = iterator->prevElement(); 314 return; 315 } 316 command = iterator->prevElement(); 317 } 318 inputLine = iterator->lastElement(); 319 } 320 */ 345 // any other keyboard key 321 346 else if (likely(event.type < 127)) 322 347 { -
trunk/src/lib/shell/shell_input.h
r5243 r5244 31 31 // InputLine 32 32 void flush(); 33 void setInputText(const char* text); 33 34 void addCharacter(char character); 34 35 void addCharacters(const char* characters);
Note: See TracChangeset
for help on using the changeset viewer.