Index: /code/branches/presentation2/src/libraries/core/IOConsole.cc
===================================================================
--- /code/branches/presentation2/src/libraries/core/IOConsole.cc	(revision 6176)
+++ /code/branches/presentation2/src/libraries/core/IOConsole.cc	(revision 6177)
@@ -33,4 +33,5 @@
 #include <iostream>
 
+#include "util/Clock.h"
 #include "util/Math.h"
 #include "core/Game.h"
@@ -61,11 +62,4 @@
     }
 
-    inline bool IOConsole::willPrintStatusLines()
-    {
-        return !this->statusLineWidths_.empty()
-             && this->terminalWidth_  >= this->statusLineMaxWidth_
-             && this->terminalHeight_ >= (this->minOutputLines_ + this->statusLineWidths_.size());
-    }
-
     // ###############################
     // ###  ShellListener methods  ###
@@ -78,18 +72,4 @@
         // or when scrolling. But scrolling is disabled and the output
         // is already in std::cout when we start the IOConsole
-    }
-
-    //! Called if the text in the input-line has changed
-    void IOConsole::inputChanged()
-    {
-        this->printInputLine();
-        this->cout_.flush();
-    }
-
-    //! Called if the position of the cursor in the input-line has changed
-    void IOConsole::cursorChanged()
-    {
-        this->printInputLine();
-        this->cout_.flush();
     }
 
@@ -131,6 +111,6 @@
         , buffer_(shell_->getInputBuffer())
         , cout_(std::cout.rdbuf())
+        , promptString_("orxonox # ")
         , bStatusPrinted_(false)
-        , promptString_("orxonox # ")
         , originalTerminalSettings_(0)
     {
@@ -304,5 +284,5 @@
     }
 
-    void IOConsole::printLogText(const std::string& text)
+    void IOConsole::printOutputLine(const std::string& text)
     {
         std::string output = text;
@@ -419,4 +399,11 @@
     }
 
+    inline bool IOConsole::willPrintStatusLines()
+    {
+        return !this->statusLineWidths_.empty()
+             && this->terminalWidth_  >= this->statusLineMaxWidth_
+             && this->terminalHeight_ >= (this->minOutputLines_ + this->statusLineWidths_.size());
+    }
+
     // ###############################
     // ###  ShellListener methods  ###
@@ -431,5 +418,5 @@
         this->cout_ << "\033[K";
         // Reprint the last output line
-        this->printLogText(*(this->shell_->getNewestLineIterator()));
+        this->printOutputLine(*(this->shell_->getNewestLineIterator()));
         // Restore cursor
         this->cout_ << "\033[u";
@@ -449,5 +436,5 @@
         // Print the new output lines
         for (int i = 0; i < newLines; ++i)
-            this->printLogText(this->shell_->getNewestLineIterator()->substr(i*this->terminalWidth_, this->terminalWidth_));
+            this->printOutputLine(this->shell_->getNewestLineIterator()->substr(i*this->terminalWidth_, this->terminalWidth_));
         // Move cursor down
         this->cout_ << "\033[1B\033[1G";
@@ -457,4 +444,18 @@
         this->cout_.flush();
     }
+
+    //! Called if the text in the input-line has changed
+    void IOConsole::inputChanged()
+    {
+        this->printInputLine();
+        this->cout_.flush();
+    }
+
+    //! Called if the position of the cursor in the input-line has changed
+    void IOConsole::cursorChanged()
+    {
+        this->printInputLine();
+        this->cout_.flush();
+    }
 }
 
@@ -472,18 +473,9 @@
         , buffer_(shell_->getInputBuffer())
         , cout_(std::cout.rdbuf())
-        , bStatusPrinted_(false)
         , promptString_("orxonox # ")
