Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7762 in orxonox.OLD for trunk/src/lib/shell/shell.cc


Ignore:
Timestamp:
May 22, 2006, 6:20:35 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: ShellBuffer gets polled from the Shell, and does not put the other way round

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/shell/shell.cc

    r7757 r7762  
    6262    this->setName("Shell");
    6363
     64    this->shellBuffer = ShellBuffer::getInstance();
     65
    6466    // EVENT-Handler subscription of '`' to all States.
    6567    EventHandler::getInstance()->subscribe(this, ES_ALL, SDLK_BACKQUOTE);
     
    7072
    7173    // BUFFER
    72     this->bufferIterator = ShellBuffer::getInstance()->getBuffer().begin();
     74    this->bufferIterator = this->shellBuffer->getBuffer().begin();
    7375
    7476    // INPUT LINE
     
    9193
    9294    this->deactivate();
    93     // register the shell at the ShellBuffer
    94     ShellBuffer::getInstance()->registerShell(this);
    9595  }
    9696
     
    100100  Shell::~Shell ()
    101101  {
    102     ShellBuffer::getInstance()->unregisterShell(this);
    103 
    104102    // delete the displayable Buffers
    105103    while (!this->bufferText.empty())
     
    120118      PRINTF(3)("The shell is already active\n");
    121119    this->bActive = true;
     120    this->activate2D();
    122121
    123122    EventHandler::getInstance()->pushState(ES_SHELL);
     
    126125    this->setRelCoorSoft2D(0, 0, 5);
    127126
    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();
    129129    for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text)
    130130    {
    131131      (*text)->setVisibility(true);
    132       if (textLine !=  ShellBuffer::getInstance()->getBuffer().end())
     132      if (textLine !=  this->shellBuffer->getBuffer().end())
    133133      {
    134134        (*text)->setText((*textLine));
     
    150150      PRINTF(3)("The shell is already inactive\n");
    151151    this->bActive = false;
     152    this->deactivate2D();
    152153
    153154    EventHandler::getInstance()->withUNICODE(false);
     
    159160      (*text)->setVisibility(false);
    160161    // Go to the End again.
    161     this->bufferIterator = ShellBuffer::getInstance()->getBuffer().begin();
     162    this->bufferIterator = this->shellBuffer->getBuffer().begin();
    162163  }
    163164
     
    337338      (*textIt)->setText("");  // remove all chars from the BufferTexts.
    338339    }
    339     ShellBuffer::getInstance()->flush();
     340    this->shellBuffer->flush();
    340341    // BUFFER FLUSHING
    341342  }
     
    353354    // Set the new Text.
    354355    this->bufferText.front()->setText(text);
     356    this->bufferIterator = this->shellBuffer->getBuffer().begin();
    355357
    356358    // The LineCount will be started here.
     
    358360    // The First Line gets a special Animation
    359361    this->bufferText.front()->setRelCoor2D(this->calculateLinePosition(0)- Vector2D(-1000,0));
     362
    360363
    361364    // Move all lines one Entry up.
     
    378381      if (moves < lineCount)
    379382      {
    380         if(this->bufferIterator == --ShellBuffer::getInstance()->getBuffer().end())
     383        if(this->bufferIterator == --this->shellBuffer->getBuffer().end())
    381384          break;
    382385        ++moves;
     
    385388      else
    386389      {
    387         if (this->bufferIterator == ShellBuffer::getInstance()->getBuffer().begin())
     390        if (this->bufferIterator == this->shellBuffer->getBuffer().begin())
    388391          break;
    389392        --moves;
     
    414417    for (textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt, ++it)
    415418    {
    416       if (it == ShellBuffer::getInstance()->getBuffer().end())
     419      if (it == this->shellBuffer->getBuffer().end())
    417420      {
    418421        PRINTF(1)("LAST LINE REACHED\n");
     
    473476  }
    474477
     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
    475501  /**
    476502   * displays the Shell
     
    527553
    528554
    529     ShellBuffer::getInstance()->debug();
     555    this->shellBuffer->debug();
    530556  }
    531557
Note: See TracChangeset for help on using the changeset viewer.