Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5075 in orxonox.OLD for trunk/src/util


Ignore:
Timestamp:
Aug 19, 2005, 3:21:27 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: redirected all printf-output to the shell
This is just for testing purposes, and will be changed again in the future (perhaps)

Location:
trunk/src/util
Files:
2 edited

Legend:

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

    r5074 r5075  
    2121#include "list.h"
    2222
     23#include <stdarg.h>
     24#include <stdio.h>
     25
    2326using namespace std;
    2427
     
    4144
    4245
    43   this->addBufferLine("asjflksjdvklasmv", NULL);
    44   TextEngine::getInstance()->debug();
     46  //this->addBufferLineStatic("asjflksjdvklasmv %s", "doom");
     47  //TextEngine::getInstance()->debug();
    4548  //exit(-1);
    4649}
     
    7376  while(bufferDisplaySize > this->bufferText->getSize())
    7477  {
    75     Text* newText = TextEngine::getInstance()->createText("fonts/earth.ttf", 30, TEXT_DYNAMIC, 0, 255, 0);
     78    Text* newText = TextEngine::getInstance()->createText("fonts/earth.ttf", 10, TEXT_DYNAMIC, 0, 255, 0);
    7679    newText->setAlignment(TEXT_ALIGN_LEFT);
    7780    newText->setPosition2D(5, 5);
     
    120123 * @todo optimize
    121124 */
    122 void Shell::addBufferLine(const char* line, va_list args)
    123 {
    124   char tmp[1024];// = new char*
    125   vsprintf(tmp, line, args);
    126 
    127   char* newLine = new char[strlen(tmp)+1];
    128   strcpy(newLine, tmp);
    129 
    130   this->buffer->addAtBeginning(newLine);
    131 
    132   if (this->buffer->getSize() > this->bufferSize)
    133   {
    134     delete this->buffer->firstElement();
    135     this->buffer->remove(this->buffer->firstElement());
    136   }
     125bool Shell::addBufferLineStatic(const char* line, ...)
     126{
     127  va_list arguments;
     128  va_start(arguments, line);
     129
     130  if (Shell::singletonRef == NULL)
     131   vprintf(line, arguments);
     132  else
     133    Shell::singletonRef->addBufferLine(line, arguments);
     134  return true;
     135}
     136
     137void Shell::addBufferLine(const char* line, va_list arguments)
     138{
     139  vsprintf(this->bufferArray, line, arguments);
     140
     141  char* newLine = new char[strlen(this->bufferArray)+1];
     142  strcpy(newLine, this->bufferArray);
     143
     144//  this->buffer->add(newLine);
     145
     146//    if (this->buffer->getSize() > this->bufferSize)
     147//    {
     148//      delete this->buffer->firstElement();
     149//      this->buffer->remove(this->buffer->firstElement());
     150//    }
    137151
    138152  this->bufferText->firstElement()->setText(newLine);
    139 
    140153}
    141154
  • trunk/src/util/shell.h

    r5074 r5075  
    1010#include "event_listener.h"
    1111
    12 #include <stdio.h>
    1312#include <stdarg.h>
    14 
    1513
    1614// FORWARD DECLARATION
     
    4442    // BUFFER //
    4543    void flushBuffers();
    46     void addBufferLine(const char* Line, va_list args);
     44    static bool addBufferLineStatic(const char* line, ...);
     45    void addBufferLine(const char* line, va_list arg);
    4746    void moveBuffer(int lineCount);
    4847    const char* getBufferLine(unsigned int lineNumber);
     
    8180    tList<Text>*           bufferText;             //!< A list of stored bufferTexts for the display of the buffer
    8281    Text*                  inputLineText;          //!< The inputLine of the Shell
     82
     83    char                   bufferArray[10000];     //!< a BUFFER for fast writing
     84
    8385};
    8486
Note: See TracChangeset for help on using the changeset viewer.