-    {
-        this->setTerminalMode();
-        this->shell_->registerListener(this);
-
-        // Manually set the widths of the individual status lines
-        this->statusLineWidths_.push_back(29);
-        this->statusLineMaxWidth_ = 29;
-
-        this->getTerminalSize();
-        this->lastTerminalWidth_ = this->terminalWidth_;
-        this->lastTerminalHeight_ = this->terminalHeight_;
-
+        , statusLines_(1)
+        , inputLineHeight_(1)
+        , lastOutputLineHeight_(1)
+    {
         // Disable standard this->cout_ logging
         OutputHandler::getInstance().disableCout();
@@ -492,15 +484,45 @@
         std::cout.rdbuf(this->origCout_.rdbuf());
 
-        // Make sure we make way for the status lines
+        this->setTerminalMode();
+        CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo;
+        GetConsoleScreenBufferInfo(this->stdOutHandle_, &screenBufferInfo);
+        this->terminalWidth_  = screenBufferInfo.dwSize.X;
+        this->terminalHeight_ = screenBufferInfo.dwSize.Y;
+        this->lastTerminalWidth_  = this->terminalWidth_;
+        this->lastTerminalHeight_ = this->terminalHeight_;
+        // Determines where we are in respect to output already written with std::cout
+        this->inputLineRow_ = screenBufferInfo.dwCursorPosition.Y;
+
+        // Cursor already at the end of the screen buffer?
+        // (assuming the current input line height is 1)
+        if (this->inputLineRow_ >= (int)this->terminalHeight_ - (int)this->statusLines_)
+            this->moveCursor(0, -this->inputLineRow_ + this->terminalHeight_ - this->statusLines_ - 1);
+
+        // Prevent input line from overflowing
+        int maxInputLength = (this->terminalHeight_ - this->statusLines_) * this->terminalWidth_ - 1 - this->promptString_.size();
+        // Consider that the echo of a command might include the command plus some other characters (assumed max 80)
+        // Also put a minimum so the config file parser is not overwhelmed with the command history
+        this->shell_->getInputBuffer()->setMaxLength(std::min(8192, (maxInputLength - 80) / 2));
+
+        // Print input and status line and position cursor
+        this->lastRefreshTime_ = Game::getInstance().getGameClock().getRealMicroseconds();
         this->update(Game::getInstance().getGameClock());
+        this->inputChanged();
+        this->cursorChanged();
+
+        this->shell_->registerListener(this);
     }
 
     IOConsole::~IOConsole()
     {
+        this->shell_->unregisterListener(this);
         // Empty all buffers
         this->update(Game::getInstance().getGameClock());
 
-        resetTerminalMode();
-        this->shell_->destroy();
+        // Erase input and status lines
+        COORD pos = {0, this->inputLineRow_};
+        this->writeText(std::string((this->inputLineHeight_ + this->statusLines_) * this->terminalWidth_, ' '), pos);
+        // Move cursor to the beginning of the line
+        SetConsoleCursorPosition(stdOutHandle_, pos);
 
         // Restore this->cout_ redirection
@@ -508,8 +530,12 @@
         // Enable standard this->cout_ logging again
         OutputHandler::getInstance().enableCout();
+
+        resetTerminalMode();
+        this->shell_->destroy();
     }
 
     void IOConsole::update(const Clock& time)
     {
+        // Process input
         while (true)
         {
@@ -539,6 +565,6 @@
                 {
                 case VK_BACK:   this->buffer_->buttonPressed(KeyEvent(KeyCode::Back,     asciiChar, modifiersOut)); break;
-                case VK_TAB:    this->buffer_->buttonPressed(KeyEvent(KeyCode::Back,     asciiChar, modifiersOut)); break;
-                case VK_RETURN: this->buffer_->buttonPressed(KeyEvent(KeyCode::Back,     asciiChar, modifiersOut)); break;
+                case VK_TAB:    this->buffer_->buttonPressed(KeyEvent(KeyCode::Tab,      asciiChar, modifiersOut)); break;
+                case VK_RETURN: this->buffer_->buttonPressed(KeyEvent(KeyCode::Return,   asciiChar, modifiersOut)); break;
                 case VK_PAUSE:  this->buffer_->buttonPressed(KeyEvent(KeyCode::Pause,    asciiChar, modifiersOut)); break;
                 case VK_ESCAPE: this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape,   asciiChar, modifiersOut)); break;
@@ -559,9 +585,20 @@
         }
 
-        // Get info about cursor and terminal size
-        this->getTerminalSize();
-
-        // Refresh status line
-        this->printStatusLines();
+        // TODO: Respect screen buffer size changes
+        // The user can manually adjust the screen buffer size on Windows
+        // And we don't want to screw the console because of that
+        //this->lastTerminalWidth_ = this->terminalWidth_;
+        //this->lastTerminalHeight_ = this->terminalHeight_;
+        //this->getTerminalSize(); // Also sets this->inputLineRow_ according to the cursor position
+        // Is there still enough space below the cursor for the status line(s)?
+        //if (this->inputLineRow_ >= this->terminalHeight_ - this->statusLines_)
+        //    this->moveCursor(0, -this->inputLineRow_ + this->terminalHeight_ - this->statusLines_ - 1);
+
+        // Refresh status line 5 times per second
+        if (time.getMicroseconds() > this->lastRefreshTime_ + 1000000)
+        {
+            this->printStatusLines();
+            this->lastRefreshTime_ = time.getMicroseconds();
+        }
 
         // Process output written to std::cout
@@ -571,8 +608,7 @@
             this->origCout_.str("");
         }
