Index: trunk/src/defs/debug.h
===================================================================
--- trunk/src/defs/debug.h	(revision 5173)
+++ trunk/src/defs/debug.h	(revision 5174)
@@ -27,5 +27,5 @@
 
 #include "confincl.h"
-#include "shell.h"
+#include "shell_buffer.h"
 
 #include <stdio.h>
@@ -100,5 +100,5 @@
 //#ifdef
 #define PRINTF(x)        PRINT(x)
-#define PRINT_EXEC       Shell::addBufferLineStatic
+#define PRINT_EXEC       ShellBuffer::addBufferLineStatic
 
 #ifndef PRINTF
Index: trunk/src/lib/shell/shell.cc
===================================================================
--- trunk/src/lib/shell/shell.cc	(revision 5173)
+++ trunk/src/lib/shell/shell.cc	(revision 5174)
@@ -43,9 +43,6 @@
   this->setName("Shell");
 
-  this->keepBufferArray[0] = '\0';
-  this->keepBuffer = false;
 
   this->bActive = false;
-  this->buffer = new tList<char>;
   this->bufferIterator = this->buffer->getIterator();
 
@@ -57,7 +54,4 @@
 
   //this->bufferSize = 0;
-  this->bufferText = NULL;
-  this->setBufferSize(10);
-  this->bufferDisplaySize = 10;
   this->setAbsCoor2D(3, -400);
   this->delayed = 0;
@@ -95,5 +89,5 @@
   delete this->inputLine;
 
-  // delete all the Chars in the Buffers
+  // delete all the Strings in the Buffers
   char* charElem = this->bufferIterator->firstElement();
   while (charElem != NULL)
Index: trunk/src/lib/shell/shell.h
===================================================================
--- trunk/src/lib/shell/shell.h	(revision 5173)
+++ trunk/src/lib/shell/shell.h	(revision 5174)
@@ -9,7 +9,9 @@
 #include "element_2d.h"
 #include "event_listener.h"
-#include "shell_buffer.h"
+//#include "shell_buffer.h"
 
 #include <stdarg.h>
+
+#define      SHELL_BUFFER_SIZE       16384
 
 // FORWARD DECLARATION
Index: trunk/src/lib/shell/shell_buffer.cc
===================================================================
--- trunk/src/lib/shell/shell_buffer.cc	(revision 5173)
+++ trunk/src/lib/shell/shell_buffer.cc	(revision 5174)
@@ -17,4 +17,8 @@
 
 #include "shell_buffer.h"
+#include "debug.h"
+#include "list.h"
+
+#include "stdlibincl.h"
 
 using namespace std;
@@ -27,18 +31,12 @@
 ShellBuffer::ShellBuffer ()
 {
-// this->setClassID(CL_PROTO_ID, "ProtoClass");
+  this->keepBufferArray[0] = '\0';
+  this->keepBuffer = false;
+  this->buffer = new tList<char>;
 
-   /* If you make a new class, what is most probably the case when you write this file
-      don't forget to:
-       1. Add the new file new_class.cc to the ./src/Makefile.am
-       2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS
-
-      Advanced Topics:
-      - if you want to let your object be managed via the ObjectManager make sure to read
-        the object_manager.h header comments. You will use this most certanly only if you
-        make many objects of your class, like a weapon bullet.
-   */
+  this->setBufferSize(10);
 }
 
