Index: trunk/src/lib/shell/shell.cc
===================================================================
--- trunk/src/lib/shell/shell.cc	(revision 7340)
+++ trunk/src/lib/shell/shell.cc	(revision 7341)
@@ -36,23 +36,23 @@
 
 SHELL_COMMAND(clear, Shell, clear)
-    ->describe("Clears the shell from unwanted lines (empties all buffers)")
-    ->setAlias("clear");
+->describe("Clears the shell from unwanted lines (empties all buffers)")
+->setAlias("clear");
 SHELL_COMMAND(deactivate, Shell, deactivate)
-    ->describe("Deactivates the Shell. (moves it into background)")
-    ->setAlias("hide");
+->describe("Deactivates the Shell. (moves it into background)")
+->setAlias("hide");
 SHELL_COMMAND(textsize, Shell, setTextSize)
-    ->describe("Sets the size of the Text size, linespacing")
-    ->defaultValues(15, 0);
+->describe("Sets the size of the Text size, linespacing")
+->defaultValues(15, 0);
 SHELL_COMMAND(textcolor, Shell, setTextColor)
-    ->describe("Sets the Color of the Shells Text (red, green, blue, alpha)")
-    ->defaultValues(SHELL_DEFAULT_TEXT_COLOR);
+->describe("Sets the Color of the Shells Text (red, green, blue, alpha)")
+->defaultValues(SHELL_DEFAULT_TEXT_COLOR);
 SHELL_COMMAND(backgroundcolor, Shell, setBackgroundColor)
-    ->describe("Sets the Color of the Shells Background (red, green, blue, alpha)")
-    ->defaultValues(SHELL_DEFAULT_BACKGROUND_COLOR);
+->describe("Sets the Color of the Shells Background (red, green, blue, alpha)")
+->defaultValues(SHELL_DEFAULT_BACKGROUND_COLOR);
 SHELL_COMMAND(backgroundimage, Shell, setBackgroundImage)
-    ->describe("sets the background image to load for the Shell");
+->describe("sets the background image to load for the Shell");
 SHELL_COMMAND(font, Shell, setFont)
-    ->describe("Sets the font of the Shell")
-    ->defaultValues(SHELL_DEFAULT_FONT);
+->describe("Sets the font of the Shell")
+->defaultValues(SHELL_DEFAULT_FONT);
 
 /**
@@ -71,17 +71,15 @@
 
   // BUFFER
-  this->bufferText = NULL;
-  this->bufferDisplaySize = 10;
   this->bufferOffset = 0;
   this->bufferIterator = ShellBuffer::getInstance()->getBuffer().begin();
 
   // INPUT LINE
-  this->shellInput = new ShellInput;
-  this->shellInput->setLayer(E2D_LAYER_ABOVE_ALL);
+  this->setLayer(E2D_LAYER_ABOVE_ALL);
+  this->shellInput.setLayer(E2D_LAYER_ABOVE_ALL);
 
   this->backgroundMaterial = new Material;
+
   // Element2D and generals
   this->setAbsCoor2D(3, -400);
-  this->setLayer(E2D_LAYER_ABOVE_ALL);
   this->textSize = 20;
   this->lineSpacing = 0;
@@ -89,9 +87,9 @@
   this->fontFile = SHELL_DEFAULT_FONT;
 
-
-  this->rebuildText();
+  this->setBufferDisplaySize(10);
 
   this->setTextColor(SHELL_DEFAULT_TEXT_COLOR);
   this->setBackgroundColor(SHELL_DEFAULT_BACKGROUND_COLOR);
+
 
   this->deactivate();
@@ -101,5 +99,5 @@
 
 /**
- * standard deconstructor
+ * @brief standard deconstructor
  */
 Shell::~Shell ()
@@ -108,14 +106,16 @@
 
   // delete the displayable Buffers
-  for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
-    delete this->bufferText[i];
-  delete[] this->bufferText;
+  while (!this->bufferText.empty())
+  {
+    delete this->bufferText.front();
+    this->bufferText.pop_front();
+  }
+
   // delete the inputLine
