Changeset 5118 in orxonox.OLD for trunk/src/util
- Timestamp:
- Aug 24, 2005, 2:45:46 AM (19 years ago)
- Location:
- trunk/src/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/shell.cc
r5115 r5118 45 45 this->bActive = false; 46 46 this->buffer = new tList<char>; 47 this->bufferIterator = this->buffer->getIterator(); 47 48 48 49 this->textSize = 15; … … 53 54 this->setBufferSize(100); 54 55 this->bufferDisplaySize = 10; 55 this->setBufferDisplaySize(10);56 56 this->setAbsCoor2D(3, -400); 57 57 this->delayed = 0; … … 90 90 91 91 // delete all the Chars in the Buffers 92 tIterator<char>* charIterator = this->buffer->getIterator(); 93 char* charElem = charIterator->firstElement(); 92 char* charElem = this->bufferIterator->firstElement(); 94 93 while (charElem != NULL) 95 94 { 96 95 delete charElem; 97 charElem = charIterator->nextElement();98 } 99 delete charIterator;96 charElem = this->bufferIterator->nextElement(); 97 } 98 delete this->bufferIterator; 100 99 101 100 // if (this->completionList != NULL) … … 114 113 EventHandler::getInstance()->setState(ES_SHELL); 115 114 this->setRelCoorSoft2D(0, 0, 1, 5); 115 116 this->bufferIterator->lastElement(); 117 for (int i = 0; i < this->bufferDisplaySize; i++) 118 this->bufferText[i]->setText(this->bufferIterator->prevElement()); 116 119 } 117 120 … … 124 127 EventHandler::getInstance()->setState(ES_GAME); 125 128 this->setRelCoorSoft2D(0, -400, 1, 5); 129 126 130 } 127 131 … … 249 253 } 250 254 251 if (this->bActive && likely(bufferText != NULL))255 if (this->bActive) 252 256 { 253 Text* lastText = this->bufferText[this->bufferDisplaySize-1]; 254 Vector firstCoord = this->bufferText[0]->getRelCoorSoft2D(); 255 256 Text* swapText; 257 Text* moveText = this->bufferText[0]; 258 this->bufferText[0]->setRelCoorSoft2D(this->bufferText[1]->getRelCoorSoft2D(), 5); 259 for (unsigned int i = 1; i < this->bufferDisplaySize; i++) 260 { 261 if ( i < this->bufferDisplaySize-1) 262 this->bufferText[i]->setRelCoorSoft2D(this->bufferText[i+1]->getRelCoorSoft2D(),5); 263 swapText = this->bufferText[i]; 264 this->bufferText[i] = moveText; 265 moveText = swapText; 266 } 267 lastText->setRelCoor2D(firstCoord); 268 this->bufferText[0] = lastText; 269 270 this->bufferText[0]->setText(newLine); 257 this->printToDisplayBuffer(newLine); 271 258 } 259 } 260 261 /** 262 * prints out some text to the input-buffers 263 * @param text the text to output. 264 */ 265 void Shell::printToDisplayBuffer(const char* text) 266 { 267 if(likely(bufferText != NULL)) 268 { 269 Text* lastText = this->bufferText[this->bufferDisplaySize-1]; 270 Vector firstCoord = this->bufferText[0]->getRelCoorSoft2D(); 271 272 Text* swapText; 273 Text* moveText = this->bufferText[0]; 274 this->bufferText[0]->setRelCoorSoft2D(this->bufferText[1]->getRelCoorSoft2D(), 5); 275 for (unsigned int i = 1; i < this->bufferDisplaySize; i++) 276 { 277 if ( i < this->bufferDisplaySize-1) 278 this->bufferText[i]->setRelCoorSoft2D(this->bufferText[i+1]->getRelCoorSoft2D(),5); 279 swapText = this->bufferText[i]; 280 this ->bufferText[i] = moveText; 281 moveText = swapText; 282 } 283 lastText->setRelCoor2D(firstCoord); 284 this->bufferText[0] = lastText; 285 286 this->bufferText[0]->setText(text); 287 } 272 288 } 273 289 -
trunk/src/util/shell.h
r5113 r5118 15 15 class Text; 16 16 template<class T> class tList; 17 template<class T> class tIterator; 17 18 18 19 //! A class that is able to redirect all output to a openGL-Shell, and that one can use to input some commands … … 48 49 static bool addBufferLineStatic(const char* line, ...); 49 50 void addBufferLine(const char* line, va_list arg); 51 void printToDisplayBuffer(const char* text); 50 52 void moveBuffer(int lineCount); 51 53 const char* getBufferLine(unsigned int lineNumber); … … 96 98 97 99 tList<char>* buffer; //!< A list of stored char-arrays(strings) to store the history 100 tIterator<char>* bufferIterator; //!< An iterator for the Shells main buffer. 98 101 99 102 Text** bufferText; //!< A list of stored bufferTexts for the display of the buffer
Note: See TracChangeset
for help on using the changeset viewer.