Changeset 7762 in orxonox.OLD for trunk/src/lib/shell/shell.cc
- Timestamp:
- May 22, 2006, 6:20:35 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell.cc
r7757 r7762 62 62 this->setName("Shell"); 63 63 64 this->shellBuffer = ShellBuffer::getInstance(); 65 64 66 // EVENT-Handler subscription of '`' to all States. 65 67 EventHandler::getInstance()->subscribe(this, ES_ALL, SDLK_BACKQUOTE); … … 70 72 71 73 // BUFFER 72 this->bufferIterator = ShellBuffer::getInstance()->getBuffer().begin();74 this->bufferIterator = this->shellBuffer->getBuffer().begin(); 73 75 74 76 // INPUT LINE … … 91 93 92 94 this->deactivate(); 93 // register the shell at the ShellBuffer94 ShellBuffer::getInstance()->registerShell(this);95 95 } 96 96 … … 100 100 Shell::~Shell () 101 101 { 102 ShellBuffer::getInstance()->unregisterShell(this);103 104 102 // delete the displayable Buffers 105 103 while (!this->bufferText.empty()) … … 120 118 PRINTF(3)("The shell is already active\n"); 121 119 this->bActive = true; 120 this->activate2D(); 122 121 123 122 EventHandler::getInstance()->pushState(ES_SHELL); … … 126 125 this->setRelCoorSoft2D(0, 0, 5); 127 126 128 std::list<std::string>::const_iterator textLine = ShellBuffer::getInstance()->getBuffer().begin(); 127 this->linesProcessed = this->shellBuffer->getLineCount(); 128 std::list<std::string>::const_iterator textLine = this->bufferIterator = this->shellBuffer->getBuffer().begin(); 129 129 for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text) 130 130 { 131 131 (*text)->setVisibility(true); 132 if (textLine != ShellBuffer::getInstance()->getBuffer().end())132 if (textLine != this->shellBuffer->getBuffer().end()) 133 133 { 134 134 (*text)->setText((*textLine)); … … 150 150 PRINTF(3)("The shell is already inactive\n"); 151 151 this->bActive = false; 152 this->deactivate2D(); 152 153 153 154 EventHandler::getInstance()->withUNICODE(false); … … 159 160 (*text)->setVisibility(false); 160 161 // Go to the End again. 161 this->bufferIterator = ShellBuffer::getInstance()->getBuffer().begin();162 this->bufferIterator = this->shellBuffer->getBuffer().begin(); 162 163 } 163 164 … … 337 338 (*textIt)->setText(""); // remove all chars from the BufferTexts. 338 339 } 339 ShellBuffer::getInstance()->flush();340 this->shellBuffer->flush(); 340 341 // BUFFER FLUSHING 341 342 } … … 353 354 // Set the new Text. 354 355 this->bufferText.front()->setText(text); 356 this->bufferIterator = this->shellBuffer->getBuffer().begin(); 355 357 356 358 // The LineCount will be started here. … … 358 360 // The First Line gets a special Animation 359 361 this->bufferText.front()->setRelCoor2D(this->calculateLinePosition(0)- Vector2D(-1000,0)); 362 360 363 361 364 // Move all lines one Entry up. … … 378 381 if (moves < lineCount) 379 382 { 380 if(this->bufferIterator == -- ShellBuffer::getInstance()->getBuffer().end())383 if(this->bufferIterator == --this->shellBuffer->getBuffer().end()) 381 384 break; 382 385 ++moves; … … 385 388 else 386 389 { 387 if (this->bufferIterator == ShellBuffer::getInstance()->getBuffer().begin())390 if (this->bufferIterator == this->shellBuffer->getBuffer().begin()) 388 391 break; 389 392 --moves; … … 414 417 for (textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt, ++it) 415 418 { 416 if (it == ShellBuffer::getInstance()->getBuffer().end())419 if (it == this->shellBuffer->getBuffer().end()) 417 420 { 418 421 PRINTF(1)("LAST LINE REACHED\n"); … … 473 476 } 474 477 478 void Shell::tick(float dt) 479 { 480 if (this->linesProcessed < this->shellBuffer->getLineCount()) 481 { 482 unsigned int pollLines = this->shellBuffer->getLineCount() - this->linesProcessed; 483 if (this->bufferText.size() < pollLines) 484 pollLines = this->bufferText.size(); 485 if (unlikely(this->shellBuffer->getBuffer().size() < pollLines)) 486 pollLines = this->shellBuffer->getBuffer().size(); 487 488 std::list<std::string>::const_iterator line = this->shellBuffer->getBuffer().begin(); 489 unsigned int i; 490 for(i = 0; i < pollLines; i++) 491 line ++; 492 for (i = 0; i < pollLines; i++) 493 { 494 this->printToDisplayBuffer((*--line)); 495 } 496 } 497 this->linesProcessed = this->shellBuffer->getLineCount(); 498 } 499 500 475 501 /** 476 502 * displays the Shell … … 527 553 528 554 529 ShellBuffer::getInstance()->debug();555 this->shellBuffer->debug(); 530 556 } 531 557
Note: See TracChangeset
for help on using the changeset viewer.