Index: code/branches/console/src/libraries/core/IOConsole.cc
===================================================================
--- code/branches/console/src/libraries/core/IOConsole.cc	(revision 6102)
+++ code/branches/console/src/libraries/core/IOConsole.cc	(revision 6103)
@@ -158,8 +158,6 @@
         // Empty all buffers
         this->update(Game::getInstance().getGameClock());
-        // Goto last line and create a new one
-        if (this->bStatusPrinted_)
-            this->cout_ << "\033[" << this->statusLineWidths_.size() << 'E';
-        this->cout_ << std::endl;
+        // Erase input and status lines
+        this->cout_ << "\033[1G\033[J";
 
         resetTerminalMode();
@@ -175,5 +173,5 @@
     void IOConsole::update(const Clock& time)
     {
-        unsigned char c = 0;
+        unsigned char c;
         std::string escapeSequence;
         EscapeMode::Value escapeMode = EscapeMode::None;
@@ -260,11 +258,4 @@
             this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape, '\033', 0));
 
-        // Process output written to std::cout
-        if (!this->origCout_.str().empty())
-        {
-            this->shell_->addOutputLine(this->origCout_.str());
-            this->origCout_.str("");
-        }
-
         // Determine terminal width and height
         this->lastTerminalWidth_ = this->terminalWidth_;
@@ -279,5 +270,5 @@
             int newLines = std::min((int)this->statusLineWidths_.size(), -heightDiff);
             // Scroll terminal to create new lines
-            this->cout_ << "\033[" << newLines << "S";
+            this->cout_ << "\033[" << newLines << 'S';
         }
 
@@ -285,7 +276,13 @@
         {
             // Scroll console to make way for status lines
-            this->cout_ << "\033[" << this->statusLineWidths_.size() << "S";
+            this->cout_ << "\033[" << this->statusLineWidths_.size() << 'S';
             this->bStatusPrinted_ = true;
         }
+
+        // We always assume that the cursor is on the inputline.
+        // But we cannot always be sure about that, esp. if we scroll the console
+        this->cout_ << "\033[" << this->statusLineWidths_.size() << 'B';
+        this->cout_ << "\033[" << this->statusLineWidths_.size() << 'A';
+
         // Erase status and input lines
         this->cout_ << "\033[1G\033[J";
@@ -293,4 +290,11 @@
         this->printStatusLines();
         this->cout_.flush();
+
+        // Process output written to std::cout
+        if (!this->origCout_.str().empty())
+        {
+            this->shell_->addOutputLine(this->origCout_.str());
+            this->origCout_.str("");
+        }
     }
 
@@ -298,5 +302,5 @@
     {
         std::string output = text;
-        int level = this->extractLogLevel(&output);
+        /*int level =*/ this->extractLogLevel(&output);
 
 /*
@@ -348,5 +352,4 @@
             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";
-//            this->cout_ << "Terminal width: " << this->terminalWidth_ << ", height: " << this->terminalHeight_;
             // Restore cursor position
             this->cout_ << "\033[u";
@@ -425,15 +428,12 @@
     void IOConsole::lineAdded()
     {
-        // Move cursor to the bottom line
-        if (this->bStatusPrinted_)
-            this->cout_ << "\033[" << this->statusLineWidths_.size() << "B\033[1G";
-        // Create new lines on the screen
         int newLines = this->shell_->getNewestLineIterator()->size() / this->terminalWidth_ + 1;
-        this->cout_ << std::string(newLines, '\n');
+        // Create new lines by scrolling the screen
+        this->cout_ << "\033[" << newLines << 'S';
         // Move cursor to the beginning of the new (last) output line
-        this->cout_ << "\033[" << (newLines + this->statusLineWidths_.size()) << "A\033[1G";
+        this->cout_ << "\033[" << newLines << "A\033[1G";
         // Erase screen from here
         this->cout_ << "\033[J";
-        // Print the new output line
+        // Print the new output lines
         for (int i = 0; i < newLines; ++i)
             this->printLogText(this->shell_->getNewestLineIterator()->substr(i*this->terminalWidth_, this->terminalWidth_));