+ShellBuffer* ShellBuffer::singletonRef = NULL;
 
 /**
@@ -47,4 +45,141 @@
 ShellBuffer::~ShellBuffer ()
 {
-  // delete what has to be deleted here
+
+  delete buffer;
+
+  ShellBuffer::singletonRef = NULL;
 }
+
+/**
+ * deletes all the Buffers
+ */
+void ShellBuffer::flushBuffers()
+{
+  // delete all the Chars in the Buffers
+  tIterator<char>* charIterator = this->buffer->getIterator();
+  char* charElem = charIterator->firstElement();
+  while (charElem != NULL)
+  {
+    delete charElem;
+
+    charElem = charIterator->nextElement();
+  }
+  delete charIterator;
+  delete this->buffer;
+  this->buffer = new tList<char>;
+}
+
+/**
+ * adds a new Line to the List of Buffers
+ * @param line the Line as in the first argument in printf
+ */
+bool ShellBuffer::addBufferLineStatic(const char* line, ...)
+{
+  va_list arguments;
+  va_start(arguments, line);
+
+#if DEBUG < 3
+  if (ShellBuffer::singletonRef == NULL)
+#endif
+
+//  vprintf(line, arguments);
+#if DEBUG < 3
+  else
+#else
+  if (ShellBuffer::singletonRef != NULL)
+#endif
+    ShellBuffer::singletonRef->addBufferLine(line, arguments);
+  return true;
+}
+
+/**
+ * add a Line to the List of Buffers
+ * @param line
+ * @param arguments
+ *
+ * This function Adds one line to the buffer.
+ * and displays the line as the First Line of the display-buffer
+ */
+void ShellBuffer::addBufferLine(const char* line, va_list arguments)
+{
+  vsprintf(this->bufferArray, line, arguments);
+
+  char* inputEnd;
+  char* newLineBegin;
+  char* newLineEnd;
+
+   // check if we have something left in the buffers
+  if (unlikely(this->keepBuffer))
+  {
+    strcat(this->keepBufferArray, this->bufferArray);
+    inputEnd = this->keepBufferArray + strlen(this->keepBufferArray);
+    newLineBegin = this->keepBufferArray;
+    this->keepBuffer = false;
+  }
+  else
+  {
+    inputEnd = this->bufferArray + strlen(this->bufferArray);
+    newLineBegin = this->bufferArray;
+  }
+
+   // adding all the new Lines
+  while (newLineBegin < inputEnd)
+  {
+    newLineEnd = strchr(newLineBegin, '\n');
+    if (newLineEnd != NULL && *newLineEnd == '\n')
+      *newLineEnd = '\0';
+    else
+    {
+//       newLineEnd = newLineBegin + strlen(newLineBegin);
+      strcpy(this->keepBufferArray, newLineBegin);
+      this->keepBuffer = true;
+      break;
+    }
+
+    char* addLine = new char[strlen(newLineBegin)+1];
+    strcpy(addLine, newLineBegin);
+
+    this->buffer->add(addLine);
+
+    if (this->buffer->getSize() > this->bufferSize)
+    {
+      delete this->buffer->firstElement();
+      this->buffer->remove(this->buffer->firstElement());
+    }
+
+    newLineBegin = newLineEnd+1;
+  }
+}
+
+/**
+ * moves the buffer around lineCount lines upwards (negative values move down)
+ * @param lineCount the Count of lines to move upwards
+ *
+ * @todo
+ */
+void ShellBuffer::moveBuffer(unsigned int lineCount)
+{
+}
+
+/**
+ * @param lineNumber the n-th line from the bottom
+ * @returns the Buffer at Line lineNumber
+ */
+const char* ShellBuffer::getBufferLine(unsigned int lineNumber)
+{
+  tIterator<char>* charIterator = this->buffer->getIterator();
+  char* charElem = charIterator->firstElement();
+
+  int i = 1;
+  while (charElem != NULL)
+  {
+    if (i++ < lineNumber)
+    {
+      delete charIterator;
+      return charElem;
+    }
+
+    charElem = charIterator->nextElement();
+  }
+  delete charIterator;
+}
Index: trunk/src/lib/shell/shell_buffer.h
===================================================================
--- trunk/src/lib/shell/shell_buffer.h	(revision 5173)
+++ trunk/src/lib/shell/shell_buffer.h	(revision 5174)
@@ -14,5 +14,4 @@
 template<class T> class tList;
 template<class T> class tIterator;
-class Text;
 
 //! A class for ...
@@ -20,32 +19,33 @@
 
  public:
-  ShellBuffer();
   virtual ~ShellBuffer();
-
+  /** @returns a Pointer to the only object of this Class */
+  inline static ShellBuffer* getInstance() { if (!ShellBuffer::singletonRef) ShellBuffer::singletonRef = new ShellBuffer();  return ShellBuffer::singletonRef; };
 
   // BUFFER //
   /** @param bufferSize the new Buffer-Size */
   void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };
-  void setBufferDisplaySize(unsigned int bufferDisplaySize);
   void flushBuffers();
   static bool addBufferLineStatic(const char* line, ...);
   void addBufferLine(const char* line, va_list arg);
-  void printToDisplayBuffer(const char* text);
   void moveBuffer(unsigned int lineCount);
 //    void moveBufferTo(unsigned int lineNumber);
   const char* getBufferLine(unsigned int lineNumber);
 
+  private:
+    ShellBuffer();
 
- private:
-   unsigned int             bufferSize;             //!< The Size of the buffer
-   unsigned int             bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters)
-   tList<char>*             buffer;                 //!< A list of stored char-arrays(strings) to store the history
-   tIterator<char>*         bufferIterator;         //!< An iterator for the Shells main buffer.
 
-   Text**                   bufferText;             //!< A list of stored bufferTexts for the display of the buffer
+  private:
+   static ShellBuffer*      singletonRef;                       //!< The singleton-reference to the only memeber of this class.
+   unsigned int             bufferSize;                         //!< The Size of the buffer
+   tList<char>*             buffer;                             //!< A list of stored char-arrays(strings) to store the history
+   tIterator<char>*         bufferIterator;                     //!< An iterator for the Shells main buffer.
+
    char                     bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
    char                     keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
-   bool                     keepBuffer;             //!< if the keepbuffer contains unfinished lines.
+   bool                     keepBuffer;                         //!< if the keepbuffer contains unfinished lines.
 
+   unsigned long            lineCount;                          //!< how many Lines have been written out so far.
 };
 
Index: trunk/src/lib/shell/shell_command.cc
===================================================================
--- trunk/src/lib/shell/shell_command.cc	(revision 5173)
+++ trunk/src/lib/shell/shell_command.cc	(revision 5174)
@@ -25,4 +25,5 @@
 #include <stdarg.h>
 #include <stdio.h>
+#include <string.h>
 
 using namespace std;
Index: trunk/src/story_entities/world.cc
===================================================================
--- trunk/src/story_entities/world.cc	(revision 5173)
+++ trunk/src/story_entities/world.cc	(revision 5174)
@@ -39,4 +39,5 @@
 #include "text_engine.h"
 #include "load_param.h"
+#include "shell.h"
 
 #include "track_manager.h"
@@ -115,5 +116,5 @@
 World::~World ()
 {
-  delete Shell::getInstance();
+  delete ShellBuffer::getInstance();
   PRINTF(3)("World::~World() - deleting current world\n");
 
@@ -195,5 +196,5 @@
 
   /* init the world interface */
-  Shell::getInstance();
+  ShellBuffer::getInstance();
 
   LightManager::getInstance();