-        this->cout_.flush();
-    }
-
-    void IOConsole::printLogText(const std::string& text)
+    }
+
+    void IOConsole::printOutputLine(const std::string& text, const COORD& pos)
     {
         std::string output = text;
@@ -580,52 +616,28 @@
 
         // Colour line
+        WORD colour = 0;
         switch (level)
         {
-        case  1: SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_RED | FOREGROUND_INTENSITY); break;
-        case  2: SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY); break;
-        case  3: SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_INTENSITY); break;
-        case  4: SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_INTENSITY); break;
-        default: break;
+        case  1: colour = FOREGROUND_RED | FOREGROUND_INTENSITY; break;
+        case  2: colour = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY; break;
+        case  3: colour = FOREGROUND_INTENSITY; break;
+        case  4: colour = FOREGROUND_INTENSITY; break;
+        default: colour = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN; break;
         }
 
         // Print output line
-        this->cout_ << output;
-
-        // Reset colour to white
-        SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
-    }
-
-    void IOConsole::printInputLine()
-    {
-        SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
-        this->moveCursorYAndHome(0);
-        this->clearCurrentLine();
-        this->cout_ << this->promptString_ << this->shell_->getInput();
-        this->moveCursorYAndHome(0);
-        this->moveCursor(this->promptString_.size() + this->buffer_->getCursorPosition(), 0);
-        SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
+        this->writeText(output, pos, colour);
     }
 
     void IOConsole::printStatusLines()
     {
-        if (this->willPrintStatusLines())
-        {
-            SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_GREEN);
-            this->bStatusPrinted_ = true;
-            // Put cursor on home position, one line down the input line
-            this->moveCursorYAndHome(1);
-            this->cout_ << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, ";
-            this->cout_ <<               std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms tick time";
-            // Clear rest of the line
-            CONSOLE_SCREEN_BUFFER_INFO info;
-            GetConsoleScreenBufferInfo(this->stdOutHandle_, &info);
-            this->cout_ << std::string(info.dwSize.X - info.dwCursorPosition.X - 1, ' ');
-            // Restore cursor position
-            this->moveCursorYAndHome(-1);
-            this->moveCursor(this->promptString_.size() + this->buffer_->getCursorPosition(), 0);
-            SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
-        }
-        else
-            this->bStatusPrinted_ = false;
+        // Prepare text to be written
+        std::ostringstream oss;
+        oss << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, ";
+        oss <<               std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms tick time";
+        // Clear rest of the line by inserting spaces
+        oss << std::string(this->terminalWidth_ - oss.str().size(), ' ');
+        COORD pos = {0, this->inputLineRow_ + this->inputLineHeight_};
+        this->writeText(oss.str(), pos, FOREGROUND_GREEN);
     }
 
@@ -650,6 +662,5 @@
     }
 
