Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5246 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Sep 24, 2005, 9:20:49 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: minimalized the ShellBuffer

Location:
trunk/src/lib/shell
Files:
4 edited

Legend:

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

    r5245 r5246  
    5656  // EVENT-Handler subscription of '`' to all States.
    5757  EventHandler::getInstance()->subscribe(this, ES_ALL, SDLK_BACKQUOTE);
     58  EventHandler::getInstance()->subscribe(this, ES_SHELL, SDLK_PAGEUP);
     59  EventHandler::getInstance()->subscribe(this, ES_SHELL, SDLK_PAGEDOWN);
    5860
    5961  // Element2D and generals
     
    6668  this->bufferText = NULL;
    6769  this->bufferDisplaySize = 10;
     70  this->bufferOffset = 0;
    6871
    6972  // INPUT LINE
     
    7275
    7376  this->rebuildText();
    74 
    7577}
    7678
     
    104106  this->setRelCoorSoft2D(0, 0, 1, 5);
    105107
    106   ShellBuffer::getInstance()->getBufferIterator()->lastElement();
    107   for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
    108     this->bufferText[i]->setText(ShellBuffer::getInstance()->getBufferIterator()->prevElement(), true);
     108  tIterator<char>* bufferIT = ShellBuffer::getInstance()->getBuffer()->getIterator();
     109  bufferIT->lastElement();
     110  for (int i = 0; i < this->bufferDisplaySize; i++)
     111    this->bufferText[i]->setText(bufferIT->prevElement(), true);
     112  delete bufferIT;
    109113}
    110114
     
    121125  this->setRelCoorSoft2D(0, -400, 1, 5);
    122126
    123   ShellBuffer::getInstance()->getBufferIterator()->lastElement();
     127  tIterator<char>* bufferIT = ShellBuffer::getInstance()->getBuffer()->getIterator();
     128  bufferIT->lastElement();
    124129  for (int i = 0; i < this->bufferDisplaySize; i++)
    125     this->bufferText[i]->setText(ShellBuffer::getInstance()->getBufferIterator()->prevElement(), false);
    126 }
    127 
     130    this->bufferText[i]->setText(bufferIT->prevElement(), false);
     131  delete bufferIT;
     132}
    128133
    129134/**
     
    199204      this->bufferText[i]->setText(NULL, true);
    200205    }
    201   // BUFFER FLUSHING
     206
     207    ShellBuffer::getInstance()->flush();
     208    // BUFFER FLUSHING
    202209}
    203210
     
    231238
    232239/**
     240 * moves the Display buffer (up or down)
     241 * @param lineCount the count by which to shift the InputBuffer.
     242 */
     243void Shell::moveDisplayBuffer(int lineCount)
     244{
     245
     246
     247}
     248
     249/**
    233250 * clears the Shell (empties all buffers)
    234251 */
     
    253270      else
    254271        this->deactivate();
     272    }
     273    else if (event.type == SDLK_PAGEUP)
     274    {
     275
     276    }
     277    else if (event.type == SDLK_PAGEDOWN)
     278    {
     279
    255280    }
    256281  }
  • trunk/src/lib/shell/shell.h

    r5245 r5246  
    3030 *
    3131 * Furthermore the Shell should enable us, to input some simple commands
    32  * Each Class can tell check itself in to the Shell, and listen for commands.
     32 * Each Class can check itself in to the Shell, and listen for commands.
    3333 *
    34  * @todo implement what is written above :/
     34 * more info: @see ShellCommand
     35 * @see shell_command.h
     36 * @see shell_buffer.h
     37 * @see shell_input.h
     38 *
     39 * !! note in order to keep shellbuffer to a minimal (it is included with
     40 * !! debug.h) Display of it inside the Shell is located here !!
    3541 */
    3642class Shell : public Element2D, public EventListener {
     
    5157    void setBufferDisplaySize(unsigned int bufferDisplaySize);
    5258    void printToDisplayBuffer(const char* text);
     59    void moveDisplayBuffer(int lineCount);
     60
    5361    void flush();
    5462
     
    7381
    7482  private:
    75 
    7683    // GENERAL
    77     bool                     bActive;                //!< if the shell is active;
    78     unsigned int             shellHeight;            //!< The hight of the Shell in Pixels
     84    bool                     bActive;                //!< If the shell is active.
     85    unsigned int             shellHeight;            //!< The hight of the Shell in Pixels.
    7986    unsigned int             lineSpacing;            //!< The Spacing between lines.
    8087    unsigned int             textSize;               //!< The size of the text.
     
    8491    ShellInput*              shellInput;             //!< The inputLine of the Shell.
    8592    // BUFFER
    86     unsigned int             bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters)
    87     Text**                   bufferText;             //!< A list of stored bufferTexts for the display of the buffer
     93    unsigned int             bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters).
     94    Text**                   bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
     95    int                      bufferOffset;           //!< how many lines from the bottom up we display the Buffer.
    8896};
    8997
  • trunk/src/lib/shell/shell_buffer.cc

    r5215 r5246  
    1010
    1111   ### File Specific:
    12    main-programmer: ...
     12   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
    1414*/
     
    4040  this->keepBuffer = false;
    4141  this->buffer = new tList<char>;
    42   this->bufferIterator = this->buffer->getIterator();
    4342
    4443  this->setBufferSize(100);
     
    5554    delete this->shell;
    5655
    57   this->flushBuffers();
    58   delete bufferIterator;
     56  this->flush();
    5957  delete buffer;
    6058
     
    8987 * deletes all the Buffers
    9088 */
    91 void ShellBuffer::flushBuffers()
     89void ShellBuffer::flush()
    9290{
    9391  // delete all the Chars in the Buffers
     92  tIterator<char>* bufferIterator = this->buffer->getIterator();
    9493  char* charElem = bufferIterator->firstElement();
    9594  while (charElem != NULL)
     
    9897    charElem = bufferIterator->nextElement();
    9998  }
    100   delete this->bufferIterator;
     99  delete bufferIterator;
    101100  delete this->buffer;
    102101  this->buffer = new tList<char>;
    103   this->bufferIterator = this->buffer->getIterator();
    104 
    105102}
    106103
     
    193190
    194191/**
    195  * moves the buffer around lineCount lines upwards (negative values move down)
    196  * @param lineCount the Count of lines to move upwards
    197  *
    198  * @todo
    199  */
    200 void ShellBuffer::moveBuffer(unsigned int lineCount)
    201 {
    202 }
    203 
    204 /**
    205  * @param lineNumber the n-th line from the bottom
    206  * @returns the Buffer at Line lineNumber
    207  */
    208 const char* ShellBuffer::getBufferLine(unsigned int lineNumber)
    209 {
     192 * displays some nice output from the Shell
     193 */
     194void ShellBuffer::debug() const
     195{
     196  PRINT(3)("Debugging output to console (not this shell)\n");
     197
    210198  tIterator<char>* charIterator = this->buffer->getIterator();
    211   char* charElem = charIterator->firstElement();
    212 
    213   int i = 1;
    214   while (charElem != NULL)
    215   {
    216     if (i++ < lineNumber)
    217     {
    218       delete charIterator;
    219       return charElem;
    220     }
    221 
    222     charElem = charIterator->nextElement();
     199  char* tmpChar = charIterator->firstElement();
     200  while(tmpChar != NULL)
     201  {
     202    printf(tmpChar);
     203    tmpChar = charIterator->nextElement();
    223204  }
    224205  delete charIterator;
    225206}
    226 
    227 /**
    228  * displays some nice output from the Shell
    229  */
    230 void ShellBuffer::debug() const
    231 {
    232   PRINT(3)("Debugging output to console (not this shell)\n");
    233 
    234   char* tmpChar = bufferIterator->firstElement();
    235   while(tmpChar != NULL)
    236   {
    237     printf(tmpChar);
    238     tmpChar = bufferIterator->nextElement();
    239   }
    240 }
  • trunk/src/lib/shell/shell_buffer.h

    r5206 r5246  
    22 * @file shell_buffer.h
    33 * @brief The Shell buffer Tasks
     4 * @see debug.h
    45*/
    56
     
    1415class Shell;
    1516template<class T> class tList;
    16 template<class T> class tIterator;
    1717#ifndef NULL
    1818#define NULL 0            //!< a pointer to NULL
    1919#endif
    2020
    21 //! A class for ...
     21//! A class handling output from orxonox via debug.h
    2222class ShellBuffer {
    2323
     
    3535  /** @param bufferSize the new Buffer-Size */
    3636  void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };
    37   void flushBuffers();
     37  void flush();
    3838  static bool addBufferLineStatic(const char* line, ...);
    3939  void addBufferLine(const char* line, va_list arg);
    40   void moveBuffer(unsigned int lineCount);
    41 // void moveBufferTo(unsigned int lineNumber);
    42   const char* getBufferLine(unsigned int lineNumber);
    43   /** @returns the Buffer Iterator, that enables externals to walk through the Buffer */
    44   inline tIterator<char>* getBufferIterator() const { return bufferIterator; };
    45   /** @returns the Count of lines processed by the Shell. */
     40  /** @returns the List of stings from the Buffer */
     41  const tList<char>* getBuffer() const { return this->buffer; };
     42 /** @returns the Count of lines processed by the Shell. */
    4643  inline long getLineCount() const { return this->lineCount; };
    4744
     
    5148    ShellBuffer();
    5249
    53 
    5450  private:
    5551   static ShellBuffer*      singletonRef;                       //!< The singleton-reference to the only memeber of this class.
    5652   unsigned int             bufferSize;                         //!< The Size of the buffer
    5753   tList<char>*             buffer;                             //!< A list of stored char-arrays(strings) to store the history
    58    tIterator<char>*         bufferIterator;                     //!< An iterator for the Shells main buffer.
    5954
    6055   Shell*                   shell;                              //!< the Registered Shell.
Note: See TracChangeset for help on using the changeset viewer.