- Timestamp:
- Sep 24, 2005, 9:20:49 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell.cc
r5245 r5246 56 56 // EVENT-Handler subscription of '`' to all States. 57 57 EventHandler::getInstance()->subscribe(this, ES_ALL, SDLK_BACKQUOTE); 58 EventHandler::getInstance()->subscribe(this, ES_SHELL, SDLK_PAGEUP); 59 EventHandler::getInstance()->subscribe(this, ES_SHELL, SDLK_PAGEDOWN); 58 60 59 61 // Element2D and generals … … 66 68 this->bufferText = NULL; 67 69 this->bufferDisplaySize = 10; 70 this->bufferOffset = 0; 68 71 69 72 // INPUT LINE … … 72 75 73 76 this->rebuildText(); 74 75 77 } 76 78 … … 104 106 this->setRelCoorSoft2D(0, 0, 1, 5); 105 107 106 ShellBuffer::getInstance()->getBufferIterator()->lastElement(); 107 for (unsigned int i = 0; i < this->bufferDisplaySize; i++) 108 this->bufferText[i]->setText(ShellBuffer::getInstance()->getBufferIterator()->prevElement(), true); 108 tIterator<char>* bufferIT = ShellBuffer::getInstance()->getBuffer()->getIterator(); 109 bufferIT->lastElement(); 110 for (int i = 0; i < this->bufferDisplaySize; i++) 111 this->bufferText[i]->setText(bufferIT->prevElement(), true); 112 delete bufferIT; 109 113 } 110 114 … … 121 125 this->setRelCoorSoft2D(0, -400, 1, 5); 122 126 123 ShellBuffer::getInstance()->getBufferIterator()->lastElement(); 127 tIterator<char>* bufferIT = ShellBuffer::getInstance()->getBuffer()->getIterator(); 128 bufferIT->lastElement(); 124 129 for (int i = 0; i < this->bufferDisplaySize; i++) 125 this->bufferText[i]->setText( ShellBuffer::getInstance()->getBufferIterator()->prevElement(), false);126 } 127 130 this->bufferText[i]->setText(bufferIT->prevElement(), false); 131 delete bufferIT; 132 } 128 133 129 134 /** … … 199 204 this->bufferText[i]->setText(NULL, true); 200 205 } 201 // BUFFER FLUSHING 206 207 ShellBuffer::getInstance()->flush(); 208 // BUFFER FLUSHING 202 209 } 203 210 … … 231 238 232 239 /** 240 * moves the Display buffer (up or down) 241 * @param lineCount the count by which to shift the InputBuffer. 242 */ 243 void Shell::moveDisplayBuffer(int lineCount) 244 { 245 246 247 } 248 249 /** 233 250 * clears the Shell (empties all buffers) 234 251 */ … … 253 270 else 254 271 this->deactivate(); 272 } 273 else if (event.type == SDLK_PAGEUP) 274 { 275 276 } 277 else if (event.type == SDLK_PAGEDOWN) 278 { 279 255 280 } 256 281 } -
trunk/src/lib/shell/shell.h
r5245 r5246 30 30 * 31 31 * Furthermore the Shell should enable us, to input some simple commands 32 * Each Class can tellcheck itself in to the Shell, and listen for commands.32 * Each Class can check itself in to the Shell, and listen for commands. 33 33 * 34 * @todo implement what is written above :/ 34 * more info: @see ShellCommand 35 * @see shell_command.h 36 * @see shell_buffer.h 37 * @see shell_input.h 38 * 39 * !! note in order to keep shellbuffer to a minimal (it is included with 40 * !! debug.h) Display of it inside the Shell is located here !! 35 41 */ 36 42 class Shell : public Element2D, public EventListener { … … 51 57 void setBufferDisplaySize(unsigned int bufferDisplaySize); 52 58 void printToDisplayBuffer(const char* text); 59 void moveDisplayBuffer(int lineCount); 60 53 61 void flush(); 54 62 … … 73 81 74 82 private: 75 76 83 // GENERAL 77 bool bActive; //!< if the shell is active;78 unsigned int shellHeight; //!< The hight of the Shell in Pixels 84 bool bActive; //!< If the shell is active. 85 unsigned int shellHeight; //!< The hight of the Shell in Pixels. 79 86 unsigned int lineSpacing; //!< The Spacing between lines. 80 87 unsigned int textSize; //!< The size of the text. … … 84 91 ShellInput* shellInput; //!< The inputLine of the Shell. 85 92 // BUFFER 86 unsigned int bufferDisplaySize; //!< The Size of the Display-buffer, in lines (not in characters) 87 Text** bufferText; //!< A list of stored bufferTexts for the display of the buffer 93 unsigned int bufferDisplaySize; //!< The Size of the Display-buffer, in lines (not in characters). 94 Text** bufferText; //!< A list of stored bufferTexts for the display of the buffer. 95 int bufferOffset; //!< how many lines from the bottom up we display the Buffer. 88 96 }; 89 97 -
trunk/src/lib/shell/shell_buffer.cc
r5215 r5246 10 10 11 11 ### File Specific: 12 main-programmer: ...12 main-programmer: Benjamin Grauer 13 13 co-programmer: ... 14 14 */ … … 40 40 this->keepBuffer = false; 41 41 this->buffer = new tList<char>; 42 this->bufferIterator = this->buffer->getIterator();43 42 44 43 this->setBufferSize(100); … … 55 54 delete this->shell; 56 55 57 this->flushBuffers(); 58 delete bufferIterator; 56 this->flush(); 59 57 delete buffer; 60 58 … … 89 87 * deletes all the Buffers 90 88 */ 91 void ShellBuffer::flush Buffers()89 void ShellBuffer::flush() 92 90 { 93 91 // delete all the Chars in the Buffers 92 tIterator<char>* bufferIterator = this->buffer->getIterator(); 94 93 char* charElem = bufferIterator->firstElement(); 95 94 while (charElem != NULL) … … 98 97 charElem = bufferIterator->nextElement(); 99 98 } 100 delete this->bufferIterator;99 delete bufferIterator; 101 100 delete this->buffer; 102 101 this->buffer = new tList<char>; 103 this->bufferIterator = this->buffer->getIterator();104 105 102 } 106 103 … … 193 190 194 191 /** 195 * moves the buffer around lineCount lines upwards (negative values move down) 196 * @param lineCount the Count of lines to move upwards 197 * 198 * @todo 199 */ 200 void ShellBuffer::moveBuffer(unsigned int lineCount) 201 { 202 } 203 204 /** 205 * @param lineNumber the n-th line from the bottom 206 * @returns the Buffer at Line lineNumber 207 */ 208 const char* ShellBuffer::getBufferLine(unsigned int lineNumber) 209 { 192 * displays some nice output from the Shell 193 */ 194 void ShellBuffer::debug() const 195 { 196 PRINT(3)("Debugging output to console (not this shell)\n"); 197 210 198 tIterator<char>* charIterator = this->buffer->getIterator(); 211 char* charElem = charIterator->firstElement(); 212 213 int i = 1; 214 while (charElem != NULL) 215 { 216 if (i++ < lineNumber) 217 { 218 delete charIterator; 219 return charElem; 220 } 221 222 charElem = charIterator->nextElement(); 199 char* tmpChar = charIterator->firstElement(); 200 while(tmpChar != NULL) 201 { 202 printf(tmpChar); 203 tmpChar = charIterator->nextElement(); 223 204 } 224 205 delete charIterator; 225 206 } 226 227 /**228 * displays some nice output from the Shell229 */230 void ShellBuffer::debug() const231 {232 PRINT(3)("Debugging output to console (not this shell)\n");233 234 char* tmpChar = bufferIterator->firstElement();235 while(tmpChar != NULL)236 {237 printf(tmpChar);238 tmpChar = bufferIterator->nextElement();239 }240 } -
trunk/src/lib/shell/shell_buffer.h
r5206 r5246 2 2 * @file shell_buffer.h 3 3 * @brief The Shell buffer Tasks 4 * @see debug.h 4 5 */ 5 6 … … 14 15 class Shell; 15 16 template<class T> class tList; 16 template<class T> class tIterator;17 17 #ifndef NULL 18 18 #define NULL 0 //!< a pointer to NULL 19 19 #endif 20 20 21 //! A class for ...21 //! A class handling output from orxonox via debug.h 22 22 class ShellBuffer { 23 23 … … 35 35 /** @param bufferSize the new Buffer-Size */ 36 36 void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; }; 37 void flush Buffers();37 void flush(); 38 38 static bool addBufferLineStatic(const char* line, ...); 39 39 void addBufferLine(const char* line, va_list arg); 40 void moveBuffer(unsigned int lineCount); 41 // void moveBufferTo(unsigned int lineNumber); 42 const char* getBufferLine(unsigned int lineNumber); 43 /** @returns the Buffer Iterator, that enables externals to walk through the Buffer */ 44 inline tIterator<char>* getBufferIterator() const { return bufferIterator; }; 45 /** @returns the Count of lines processed by the Shell. */ 40 /** @returns the List of stings from the Buffer */ 41 const tList<char>* getBuffer() const { return this->buffer; }; 42 /** @returns the Count of lines processed by the Shell. */ 46 43 inline long getLineCount() const { return this->lineCount; }; 47 44 … … 51 48 ShellBuffer(); 52 49 53 54 50 private: 55 51 static ShellBuffer* singletonRef; //!< The singleton-reference to the only memeber of this class. 56 52 unsigned int bufferSize; //!< The Size of the buffer 57 53 tList<char>* buffer; //!< A list of stored char-arrays(strings) to store the history 58 tIterator<char>* bufferIterator; //!< An iterator for the Shells main buffer.59 54 60 55 Shell* shell; //!< the Registered Shell.
Note: See TracChangeset
for help on using the changeset viewer.