-  delete this->shellInput;
   delete this->backgroundMaterial;
 }
 
 /**
- * activates the shell
+ * @brief activates the shell
  *
  * This also feeds the Last few lines from the main buffers into the displayBuffer
@@ -134,12 +134,12 @@
   list<std::string>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer().end();
   bool top = false;
-  for (int i = 0; i < this->bufferDisplaySize; i++)
-  {
-    this->bufferText[i]->setVisibility(true);
+  for (std::list<Text*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text)
+  {
+    (*text)->setVisibility(true);
     if (!top)
     {
-      this->bufferText[i]->setText((*textLine));
-    if (textLine != ShellBuffer::getInstance()->getBuffer().begin())
-      top = true;
+      (*text)->setText((*textLine));
+      if (textLine != ShellBuffer::getInstance()->getBuffer().begin())
+        top = true;
       textLine--;
     }
@@ -161,14 +161,6 @@
   this->setRelCoorSoft2D(0, -(int)this->shellHeight, 5);
 
-  list<std::string>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer().end();
-  for (int i = 0; i < this->bufferDisplaySize; i++)
-  {
-    this->bufferText[i]->setVisibility(false);
-    if (textLine != ShellBuffer::getInstance()->getBuffer().begin())
-    {
-      this->bufferText[i]->setText((*textLine));
-      textLine--;
-    }
-  }
+  for (std::list<Text*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text)
+    (*text)->setVisibility(false);
   this->bufferOffset = 0;
 }
@@ -183,10 +175,10 @@
 void Shell::setFont(const std::string& fontFile)
 {
-//   if (!ResourceManager::isInDataDir(fontFile))
-//     return false;
+  //   if (!ResourceManager::isInDataDir(fontFile))
+  //     return false;
 
   this->fontFile = fontFile;
 
-  this->rebuildText();
+  this->resetValues();
 }
 
@@ -203,9 +195,10 @@
   this->textSize = textSize;
   this->lineSpacing = lineSpacing;
+
   this->resetValues();
 }
 
 /**
- * sets the color of the Font.
+ * @brief sets the color of the Font.
  * @param r: red
  * @param g: green
@@ -225,5 +218,5 @@
 
 /**
- * sets the color of the Backgrond.
+ * @brief sets the color of the Backgrond.
  * @param r: red
  * @param g: green
@@ -238,5 +231,5 @@
 
 /**
- * sets a nice background image to the Shell's background
+ * @brief sets a nice background image to the Shell's background
  * @param fileName the filename of the Image to load
  */
