Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5127 in orxonox.OLD for trunk/src


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

orxonox/trunk: now it is possible to add multi-non-newLine printf's into the Shell.
This is especially good, to print multiple entities from a loop onto the same line

Location:
trunk/src/util
Files:
2 edited

Legend:

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

    r5126 r5127  
    4242  this->setName("Shell");
    4343
    44   this->shellHeight = 400;
     44  this->keepBufferArray[0] = '\0';
     45  this->keepBuffer = false;
     46
    4547  this->bActive = false;
    4648  this->buffer = new tList<char>;
     
    154156}
    155157
     158/**
     159 * rebuilds the Text's
     160 *
     161 * use this function, if you changed the Font/Size or something else.
     162 */
    156163void Shell::rebuildText()
    157164{
     
    258265   vsprintf(this->bufferArray, line, arguments);
    259266
    260    unsigned int inputLength = strlen(this->bufferArray);
    261    char* newLineBegin = this->bufferArray;
     267   char* inputEnd;
     268   char* newLineBegin;
    262269   char* newLineEnd;
    263270
    264    while (newLineBegin < this->bufferArray + inputLength)
     271   // check if we have something left in the buffers
     272   if (unlikely(this->keepBuffer))
     273   {
     274     strcat(this->keepBufferArray, this->bufferArray);
     275     inputEnd = this->keepBufferArray + strlen(this->keepBufferArray);
     276     newLineBegin = this->keepBufferArray;
     277     this->keepBuffer = false;
     278   }
     279   else
     280   {
     281     inputEnd = this->bufferArray + strlen(this->bufferArray);
     282     newLineBegin = this->bufferArray;
     283   }
     284
     285   // adding all the new Lines
     286   while (newLineBegin < inputEnd)
    265287   {
    266288     newLineEnd = strchr(newLineBegin, '\n');
     
    268290       *newLineEnd = '\0';
    269291     else
     292     {
     293//       newLineEnd = newLineBegin + strlen(newLineBegin);
     294       strcpy(this->keepBufferArray, newLineBegin);
     295       this->keepBuffer = true;
    270296       break;
     297     }
    271298
    272299     char* addLine = new char[strlen(newLineBegin)+1];
  • trunk/src/util/shell.h

    r5120 r5127  
    1111
    1212#include <stdarg.h>
     13
     14#define      SHELL_BUFFER_SIZE       16384         //!< The Size of the input-buffers (should be large enough to carry any kind of input)
    1315
    1416// FORWARD DECLARATION
     
    110112    bool                   bActive;                //!< if the shell is active;
    111113
    112     char                   bufferArray[10000];     //!< a BUFFER for fast writing
     114    char                   bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
     115    char                   keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
     116    bool                   keepBuffer;
    113117
    114118    // completion
Note: See TracChangeset for help on using the changeset viewer.