Changeset 5781 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Nov 26, 2005, 4:17:20 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell.cc
r5767 r5781 75 75 this->bufferDisplaySize = 10; 76 76 this->bufferOffset = 0; 77 this->bufferIterator = ShellBuffer::getInstance()->getBuffer()-> getIterator();77 this->bufferIterator = ShellBuffer::getInstance()->getBuffer()->begin(); 78 78 79 79 // INPUT LINE … … 111 111 delete this->bufferText[i]; 112 112 delete[] this->bufferText; 113 delete this->bufferIterator;114 113 delete[] this->fontFile; 115 114 // delete the inputLine … … 132 131 this->setRelCoorSoft2D(0, 0, 1, 5); 133 132 134 tIterator<char>* bufferIT = ShellBuffer::getInstance()->getBuffer()->getIterator(); 135 bufferIT->lastElement(); 133 list<char*>::const_reverse_iterator textLine = ShellBuffer::getInstance()->getBuffer()->rbegin(); 136 134 for (int i = 0; i < this->bufferDisplaySize; i++) 137 135 { 138 this->bufferText[i]->setText( bufferIT->getCurrent(), true);136 this->bufferText[i]->setText((*textLine), true); 139 137 this->bufferText[i]->setVisibility(true); 140 bufferIT->prevStep(); 141 } 142 delete bufferIT; 138 textLine--; 139 } 143 140 } 144 141 … … 156 153 this->setRelCoorSoft2D(0, -(int)this->shellHeight, 1, 5); 157 154 158 tIterator<char>* bufferIT = ShellBuffer::getInstance()->getBuffer()->getIterator(); 159 bufferIT->lastElement(); 155 list<char*>::const_reverse_iterator textLine = ShellBuffer::getInstance()->getBuffer()->rbegin(); 160 156 for (int i = 0; i < this->bufferDisplaySize; i++) 161 157 { 162 this->bufferText[i]->setText(bufferIT->getCurrent(), false); 163 bufferIT->prevStep(); 158 this->bufferText[i]->setText((*textLine), false); 164 159 this->bufferText[i]->setVisibility(false); 165 } 166 delete bufferIT; 167 160 textLine--; 161 } 168 162 this->bufferOffset = 0; 169 163 } … … 307 301 } 308 302 309 tIterator<char>* it = ShellBuffer::getInstance()->getBuffer()->getIterator(); 310 char* text = it->lastElement(); 303 list<char*>::const_reverse_iterator textLine = ShellBuffer::getInstance()->getBuffer()->rbegin(); 311 304 bufferText = new Text*[bufferDisplaySize]; 312 305 for (unsigned int i = 0; i < bufferDisplaySize; i++) … … 314 307 bufferText[i] = new Text(this->fontFile, this->textSize); 315 308 bufferText[i]->setAlignment(TEXT_ALIGN_LEFT); 316 bufferText[i]->setText( text);309 bufferText[i]->setText(*textLine); 317 310 bufferText[i]->setParent2D(this); 318 text = it->prevElement(); 319 } 320 delete it; 311 textLine--; 312 } 321 313 this->bufferDisplaySize = bufferDisplaySize; 322 314 … … 386 378 void Shell::moveDisplayBuffer(int lineCount) 387 379 { 388 if (!this->bufferIterator->compareListPointer(ShellBuffer::getInstance()->getBuffer())) 389 { 390 delete this->bufferIterator; 391 this->bufferIterator = ShellBuffer::getInstance()->getBuffer()->getIterator(); 392 } 393 394 if (this->bufferOffset == 0) 395 { 396 this->bufferIterator->lastElement(); 397 // for (unsigned int i = 0; i < this->bufferDisplaySize; i++) 380 /// FIXME 381 // if (!this->bufferIterator->compareListPointer(ShellBuffer::getInstance()->getBuffer())) 382 // { 383 // delete this->bufferIterator; 384 // this->bufferIterator = ShellBuffer::getInstance()->getBuffer()->getIterator(); 385 // } 386 // 387 // if (this->bufferOffset == 0) 388 // { 389 // this->bufferIterator->lastElement(); 390 // // for (unsigned int i = 0; i < this->bufferDisplaySize; i++) 391 // // this->bufferIterator->prevStep(); 392 // } 393 // 394 // // boundraries 395 // if (this->bufferOffset + lineCount > (int)ShellBuffer::getInstance()->getBuffer()->getSize()) 396 // lineCount = (int)ShellBuffer::getInstance()->getBuffer()->getSize()- this->bufferOffset; 397 // else if (this->bufferOffset + lineCount < 0) 398 // lineCount = -bufferOffset; 399 // this->bufferOffset += lineCount; 400 // 401 // // moving the iterator to the right position 402 // int move = 0; 403 // while (move != lineCount) 404 // { 405 // if (move < lineCount) 406 // { 407 // ++move; 398 408 // this->bufferIterator->prevStep(); 399 } 400 401 // boundraries 402 if (this->bufferOffset + lineCount > (int)ShellBuffer::getInstance()->getBuffer()->getSize()) 403 lineCount = (int)ShellBuffer::getInstance()->getBuffer()->getSize()- this->bufferOffset; 404 else if (this->bufferOffset + lineCount < 0) 405 lineCount = -bufferOffset; 406 this->bufferOffset += lineCount; 407 408 // moving the iterator to the right position 409 int move = 0; 410 while (move != lineCount) 411 { 412 if (move < lineCount) 413 { 414 ++move; 415 this->bufferIterator->prevStep(); 416 } 417 else 418 { 419 --move; 420 this->bufferIterator->nextStep(); 421 } 422 } 423 // redisplay the buffers 424 tIterator<char> it = *this->bufferIterator; 425 for (unsigned int i = 0; i < this->bufferDisplaySize; i++) 426 { 427 this->bufferText[i]->setText(it.getCurrent(), false); 428 it.prevStep(); 429 } 409 // } 410 // else 411 // { 412 // --move; 413 // this->bufferIterator->nextStep(); 414 // } 415 // } 416 // // redisplay the buffers 417 // tIterator<char> it = *this->bufferIterator; 418 // for (unsigned int i = 0; i < this->bufferDisplaySize; i++) 419 // { 420 // this->bufferText[i]->setText(it.getCurrent(), false); 421 // it.prevStep(); 422 // } 430 423 } 431 424 -
trunk/src/lib/shell/shell.h
r5513 r5781 91 91 private: 92 92 // GENERAL 93 bool bActive; //!< If the shell is active.94 unsigned int shellHeight; //!< The hight of the Shell in Pixels.95 unsigned int lineSpacing; //!< The Spacing between lines.96 unsigned int textSize; //!< The size of the text.97 float textColor[4]; //!< The text's color [r,g,b,a].98 char* fontFile; //!< The file containing the font.99 Material* backgroundMaterial; //!< A material for the background.93 bool bActive; //!< If the shell is active. 94 unsigned int shellHeight; //!< The hight of the Shell in Pixels. 95 unsigned int lineSpacing; //!< The Spacing between lines. 96 unsigned int textSize; //!< The size of the text. 97 float textColor[4]; //!< The text's color [r,g,b,a]. 98 char* fontFile; //!< The file containing the font. 99 Material* backgroundMaterial; //!< A material for the background. 100 100 101 101 // HANDLING TEXT INPUT 102 ShellInput* shellInput; //!< The inputLine of the Shell.102 ShellInput* shellInput; //!< The inputLine of the Shell. 103 103 // BUFFER 104 unsigned int bufferDisplaySize; //!< The Size of the Display-buffer, in lines (not in characters).105 Text** bufferText; //!< A list of stored bufferTexts for the display of the buffer.106 int bufferOffset; //!< how many lines from the bottom up we display the Buffer.107 tIterator<char>*bufferIterator; //!< used to move through and print the Buffer104 unsigned int bufferDisplaySize; //!< The Size of the Display-buffer, in lines (not in characters). 105 Text** bufferText; //!< A list of stored bufferTexts for the display of the buffer. 106 int bufferOffset; //!< how many lines from the bottom up we display the Buffer. 107 std::list<char*>::const_iterator bufferIterator; //!< used to move through and print the Buffer 108 108 }; 109 109 -
trunk/src/lib/shell/shell_buffer.cc
r5290 r5781 38 38 this->bufferArray[0] = '\0'; 39 39 this->keepBuffer = false; 40 this->buffer = new tList<char>;41 40 42 41 this->setBufferSize(100); … … 54 53 55 54 this->flush(); 56 delete buffer;57 55 58 56 ShellBuffer::singletonRef = NULL; … … 89 87 { 90 88 // delete all the Chars in the Buffers 91 tIterator<char>* bufferIterator = this->buffer->getIterator(); 92 char* charElem = bufferIterator->firstElement(); 93 while (charElem != NULL) 89 list<char*>::iterator bufferLine; 90 for (bufferLine = this->buffer.begin(); bufferLine != this->buffer.end(); bufferLine++) 94 91 { 95 delete[] charElem; 96 charElem = bufferIterator->nextElement(); 92 delete[] (*bufferLine); 97 93 } 98 delete bufferIterator; 99 delete this->buffer; 100 this->buffer = new tList<char>; 94 this->buffer.erase(this->buffer.begin(), this->buffer.end()); 101 95 } 102 96 … … 178 172 179 173 this->lineCount++; 180 this->buffer ->add(addLine);174 this->buffer.push_back(addLine); 181 175 if (likely (this->shell != NULL) && unlikely (this->shell->isActive())) 182 176 this->shell->printToDisplayBuffer(addLine); 183 177 184 if (this->buffer ->getSize() > this->bufferSize)178 if (this->buffer.size() > this->bufferSize) 185 179 { 186 delete[] this->buffer ->firstElement();187 this->buffer ->remove(this->buffer->firstElement());180 delete[] this->buffer.front(); 181 this->buffer.pop_front(); 188 182 } 189 183 … … 199 193 PRINT(3)("Debugging output to console (not this shell)\n"); 200 194 201 tIterator<char>* charIterator = this->buffer->getIterator(); 202 char* tmpChar = charIterator->firstElement(); 203 while(tmpChar != NULL) 204 { 205 printf(tmpChar); 206 tmpChar = charIterator->nextElement(); 207 } 208 delete charIterator; 195 list<char*>::const_iterator bufferLine; 196 for (bufferLine = this->buffer.begin(); bufferLine != this->buffer.end(); bufferLine++) 197 printf(*bufferLine); 209 198 } -
trunk/src/lib/shell/shell_buffer.h
r5246 r5781 9 9 10 10 #include <stdarg.h> 11 #include <list> 11 12 12 13 #define SHELL_BUFFER_SIZE 16384 //!< The Size of the input-buffers (should be large enough to carry any kind of input) … … 39 40 void addBufferLine(const char* line, va_list arg); 40 41 /** @returns the List of stings from the Buffer */ 41 const tList<char>* getBuffer() const { returnthis->buffer; };42 const std::list<char*>* getBuffer() const { return &this->buffer; }; 42 43 /** @returns the Count of lines processed by the Shell. */ 43 44 inline long getLineCount() const { return this->lineCount; }; … … 49 50 50 51 private: 51 static ShellBuffer* singletonRef; //!< The singleton-reference to the only memeber of this class.52 unsigned int bufferSize; //!< The Size of the buffer53 tList<char>*buffer; //!< A list of stored char-arrays(strings) to store the history52 static ShellBuffer* singletonRef; //!< The singleton-reference to the only memeber of this class. 53 unsigned int bufferSize; //!< The Size of the buffer 54 std::list<char*> buffer; //!< A list of stored char-arrays(strings) to store the history 54 55 55 Shell* shell; //!< the Registered Shell.56 char bufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER for fast writing57 char keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.58 bool keepBuffer; //!< if the keepbuffer contains unfinished lines.56 Shell* shell; //!< the Registered Shell. 57 char bufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER for fast writing 58 char keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell. 59 bool keepBuffer; //!< if the keepbuffer contains unfinished lines. 59 60 60 unsigned long lineCount; //!< how many Lines have been written out so far.61 unsigned long lineCount; //!< how many Lines have been written out so far. 61 62 }; 62 63 -
trunk/src/lib/shell/shell_command_class.h
r5779 r5781 12 12 13 13 // FORWARD DECLARATION 14 template<class T> class tList;15 14 16 15 ////////////////
Note: See TracChangeset
for help on using the changeset viewer.