- Timestamp:
- May 20, 2006, 6:09:17 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell.cc
r7742 r7744 53 53 ->completionPlugin(0, OrxShell::CompletorFileSystem(".ttf", "fonts/")); 54 54 55 56 void Shell::testShell() 57 { 58 for (unsigned int i = 0; i < 100; i++) 59 PRINT(0)("%d\n", i); 60 } 61 SHELL_COMMAND(test, Shell, testShell); 62 63 55 64 /** 56 65 * standard constructor … … 68 77 69 78 // BUFFER 70 this->bufferOffset = 0;71 79 this->bufferIterator = ShellBuffer::getInstance()->getBuffer().begin(); 72 80 … … 137 145 } 138 146 } 147 repositionText(); 139 148 } 140 149 … … 155 164 for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text) 156 165 (*text)->setVisibility(false); 157 this->bufferOffset = 0; 166 // Go to the End again. 167 this->bufferIterator = ShellBuffer::getInstance()->getBuffer().begin(); 158 168 } 159 169 … … 352 362 void Shell::moveDisplayBuffer(int lineCount) 353 363 { 354 if (this->bufferOffset == 0) 355 { 356 this->bufferIterator = ShellBuffer::getInstance()->getBuffer().end(); 357 // for (unsigned int i = 0; i < this->bufferDisplaySize; i++) 358 // this->bufferIterator->prevStep(); 359 } 360 361 // boundraries 362 if (this->bufferOffset + lineCount > (int)ShellBuffer::getInstance()->getBuffer().size()) 363 lineCount = (int)ShellBuffer::getInstance()->getBuffer().size()- this->bufferOffset; 364 else if (this->bufferOffset + lineCount < 0) 365 lineCount = -bufferOffset; 366 this->bufferOffset += lineCount; 367 368 // moving the iterator to the right position 369 int move = 0; 370 while (move != lineCount) 371 { 372 if (move < lineCount) 373 { 374 ++move; 375 this->bufferIterator--; 364 // moving the iterator to the right position (counting the steps) 365 int moves = 0; 366 while (moves != lineCount) 367 { 368 if (moves < lineCount) 369 { 370 if(this->bufferIterator == --ShellBuffer::getInstance()->getBuffer().end()) 371 break; 372 ++moves; 373 ++this->bufferIterator; 376 374 } 377 375 else 378 376 { 379 --move; 380 this->bufferIterator++; 381 } 382 } 377 if (this->bufferIterator == ShellBuffer::getInstance()->getBuffer().begin()) 378 break; 379 --moves; 380 --this->bufferIterator; 381 } 382 } 383 384 383 385 // redisplay the buffers 386 int linePos = moves; 384 387 std::list<std::string>::const_iterator it = this->bufferIterator; 385 if (it == ShellBuffer::getInstance()->getBuffer().end()) 386 { 387 /// FIXME 388 PRINTF(1)("Should not happen\n"); 389 it--; 390 } 391 for (std::list<MultiLineText*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt) 392 { 388 std::list<MultiLineText*>::iterator textIt; 389 for (textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt, ++it) 390 { 391 if (it == ShellBuffer::getInstance()->getBuffer().end()) 392 { 393 PRINTF(1)("LAST LINE REACHED\n"); 394 break; 395 } 396 397 398 (*textIt)->setRelCoor2D(calculateLinePosition( (linePos++ > 0)? linePos : 0)); 393 399 (*textIt)->setText((*it)); 394 if (it == ShellBuffer::getInstance()->getBuffer().begin())395 {396 /// FIXME397 PRINTF(1)("Should not happen\n");398 break;399 400 it--; 401 }400 } 401 while (textIt != this->bufferText.end()) 402 { 403 (*textIt)->setText(""); 404 textIt++; 405 } 406 407 this->repositionText(); 402 408 } 403 409 … … 493 499 ShellBuffer::getInstance()->debug(); 494 500 } 495 496 // void Shell::testI (int i)497 // {498 // PRINTF(3)("This is the Test for one Int '%d'\n", i);499 // }500 //501 // void Shell::testS (const char* s)502 // {503 // PRINTF(3)("This is the Test for one String '%s'\n", s);504 // }505 //506 // void Shell::testB (bool b)507 // {508 // PRINTF(3)("This is the Test for one Bool: ");509 // if (b)510 // PRINTF(3)("true\n");511 // else512 // PRINTF(3)("false\n");513 // }514 //515 // void Shell::testF (float f)516 // {517 // PRINTF(3)("This is the Test for one Float '%f'\n", f);518 // }519 //520 // void Shell::testSF (const char* s, float f)521 // {522 // PRINTF(3)("This is the Test for one String '%s' and one Float '%f'\n",s , f);523 // }524 525 501 } -
trunk/src/lib/shell/shell.h
r7738 r7744 79 79 void debug() const; 80 80 81 void testShell(); 81 82 private: 82 83 void repositionText(); … … 85 86 // helpers // 86 87 Vector2D calculateLinePosition(unsigned int lineNumber); 87 88 // void testI (int i);89 // void testS (const std::string& s);90 // void testB (bool b);91 // void testF (float f);92 // void testSF (const std::string& s, float f);93 88 94 89 private: … … 107 102 unsigned int bufferDisplaySize; //!< The Size of the Display-buffer, in lines (not in characters). 108 103 std::list<MultiLineText*> bufferText; //!< A list of stored bufferTexts for the display of the buffer. 109 int bufferOffset; //!< how many lines from the bottom up we display the Buffer. 104 110 105 std::list<std::string>::const_iterator bufferIterator; //!< used to move through and print the Buffer 111 106 }; -
trunk/src/lib/shell/shell_buffer.cc
r7737 r7744 164 164 165 165 this->lineCount++; 166 this->buffer.push_ back(newLineBegin);166 this->buffer.push_front(newLineBegin); 167 167 if (likely (this->shell != NULL) && unlikely (this->shell->isActive())) 168 168 this->shell->printToDisplayBuffer(newLineBegin); 169 169 170 170 if (this->buffer.size() > this->bufferSize) 171 this->buffer.pop_ front();171 this->buffer.pop_back(); 172 172 173 173 newLineBegin = newLineEnd+1; … … 183 183 184 184 std::list<std::string>::const_iterator bufferLine; 185 for (bufferLine = this->buffer.begin(); bufferLine != this->buffer.end(); bufferLine++)185 for (bufferLine = --this->buffer.end(); bufferLine != this->buffer.begin(); --bufferLine) 186 186 printf((*bufferLine).c_str()); 187 187 } -
trunk/src/lib/shell/shell_buffer.h
r7737 r7744 18 18 19 19 //! A class handling output from orxonox via debug.h 20 /** 21 * the ShellBuffer redirects output from PRINTF(x) to the Shell and STDOUT 22 * the ShellBuffer is a front-filling queue of limited length, that has the 23 * youngest added Entry at the beginning, and the oldest at the end. 24 */ 20 25 class ShellBuffer 21 26 { … … 26 31 inline static ShellBuffer* getInstance() { if (!ShellBuffer::singletonRef) ShellBuffer::singletonRef = new ShellBuffer(); return ShellBuffer::singletonRef; }; 27 32 /** @returns true if this class is instanciated, false otherwise */ 28 inline static bool isInstanciated() { return (ShellBuffer::singletonRef == NULL)?false:true; };33 inline static bool isInstanciated() { return (ShellBuffer::singletonRef == NULL)?false:true; }; 29 34 30 35 void registerShell(Shell* shell); 31 36 void unregisterShell(Shell* shell); 37 38 static bool addBufferLineStatic(const char* line, ...); 39 void addBufferLine(const char* line, va_list arg); 32 40 33 41 // BUFFER // … … 35 43 void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; }; 36 44 void flush(); 37 static bool addBufferLineStatic(const char* line, ...); 38 void addBufferLine(const char* line, va_list arg); 45 39 46 /** @returns the List of stings from the Buffer */ 40 47 const std::list<std::string>& getBuffer() const { return this->buffer; }; 41 48 /** @returns the Count of lines processed by the Shell. */ 42 inline long getLineCount() const { return this->lineCount; };49 inline unsigned long getLineCount() const { return this->lineCount; }; 43 50 44 51 void debug() const; … … 58 65 unsigned long lineCount; //!< how many Lines have been written out so far. 59 66 67 // The Beginning of buffer (buffer.front()) is the last added line. 60 68 static std::list<std::string> buffer; //!< A list of stored char-arrays(strings) to store the history 61 69 };
Note: See TracChangeset
for help on using the changeset viewer.