@@ -248,5 +241,5 @@
 
 /**
- * resets the Values of all visible shell's commandos to the Shell's stored values
+ * @brief resets the Values of all visible shell's commandos to the Shell's stored values
  *
  * this functions synchronizes the stored Data with the visible one.
@@ -254,114 +247,84 @@
 void Shell::resetValues()
 {
-  if (this->shellInput != NULL)
-  {
-    this->shellInput->setSize(this->textSize);
-    this->shellInput->setColor(this->textColor[0], this->textColor[1], this->textColor[2]);
-    this->shellInput->setBlending(this->textColor[3]);
-    this->shellInput->setRelCoor2D(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize));
-  }
-
-  if (this->bufferText != NULL)
-  {
-    for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
-    {
-      if (this->bufferText[i] != NULL)
-      {
-        this->bufferText[i]->setSize(this->textSize);
-        this->bufferText[i]->setColor(this->textColor[0], this->textColor[1], this->textColor[2]);
-        this->bufferText[i]->setBlending(this->textColor[3]);
-        this->bufferText[i]->setRelCoor2D(calculateLinePosition(i));
-      }
-    }
+  this->shellInput.setFont(this->fontFile, this->textSize);
+  this->shellInput.setColor(this->textColor[0], this->textColor[1], this->textColor[2]);
+  this->shellInput.setBlending(this->textColor[3]);
+  this->shellInput.setRelCoor2D(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize));
+  this->shellInput.setLayer(this->getLayer());
+  if (shellInput.getParent2D() != this)
+    this->shellInput.setParent2D(this);
+
+  unsigned int i = 0;
+  for (std::list<Text*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text, ++i)
+  {
+    (*text)->setFont(this->fontFile, this->textSize);
+    (*text)->setColor(this->textColor[0], this->textColor[1], this->textColor[2]);
+    (*text)->setBlending(this->textColor[3]);
+    (*text)->setRelCoor2D( calculateLinePosition(i) );
+    (*text)->setLayer(this->getLayer());
+    if ((*text)->getParent2D() != this)
+      (*text)->setParent2D(this);
   }
   this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);
 }
 
-/**
- * rebuilds the Text's
- *
- * use this function, if you changed the Font/Size or something else.
- */
-void Shell::rebuildText()
-{
-  this->shellInput->setFont(this->fontFile, this->textSize);
-  this->shellInput->setAlignment(TEXT_ALIGN_LEFT);
-  if (shellInput->getParent2D() != this)
-    this->shellInput->setParent2D(this);
-
-  this->setBufferDisplaySize(this->bufferDisplaySize);
-}
-
-/**
- * sets The count of Lines to display in the buffer.
+
+/**
+ * @brief sets The count of Lines to display in the buffer.
  * @param bufferDisplaySize the count of lines to display in the Shell-Buffer.
  */
 void Shell::setBufferDisplaySize(unsigned int bufferDisplaySize)
 {
-  Text** bufferText = this->bufferText;
-  this->bufferText = NULL;
-  if (bufferText != NULL)
-  {
-    for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
-      delete bufferText[i];
-    delete[] bufferText;
-  }
-
-  list<std::string>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer().end();
-  bufferText = new Text*[bufferDisplaySize];
-  for (unsigned int i = 0; i < bufferDisplaySize; i++)
-  {
-    bufferText[i] = new Text(this->fontFile, this->textSize);
-    bufferText[i]->setLayer(E2D_LAYER_ABOVE_ALL);
-    bufferText[i]->setAlignment(TEXT_ALIGN_LEFT);
-    bufferText[i]->setParent2D(this);
-    if(textLine != ShellBuffer::getInstance()->getBuffer().begin())
-    {
-      bufferText[i]->setText(*textLine);
-      textLine--;
+  unsigned int oldSize = this->bufferText.size();
+  if (oldSize > bufferDisplaySize)
+  {
+    for (unsigned int i = bufferDisplaySize; i <= oldSize; i++)
+    {
+      delete this->bufferText.back();
+      this->bufferText.pop_back();
+    }
+  }
+  else if (oldSize < bufferDisplaySize)
+  {
+    for (unsigned int i = oldSize; i <= bufferDisplaySize; i++)
+    {
+      this->bufferText.push_back(new Text);
     }
   }
   this->bufferDisplaySize = bufferDisplaySize;
-
-  this->bufferText = bufferText;
-  this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);
-}
-
-/**
- * deletes all the Buffers
+  this->resetValues();
+}
+
+/**
+ * @brief deletes all the Buffers
  */
 void Shell::flush()
 {
-  // remove all chars from the BufferTexts.
-  if (this->bufferText != NULL)
-    for (int i = 0; i < this->bufferDisplaySize; i++)
-    {
-      this->bufferText[i]->setText("");
-    }
-
-    ShellBuffer::getInstance()->flush();
-    // BUFFER FLUSHING
-}
-
-/**
- * prints out some text to the input-buffers
+  for (std::list<Text*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text)
+  {
+    (*text)->setText("");  // remove all chars from the BufferTexts.
+  }
+  ShellBuffer::getInstance()->flush();
+  // BUFFER FLUSHING
+}
+
+/**
+ * @brief prints out some text to the input-buffers
  * @param text the text to output.
  */
 void Shell::printToDisplayBuffer(const std::string& text)
 {
-  if(likely(bufferText != NULL))
-  {
-    Text* lastText = this->bufferText[this->bufferDisplaySize-1];
-
-    Text* swapText;
-    Text* moveText = this->bufferText[0];
-    for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
-    {
-      if ( i < this->bufferDisplaySize-1)
-        this->bufferText[i]->setRelCoorSoft2D(this->calculateLinePosition(i+1), 5);
-      swapText = this->bufferText[i];
-      this->bufferText[i] = moveText;
-      moveText = swapText;
-    }
+  this->bufferText.push_front(this->bufferText.back());
+  this->bufferText.pop_back();
+
+
+  unsigned int i = 0;
+  for (std::list<Text*>::iterator textIt = ++this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt, i++)
+  {
+    (*textIt)->setRelCoorSoft2D(this->calculateLinePosition(i+1), 5);
+  }
+
+  this->bufferText.front()->setRelCoor2D(this->calculateLinePosition(0)- Vector2D(-1000,0));
+  this->bufferText.front()->setRelCoorSoft2D(this->calculateLinePosition(0),10);
 
   /*  FANCY EFFECTS :)
@@ -370,15 +333,11 @@
         lastText->setRelCoorSoft2D(this->calculateLinePosition(0),10);
     2:
-  */
     lastText->setRelDir2D(-90);
     lastText->setRelDirSoft2D(0, 20);
-    lastText->setRelCoor2D(this->calculateLinePosition(0)- Vector2D(-1000,0));
-    lastText->setRelCoorSoft2D(this->calculateLinePosition(0),10);
-
- //   lastText->setRelCoor2D(this->calculateLinePosition(0));
-    this->bufferText[0] = lastText;
-
-    this->bufferText[0]->setText(text);
-  }
+  */
+
+  //   lastText->setRelCoor2D(this->calculateLinePosition(0));
+
+  this->bufferText.front()->setText(text);
 }
 
@@ -392,9 +351,9 @@
 {
   if (this->bufferOffset == 0)
-   {
-     this->bufferIterator = ShellBuffer::getInstance()->getBuffer().end();
-//     for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
-//       this->bufferIterator->prevStep();
-   }
+  {
+    this->bufferIterator = ShellBuffer::getInstance()->getBuffer().end();
+    //     for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
+    //       this->bufferIterator->prevStep();
+  }
 
   // boundraries
@@ -422,7 +381,7 @@
   // redisplay the buffers
   list<std::string>::const_iterator it = this->bufferIterator;
-  for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
-  {
-    this->bufferText[i]->setText((*it));
+  for (std::list<Text*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt)
+  {
+    (*textIt)->setText((*it));
     it--;
   }
@@ -514,6 +473,6 @@
   PRINT(3)("Debugging output to console (not this shell)\n");
 
-//   if (this->pressedKey != SDLK_FIRST)
-//     printf("%s::%f %f\n", SDLKToKeyname(this->pressedKey), this->delayed, this->repeatDelay);
+  //   if (this->pressedKey != SDLK_FIRST)
+  //     printf("%s::%f %f\n", SDLKToKeyname(this->pressedKey), this->delayed, this->repeatDelay);
 
 
Index: trunk/src/lib/shell/shell.h
===================================================================
--- trunk/src/lib/shell/shell.h	(revision 7340)
+++ trunk/src/lib/shell/shell.h	(revision 7341)
@@ -13,5 +13,5 @@
 #include "event_listener.h"
 
-#include <stdarg.h>
+#include "shell_input.h"
 
 #define         SHELL_DEFAULT_FONT              "fonts/dpquake_.ttf"
@@ -60,5 +60,4 @@
 
     void resetValues();
-    void rebuildText();
 
     // BUFFERS
@@ -99,8 +98,8 @@
 
     // HANDLING TEXT INPUT
-    ShellInput*                 shellInput;             //!< The inputLine of the Shell.
+    ShellInput                  shellInput;             //!< The inputLine of the Shell.
     // BUFFER
     unsigned int                bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters).
-    Text**                      bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
+    std::list<Text*>            bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
     int                         bufferOffset;           //!< how many lines from the bottom up we display the Buffer.
     std::list<std::string>::const_iterator  bufferIterator;         //!< used to move through and print the Buffer
Index: trunk/src/lib/shell/shell_input.cc
===================================================================
--- trunk/src/lib/shell/shell_input.cc	(revision 7340)
+++ trunk/src/lib/shell/shell_input.cc	(revision 7341)
@@ -60,4 +60,10 @@
       evh->subscribe(this, ES_SHELL, i);
   }
+  // unsubscribe unused TODO improve.
+  evh->unsubscribe(ES_SHELL, SDLK_BACKQUOTE);
+  evh->unsubscribe(ES_SHELL, SDLK_F12);
+  evh->unsubscribe(ES_SHELL, SDLK_PAGEUP);
+  evh->unsubscribe(ES_SHELL, SDLK_PAGEDOWN);
+
   this->completion = new ShellCompletion(this);
 }
