Changeset 7737 in orxonox.OLD for trunk/src/lib/shell
- Timestamp:
- May 19, 2006, 11:38:34 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell.cc
r7426 r7737 21 21 #include "shell_input.h" 22 22 23 24 #include "text.h" 23 #include "multi_line_text.h" 24 25 25 #include "graphics_engine.h" 26 26 #include "material.h" 27 27 #include "event_handler.h" 28 #include "debug.h"29 #include "class_list.h"30 31 #include "key_names.h"32 #include <stdarg.h>33 #include <stdio.h>34 28 35 29 namespace OrxShell … … 137 131 std::list<std::string>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer().end(); 138 132 bool top = false; 139 for (std::list< Text*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text)133 for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text) 140 134 { 141 135 (*text)->setVisibility(true); … … 164 158 this->setRelCoorSoft2D(0, -(int)this->shellHeight, 5); 165 159 166 for (std::list< Text*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text)160 for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text) 167 161 (*text)->setVisibility(false); 168 162 this->bufferOffset = 0; … … 257 251 * output is routed from Some other Thread or by Changing any Values. 258 252 */ 259 std::list< Text*> bufferTextCopy = this->bufferText;260 for (std::list< Text*>::iterator text = bufferTextCopy.begin(); text != bufferTextCopy.end(); ++text, ++i)253 std::list<MultiLineText*> bufferTextCopy = this->bufferText; 254 for (std::list<MultiLineText*>::iterator text = bufferTextCopy.begin(); text != bufferTextCopy.end(); ++text, ++i) 261 255 { 262 256 this->resetText(*text, i); … … 296 290 for (unsigned int i = oldSize; i <= bufferDisplaySize; i++) 297 291 { 298 this->bufferText.push_back(new Text); 292 this->bufferText.push_back(new MultiLineText); 293 this->bufferText.back()->setLineWidth(this->getSizeX2D() * GraphicsEngine::getInstance()->getResolutionX()); 294 this->bufferText.back()->setLineSpacing(0); 299 295 } 300 296 } … … 308 304 void Shell::flush() 309 305 { 310 for (std::list< Text*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text)306 for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text) 311 307 { 312 308 (*text)->setText(""); // remove all chars from the BufferTexts. … … 322 318 void Shell::printToDisplayBuffer(const std::string& text) 323 319 { 320 // Remove Last Entry and prepend it to the front. 324 321 this->bufferText.push_front(this->bufferText.back()); 325 322 this->bufferText.pop_back(); 326 323 327 328 unsigned int i = 0; 329 for (std::list<Text*>::iterator textIt = ++this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt, i++) 330 { 331 (*textIt)->setRelCoorSoft2D(this->calculateLinePosition(i+1), 5); 332 } 333 334 this->bufferText.front()->setRelCoor2D(this->calculateLinePosition(0)- Vector2D(-1000,0)); 335 this->bufferText.front()->setRelCoorSoft2D(this->calculateLinePosition(0),10); 324 // Set the new Text. 325 this->bufferText.front()->setText(text); 326 327 // The LineCount will be started here. 328 int linePos = -1; 329 330 // The First Line gets a special Animation 331 this->bufferText.front()->setRelCoor2D(this->calculateLinePosition(linePos)- Vector2D(-1000,0)); 332 333 // Move all lines one Entry up. 334 for (std::list<MultiLineText*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt) 335 { 336 linePos += (*textIt)->getLineCount(); 337 (*textIt)->setRelCoorSoft2D(this->calculateLinePosition(linePos), 8); 338 } 339 336 340 337 341 /* FANCY EFFECTS :) … … 344 348 */ 345 349 346 this->bufferText.front()->setText(text);347 350 } 348 351 … … 389 392 { 390 393 /// FIXME 391 PRINTF(1)("Should not h eappen\n");394 PRINTF(1)("Should not happen\n"); 392 395 it--; 393 396 } 394 for (std::list< Text*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt)397 for (std::list<MultiLineText*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt) 395 398 { 396 399 (*textIt)->setText((*it)); … … 398 401 { 399 402 /// FIXME 400 PRINTF(1)("Should not h eappen\n");403 PRINTF(1)("Should not happen\n"); 401 404 break; 402 405 } … … 478 481 Vector2D Shell::calculateLinePosition(unsigned int lineNumber) 479 482 { 480 return Vector2D(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize - lineNumber - 2) + this->textSize); 483 Vector2D val(5, (int)(this->textSize + this->lineSpacing)*(int)((int)this->bufferDisplaySize - (int)lineNumber - (int)2) + (int)this->textSize); 484 val.debug(); 485 return val; 481 486 } 482 487 -
trunk/src/lib/shell/shell.h
r7426 r7737 20 20 21 21 // FORWARD DECLARATION 22 class Text;22 class MultiLineText; 23 23 class ShellInput; 24 24 class Material; … … 104 104 // BUFFER 105 105 unsigned int bufferDisplaySize; //!< The Size of the Display-buffer, in lines (not in characters). 106 std::list< Text*>bufferText; //!< A list of stored bufferTexts for the display of the buffer.106 std::list<MultiLineText*> bufferText; //!< A list of stored bufferTexts for the display of the buffer. 107 107 int bufferOffset; //!< how many lines from the bottom up we display the Buffer. 108 108 std::list<std::string>::const_iterator bufferIterator; //!< used to move through and print the Buffer -
trunk/src/lib/shell/shell_buffer.cc
r7729 r7737 17 17 18 18 #include "shell_buffer.h" 19 20 #include <stdarg.h> 21 19 22 #include "debug.h" 20 23 #include "shell.h" 24 #include "lib/util/threading.h" 21 25 22 26 namespace OrxShell … … 39 43 40 44 ShellBuffer* ShellBuffer::singletonRef = NULL; 41 SDL_mutex* ShellBuffer::bufferMutex = NULL;45 std::list<std::string> ShellBuffer::buffer; 42 46 43 47 /** … … 48 52 if (this->shell != NULL) 49 53 delete this->shell; 50 51 this->flush();52 53 if (ShellBuffer::bufferMutex != NULL)54 SDL_DestroyMutex(ShellBuffer::bufferMutex);55 ShellBuffer::bufferMutex = NULL;56 54 57 55 ShellBuffer::singletonRef = NULL; … … 99 97 va_start(arguments, line); 100 98 101 if (ShellBuffer::bufferMutex == NULL) 102 ShellBuffer::bufferMutex = SDL_CreateMutex(); 99 static OrxThread::Mutex ShellBuffer__bufferMutex; 103 100 104 SDL_mutexP(ShellBuffer::bufferMutex);101 OrxThread::MutexLock bufferLock(&ShellBuffer__bufferMutex); 105 102 #if DEBUG_LEVEL < 3 106 103 if (ShellBuffer::singletonRef == NULL) … … 113 110 #endif 114 111 ShellBuffer::singletonRef->addBufferLine(line, arguments); 115 SDL_mutexV(ShellBuffer::bufferMutex);116 112 return true; 117 113 } -
trunk/src/lib/shell/shell_buffer.h
r7661 r7737 8 8 #define _SHELL_BUFFER_H 9 9 10 #include <stdarg.h>11 10 #include <list> 12 #include "lib/util/threading.h"13 11 14 12 #define SHELL_BUFFER_SIZE 16384 //!< The Size of the input-buffers (should be large enough to carry any kind of input) … … 50 48 51 49 private: 52 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<std::string> buffer; //!< A list of stored char-arrays(strings) to store the history 50 static ShellBuffer* singletonRef; //!< The singleton-reference to the only memeber of this class. 51 unsigned int bufferSize; //!< The Size of the buffer 55 52 56 Shell* shell; //!< the Registered Shell.57 char bufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER for fast writing58 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.53 Shell* shell; //!< the Registered Shell. 54 char bufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER for fast writing 55 char keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell. 56 bool keepBuffer; //!< if the keepbuffer contains unfinished lines. 60 57 61 unsigned long lineCount; //!< how many Lines have been written out so far.58 unsigned long lineCount; //!< how many Lines have been written out so far. 62 59 63 static SDL_mutex* bufferMutex; //!< Only one thread may write into the ShellBuffer at a time.60 static std::list<std::string> buffer; //!< A list of stored char-arrays(strings) to store the history 64 61 }; 65 62
Note: See TracChangeset
for help on using the changeset viewer.