Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5126 in orxonox.OLD for trunk


Ignore:
Timestamp:
Aug 25, 2005, 3:17:53 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: the shell is now able to handle newLines

File:
1 edited

Legend:

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

    r5125 r5126  
    258258   vsprintf(this->bufferArray, line, arguments);
    259259
    260    char* newLine = new char[strlen(this->bufferArray)+1];
    261    strcpy(newLine, this->bufferArray);
    262 
    263    this->buffer->add(newLine);
    264 
    265    if (this->buffer->getSize() > this->bufferSize)
     260   unsigned int inputLength = strlen(this->bufferArray);
     261   char* newLineBegin = this->bufferArray;
     262   char* newLineEnd;
     263
     264   while (newLineBegin < this->bufferArray + inputLength)
    266265   {
    267      delete this->buffer->firstElement();
    268      this->buffer->remove(this->buffer->firstElement());
    269    }
    270 
    271    if (this->bActive)
    272    {
    273      this->printToDisplayBuffer(newLine);
     266     newLineEnd = strchr(newLineBegin, '\n');
     267     if (newLineEnd != NULL && *newLineEnd == '\n')
     268       *newLineEnd = '\0';
     269     else
     270       break;
     271
     272     char* addLine = new char[strlen(newLineBegin)+1];
     273     strcpy(addLine, newLineBegin);
     274
     275     this->buffer->add(addLine);
     276
     277     if (this->buffer->getSize() > this->bufferSize)
     278     {
     279       delete this->buffer->firstElement();
     280       this->buffer->remove(this->buffer->firstElement());
     281     }
     282
     283     if (this->bActive)
     284     {
     285       this->printToDisplayBuffer(addLine);
     286     }
     287     newLineBegin = newLineEnd+1;
    274288   }
    275289}
     
    410424  {
    411425    this->flushBuffers();
     426    this->addBufferLine("orxonox - shell\n ==================== \n", NULL);
    412427  }
    413428
Note: See TracChangeset for help on using the changeset viewer.