Changeset 5245 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Sep 24, 2005, 8:47:02 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell.cc
r5227 r5245 54 54 // register the shell at the ShellBuffer 55 55 ShellBuffer::getInstance()->registerShell(this); 56 56 // EVENT-Handler subscription of '`' to all States. 57 EventHandler::getInstance()->subscribe(this, ES_ALL, SDLK_BACKQUOTE); 57 58 58 59 // Element2D and generals … … 72 73 this->rebuildText(); 73 74 74 // EVENT-Handler subscription of '`' to all States.75 EventHandler::getInstance()->subscribe(this, ES_ALL, SDLK_BACKQUOTE);76 75 } 77 76 -
trunk/src/lib/shell/shell.h
r5243 r5245 4 4 * 5 5 * @todo Buffer Display in different Colors for different debug mode. 6 * @todo move up and down in Buffer 6 7 */ 7 8 -
trunk/src/lib/shell/shell_completion.cc
r5197 r5245 60 60 * autocompletes the Shell's inputLine 61 61 * @returns true, if a result was found, false otherwise 62 *63 * @todo implement it!!64 62 */ 65 63 bool ShellCompletion::autoComplete(ShellInput* input) … … 169 167 if (clList != NULL) 170 168 { 171 if (!this->addToCompleteList(clList, classBegin ))169 if (!this->addToCompleteList(clList, classBegin, SHELLC_CLASS)) 172 170 return false; 173 171 } … … 190 188 if (boList != NULL) 191 189 { 192 //printf("%s\n", boList->firstElement()->getName()); 193 if (!this->addToCompleteList(boList, objectBegin)) 190 SHELLC_TYPE type = SHELLC_OBJECT; 191 if (classID == CL_SHELL_COMMAND_CLASS) 192 type = SHELLC_CLASS; 193 if (!this->addToCompleteList(boList, objectBegin, type)) 194 194 return false; 195 195 } … … 211 211 ShellCommandClass::getCommandListOfClass(ClassList::IDToString(classID), &fktList); 212 212 //printf("%s\n", boList->firstElement()->getName()); 213 if (!this->addToCompleteList(&fktList, functionBegin ))213 if (!this->addToCompleteList(&fktList, functionBegin, SHELLC_FUNCTION)) 214 214 return false; 215 215 return true; … … 228 228 ShellCommandClass::getCommandListOfAlias(&aliasList); 229 229 //printf("%s\n", boList->firstElement()->getName()); 230 if (!this->addToCompleteList(&aliasList, aliasBegin ))230 if (!this->addToCompleteList(&aliasList, aliasBegin, SHELLC_ALIAS)) 231 231 return false; 232 232 return true; … … 259 259 tIterator<ShellC_Element>* charIterator = completionList->getIterator(); 260 260 ShellC_Element* charElem = charIterator->firstElement(); 261 SHELLC_TYPE changeType = SHELLC_NONE; 261 262 while (charElem != NULL) 262 263 { 263 PRINTF(0)(displayAs, charElem->name); 264 if (charElem->type != changeType) 265 { 266 if (changeType != SHELLC_NONE) 267 PRINT(0)("\n"); 268 PRINT(0)("%s: ", ShellCompletion::typeToString(charElem->type)); 269 changeType = charElem->type; 270 } 271 PRINTF(0)("%s ", charElem->name); 264 272 for (unsigned int i = inputLenght; i < addLength; i++) 265 273 if (addString[i] != charElem->name[i]) 266 274 { 267 275 addLength = i; 268 break;276 // break; 269 277 } 270 278 charElem = charIterator->nextElement(); 271 279 } 272 280 delete charIterator; 281 PRINT(0)("\n"); 273 282 274 283 if (addLength >= inputLenght) … … 301 310 * !! The strings MUST NOT be deleted !! 302 311 */ 303 bool ShellCompletion::addToCompleteList(const tList<const char>* inputList, const char* completionBegin )312 bool ShellCompletion::addToCompleteList(const tList<const char>* inputList, const char* completionBegin, SHELLC_TYPE type) 304 313 { 305 314 if (inputList == NULL || completionBegin == NULL) … … 317 326 ShellC_Element* newElem = new ShellC_Element; 318 327 newElem->name = enumString; 328 newElem->type = type; 319 329 this->completionList->add(newElem); 320 330 } … … 332 342 * !! The strings MUST NOT be deleted !! 333 343 */ 334 bool ShellCompletion::addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin )344 bool ShellCompletion::addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin, SHELLC_TYPE type) 335 345 { 336 346 if (inputList == NULL || completionBegin == NULL) … … 348 358 ShellC_Element* newElem = new ShellC_Element; 349 359 newElem->name = enumBO->getName(); 360 newElem->type = type; 350 361 this->completionList->add(newElem); 351 printf("%s\n",enumBO->getName());352 362 } 353 363 enumBO = iterator->nextElement(); … … 378 388 this->completionList = new tList<ShellC_Element>; 379 389 } 390 391 const char* ShellCompletion::typeToString(SHELLC_TYPE type) 392 { 393 switch (type) 394 { 395 default:// SHELLC_NONE 396 return "error"; 397 case SHELLC_CLASS: 398 return "class"; 399 case SHELLC_OBJECT: 400 return "object"; 401 case SHELLC_FUNCTION: 402 return "function"; 403 case SHELLC_ALIAS: 404 return "alias"; 405 } 406 } -
trunk/src/lib/shell/shell_completion.h
r5197 r5245 48 48 bool generalComplete(const char* begin, const char* displayAs = "%s", const char* addBack = NULL, const char* addFront = NULL); 49 49 50 bool addToCompleteList(const tList<const char>* inputList, const char* completionBegin );51 bool addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin );50 bool addToCompleteList(const tList<const char>* inputList, const char* completionBegin, SHELLC_TYPE type); 51 bool addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin, SHELLC_TYPE type); 52 52 void emptyCompletionList(); 53 54 static const char* ShellCompletion::typeToString(SHELLC_TYPE type); 53 55 54 56 private: -
trunk/src/lib/shell/shell_input.cc
r5244 r5245 50 50 this->history = new tList<char>; 51 51 this->historyIT = this->history->getIterator(); 52 this-> historyLength = 10;52 this->setHistoryLength(50); 53 53 this->historyScrolling = false; 54 54 this->delayed = 0; -
trunk/src/lib/shell/shell_input.h
r5244 r5245 1 1 /*! 2 2 * @file shell_input.h 3 * @brief Definition of ... 4 * @todo AutoCompletion should print nice output 5 * @todo move up and down in Buffer 6 * @todo display old shell Commands 3 * @brief Shell Input is an InputLine for the Shell. 7 4 */ 8 5 … … 18 15 class ShellCompletion; 19 16 20 21 //! A class for ... 17 //! An InputLine for the Shell 18 /** 19 * The ShellInput has the ability to catch and display user input. 20 * The ShellInput is auto-completed after the user presses [TAB] 21 * The ShellInput is executed (and sent back to the Application) on Pressing [ENTER] 22 * [UP] and [DOWN] move through the history of allready given commands. 23 */ 22 24 class ShellInput : public Text, public EventListener { 23 25 … … 38 40 bool executeCommand(); 39 41 42 /** sets the count of the History's entries */ 43 void setHistoryLength(unsigned int historyLength) { this->historyLength = historyLength; }; 40 44 void historyMoveUp(); 41 45 void historyMoveDown(); … … 50 54 ShellCompletion* completion; //!< The Completion Interface. 51 55 52 53 char* inputLine; //!< the Char-Array of the Buffer @todo not needed anymore 56 char* inputLine; //!< the Char-Array of the Buffer 54 57 float repeatRate; //!< The Repeat-Delay. 55 58 float repeatDelay; //!< The delay of the first Character of a given Character.
Note: See TracChangeset
for help on using the changeset viewer.