-    //! Moves the console cursor around and inserts new lines when reaching the end.
-    //! Moving out on the right is just clamped though.
+    //! Moves the console cursor around and clamps its position to fit into the screen buffer
     void IOConsole::moveCursor(int dx, int dy)
     {
@@ -659,31 +670,6 @@
         x = clamp(x + dx, 0, info.dwSize.X - 1);
         SHORT& y = info.dwCursorPosition.Y;
-        if (y + dy >= info.dwSize.Y)
-        {
-            // Insert new lines
-            this->cout_ << std::string(y + dy - info.dwSize.Y + 1, 'n');
-            y = info.dwSize.Y - 1;
-        }
-        else if (y < 0)
-            y = 0;
-        else
-            y += dy;
+        y = clamp(y + dy, 0, info.dwSize.Y - 1);
         SetConsoleCursorPosition(this->stdOutHandle_, info.dwCursorPosition);
-    }
-
-    void IOConsole::moveCursorYAndHome(int dy)
-    {
-        CONSOLE_SCREEN_BUFFER_INFO info;
-        GetConsoleScreenBufferInfo(this->stdOutHandle_, &info);
-        this->moveCursor(-info.dwCursorPosition.X, dy);
-    }
-
-    void IOConsole::clearCurrentLine()
-    {
-        CONSOLE_SCREEN_BUFFER_INFO info;
-        GetConsoleScreenBufferInfo(this->stdOutHandle_, &info);
-        info.dwCursorPosition.X = 0;
-        DWORD count;
-        FillConsoleOutputCharacter(this->stdOutHandle_, ' ', info.dwSize.X, info.dwCursorPosition, &count);;
     }
 
@@ -692,8 +678,42 @@
         CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo;
         GetConsoleScreenBufferInfo(this->stdOutHandle_, &screenBufferInfo);
-        // dwSize is the maximum size. If you resize you will simply see scroll bars.
-        // And if you want to write outside these boundaries, you can't.
         this->terminalWidth_  = screenBufferInfo.dwSize.X;
         this->terminalHeight_ = screenBufferInfo.dwSize.Y;
+    }
+
+    void IOConsole::writeText(const std::string& text, const COORD& coord, WORD attributes)
+    {
+        DWORD count;
+        WriteConsoleOutputCharacter(stdOutHandle_, text.c_str(), text.size(), coord, &count);
+        WORD* attributeBuf = new WORD[text.size()];
+        for (unsigned int i = 0; i < text.size(); ++i)
+            attributeBuf[i] = attributes;
+        WriteConsoleOutputAttribute(stdOutHandle_, attributeBuf, text.size(), coord, &count);
+    }
+
+    void IOConsole::createNewOutputLines(unsigned int lines)
+    {
+        CHAR_INFO fillChar = {' ', FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED};
+        // Check whether we're already at the bottom
+        if (this->inputLineRow_ + lines > this->terminalHeight_ - this->statusLines_ - this->inputLineHeight_)
+        {
+            // Scroll output up
+            SMALL_RECT oldRect = {0, lines, this->terminalWidth_ - 1, this->inputLineRow_ - 1};
+            COORD newPos = {0, 0};
+            ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, newPos, &fillChar);
+        }
+        else
+        {
+            // Scroll input and status lines down
+            SMALL_RECT oldRect = {0, this->inputLineRow_, this->terminalWidth_ - 1, this->inputLineRow_ + this->statusLines_ + this->inputLineHeight_ - 1};
+            this->inputLineRow_ += lines;
+            COORD newPos = {0, this->inputLineRow_};
+            ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, newPos, &fillChar);
+            // Move cursor down to the new bottom so the user can see the status lines
+            COORD pos = {0, this->inputLineRow_ + this->inputLineHeight_ - 1 + this->statusLines_};
+            SetConsoleCursorPosition(stdOutHandle_, pos);
+            // Get cursor back to the right position
+            this->cursorChanged();
+        }
     }
 
@@ -702,13 +722,64 @@
     // ###############################
 
+    //! Called if the text in the input-line has changed
+    void IOConsole::inputChanged()
+    {
+        int inputLineLength = this->promptString_.size() + this->shell_->getInput().size();
+        int lineHeight = 1 + inputLineLength / this->terminalWidth_;
+        int newLines = lineHeight - this->inputLineHeight_;
+        if (newLines > 0)
+        {
+            // Abuse this function to scroll the console
+            this->createNewOutputLines(newLines);
+            this->inputLineRow_ -= newLines; // Undo
+        }
+        else if (newLines < 0)
+        {
+            // Scroll status lines up
+            SMALL_RECT oldRect = {0, this->inputLineRow_ + this->inputLineHeight_, this->terminalWidth_ - 1, this->inputLineRow_ + this->inputLineHeight_ + this->statusLines_};
+            COORD newPos = {0, this->inputLineRow_ + this->inputLineHeight_ + newLines};
+            CHAR_INFO fillChar = {' ', FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED};
+            ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, newPos, &fillChar);
+            // Clear potential leftovers
+            if (-newLines - this->statusLines_ > 0)
+            {
+                COORD pos = {0, this->inputLineRow_ + lineHeight + this->statusLines_};
+                this->writeText(std::string((-newLines - this->statusLines_) * this->terminalWidth_, ' '), pos);
+            }
+        }
+        this->inputLineHeight_ = lineHeight;
+
+        // Print the whole line, including spaces to erase leftovers
+        COORD pos = {0, this->inputLineRow_};
+        WORD colour = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
+        this->writeText(this->promptString_ + this->shell_->getInput() + std::string(this->terminalWidth_ - inputLineLength % this->terminalWidth_, ' '), pos, colour);
+        // If necessary, move cursor
+        if (newLines != 0)
+            this->cursorChanged();
+    }
+
+    //! Called if the position of the cursor in the input-line has changed
+    void IOConsole::cursorChanged()
+    {
+        COORD pos;
+        unsigned int total = this->promptString_.size() + this->buffer_->getCursorPosition();
+        // Compensate for cursor further to the right than the terminal width
+        pos.X = total % this->terminalWidth_;
+        pos.Y = this->inputLineRow_ + total / this->terminalWidth_;
+        SetConsoleCursorPosition(stdOutHandle_, pos);
+    }
+
     //! Called if only the last output-line has changed
     void IOConsole::onlyLastLineChanged()
     {
-        this->moveCursorYAndHome(-1);
-        this->clearCurrentLine();
-        this->printLogText(*(this->shell_->getNewestLineIterator()));
-        this->moveCursorYAndHome(1);
-        this->moveCursor(this->promptString_.size() + this->shell_->getInput().size(), 0);
-        this->cout_.flush();
+        int lineHeight = 1 + this->shell_->getNewestLineIterator()->size() / this->terminalWidth_;
+        int newLines = lineHeight - this->lastOutputLineHeight_;
+        this->lastOutputLineHeight_ = lineHeight;
+        if (newLines > 0)
+            this->createNewOutputLines(newLines);
+        // Write text (assuming it is longer than the previous text)
+        assert(newLines >= 0);
+        COORD pos = {0, this->inputLineRow_ - lineHeight};
+        this->printOutputLine(*(this->shell_->getNewestLineIterator()), pos);
     }
 
@@ -716,14 +787,10 @@
     void IOConsole::lineAdded()
     {
-        // Move cursor to the beginning of the new (last) output line
-        this->moveCursorYAndHome(0);
-        // Print the new output lines
-        this->printLogText(*(this->shell_->getNewestLineIterator()));
-        // Move cursor down
-        this->moveCursorYAndHome(1);
-        // Print status and input lines
-        this->printInputLine();
-        this->printStatusLines();
-        this->cout_.flush();
+        this->lastOutputLineHeight_ = 1 + this->shell_->getNewestLineIterator()->size() / this->terminalWidth_;
+        if (this->lastOutputLineHeight_ > 0)
+            this->createNewOutputLines(this->lastOutputLineHeight_);
+        // Write the text
+        COORD pos = {0, this->inputLineRow_ - this->lastOutputLineHeight_};
+        this->printOutputLine(*(this->shell_->getNewestLineIterator()), pos);
     }
 }
Index: /code/branches/presentation2/src/libraries/core/IOConsole.h
===================================================================
--- /code/branches/presentation2/src/libraries/core/IOConsole.h	(revision 6176)
+++ /code/branches/presentation2/src/libraries/core/IOConsole.h	(revision 6177)
@@ -43,4 +43,5 @@
 #elif defined(ORXONOX_PLATFORM_WINDOWS)
 #define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
 #include <windows.h>
 #endif
@@ -60,11 +61,7 @@
     private:
         void setTerminalMode();
-        static void resetTerminalMode();
         void getTerminalSize();
-        bool willPrintStatusLines();
         int extractLogLevel(std::string* text);
 
-        void printLogText(const std::string& line);
-        void printInputLine();
         void printStatusLines();
 
@@ -85,21 +82,34 @@
         unsigned int            lastTerminalWidth_;
         unsigned int            lastTerminalHeight_;
+        const std::string       promptString_;
+
+#ifdef ORXONOX_PLATFORM_UNIX
+        bool willPrintStatusLines();
+        void printOutputLine(const std::string& line);
+        void printInputLine();
+        static void resetTerminalMode();
+
         bool                    bPrintStatusLine_;
         bool                    bStatusPrinted_;
         std::vector<unsigned>   statusLineWidths_;
         unsigned int            statusLineMaxWidth_;
-        const std::string       promptString_;
         static const unsigned   minOutputLines_ = 3;
+        termios*                originalTerminalSettings_;
 
-#ifdef ORXONOX_PLATFORM_UNIX
-        termios*         originalTerminalSettings_;
 #elif defined(ORXONOX_PLATFORM_WINDOWS)
+        void resetTerminalMode();
         void moveCursor(int dx, int dy);
-        void moveCursorYAndHome(int dy);
-        void clearCurrentLine();
+        void writeText(const std::string& text, const COORD& pos, WORD attributes = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
+        void createNewOutputLines(unsigned int lines);
+        void printOutputLine(const std::string& line, const COORD& pos);
 
         DWORD                   originalTerminalSettings_;
         HANDLE                  stdInHandle_;
         HANDLE                  stdOutHandle_;
+        int                     inputLineRow_;
+        unsigned int            inputLineHeight_;
+        const unsigned int      statusLines_;
+        unsigned int            lastOutputLineHeight_;
+        uint64_t                lastRefreshTime_;
 #endif
 
Index: /code/branches/presentation2/src/libraries/core/input/InputBuffer.cc
===================================================================
--- /code/branches/presentation2/src/libraries/core/input/InputBuffer.cc	(revision 6176)
+++ /code/branches/presentation2/src/libraries/core/input/InputBuffer.cc	(revision 6177)
@@ -41,4 +41,5 @@
         this->buffer_ = "";
         this->cursor_ = 0;
+        this->maxLength_ = 1024;
         this->allowedChars_ = "abcdefghijklmnopqrstuvwxyz \
                                ABCDEFGHIJKLMNOPQRSTUVWXYZ \
@@ -59,4 +60,5 @@
         RegisterRootObject(InputBuffer);
 
+        this->maxLength_ = 1024;
         this->allowedChars_ = allowedChars;
         this->buffer_ = "";
@@ -93,4 +95,11 @@
     }
 
+    void InputBuffer::setMaxLength(unsigned int length)
+    {
+        this->maxLength_ = length;
+        if (this->buffer_.size() > length)
+            this->buffer_.resize(length);
+    }
+
     void InputBuffer::set(const std::string& input, bool update)
     {
@@ -117,4 +126,6 @@
         if (this->charIsAllowed(input))
         {
+            if (this->buffer_.size() >= this->maxLength_)
+                return;
             this->buffer_.insert(this->cursor_, 1, input);
             ++this->cursor_;
Index: /code/branches/presentation2/src/libraries/core/input/InputBuffer.h
===================================================================
--- /code/branches/presentation2/src/libraries/core/input/InputBuffer.h	(revision 6176)
+++ /code/branches/presentation2/src/libraries/core/input/InputBuffer.h	(revision 6177)
@@ -82,4 +82,7 @@
 
             void setConfigValues();
+
+            unsigned int getMaxLength() const { return this->maxLength_; }
+            void setMaxLength(unsigned int length);
 
             template <class T>
@@ -175,4 +178,5 @@
             std::list<BaseInputBufferListenerTuple*> listeners_;
             std::string allowedChars_;
+            unsigned int maxLength_;
             unsigned int cursor_;
 
