Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 29, 2009, 2:47:54 PM (15 years ago)
Author:
rgrieder
Message:

Performance and robustness improvements for the IOConsole under Windows.
There should only be one way to screw the console now: Change the console properties manually at runtime (right click on the taskbar icon), esp. screen buffer size.
If you can find another bug, please let me know.

Location:
code/branches/presentation2/src/libraries/core
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/libraries/core/IOConsole.cc

    r6172 r6177  
    3333#include <iostream>
    3434
     35#include "util/Clock.h"
    3536#include "util/Math.h"
    3637#include "core/Game.h"
     
    6162    }
    6263
    63     inline bool IOConsole::willPrintStatusLines()
    64     {
    65         return !this->statusLineWidths_.empty()
    66              && this->terminalWidth_  >= this->statusLineMaxWidth_
    67              && this->terminalHeight_ >= (this->minOutputLines_ + this->statusLineWidths_.size());
    68     }
    69 
    7064    // ###############################
    7165    // ###  ShellListener methods  ###
     
    7872        // or when scrolling. But scrolling is disabled and the output
    7973        // is already in std::cout when we start the IOConsole
    80     }
    81 
    82     //! Called if the text in the input-line has changed
    83     void IOConsole::inputChanged()
    84     {
    85         this->printInputLine();
    86         this->cout_.flush();
    87     }
    88 
    89     //! Called if the position of the cursor in the input-line has changed
    90     void IOConsole::cursorChanged()
    91     {
    92         this->printInputLine();
    93         this->cout_.flush();
    9474    }
    9575
     
    131111        , buffer_(shell_->getInputBuffer())
    132112        , cout_(std::cout.rdbuf())
     113        , promptString_("orxonox # ")
    133114        , bStatusPrinted_(false)
    134         , promptString_("orxonox # ")
    135115        , originalTerminalSettings_(0)
    136116    {
     
    304284    }
    305285
    306     void IOConsole::printLogText(const std::string& text)
     286    void IOConsole::printOutputLine(const std::string& text)
    307287    {
    308288        std::string output = text;
     
    419399    }
    420400
     401    inline bool IOConsole::willPrintStatusLines()
     402    {
     403        return !this->statusLineWidths_.empty()
     404             && this->terminalWidth_  >= this->statusLineMaxWidth_
     405             && this->terminalHeight_ >= (this->minOutputLines_ + this->statusLineWidths_.size());
     406    }
     407
    421408    // ###############################
    422409    // ###  ShellListener methods  ###
     
    431418        this->cout_ << "\033[K";
    432419        // Reprint the last output line
    433         this->printLogText(*(this->shell_->getNewestLineIterator()));
     420        this->printOutputLine(*(this->shell_->getNewestLineIterator()));
    434421        // Restore cursor
    435422        this->cout_ << "\033[u";
     
    449436        // Print the new output lines
    450437        for (int i = 0; i < newLines; ++i)
    451             this->printLogText(this->shell_->getNewestLineIterator()->substr(i*this->terminalWidth_, this->terminalWidth_));
     438            this->printOutputLine(this->shell_->getNewestLineIterator()->substr(i*this->terminalWidth_, this->terminalWidth_));
    452439        // Move cursor down
    453440        this->cout_ << "\033[1B\033[1G";
     
    457444        this->cout_.flush();
    458445    }
     446
     447    //! Called if the text in the input-line has changed
     448    void IOConsole::inputChanged()
     449    {
     450        this->printInputLine();
     451        this->cout_.flush();
     452    }
     453
     454    //! Called if the position of the cursor in the input-line has changed
     455    void IOConsole::cursorChanged()
     456    {
     457        this->printInputLine();
     458        this->cout_.flush();
     459    }
    459460}
    460461
     
    472473        , buffer_(shell_->getInputBuffer())
    473474        , cout_(std::cout.rdbuf())
    474         , bStatusPrinted_(false)
    475475        , promptString_("orxonox # ")
    476     {
    477         this->setTerminalMode();
    478         this->shell_->registerListener(this);
    479 
    480         // Manually set the widths of the individual status lines
    481         this->statusLineWidths_.push_back(29);
    482         this->statusLineMaxWidth_ = 29;
    483 
    484         this->getTerminalSize();
    485         this->lastTerminalWidth_ = this->terminalWidth_;
    486         this->lastTerminalHeight_ = this->terminalHeight_;
    487 
     476        , statusLines_(1)
     477        , inputLineHeight_(1)
     478        , lastOutputLineHeight_(1)
     479    {
    488480        // Disable standard this->cout_ logging
    489481        OutputHandler::getInstance().disableCout();
     
    492484        std::cout.rdbuf(this->origCout_.rdbuf());
    493485
    494         // Make sure we make way for the status lines
     486        this->setTerminalMode();
     487        CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo;
     488        GetConsoleScreenBufferInfo(this->stdOutHandle_, &screenBufferInfo);
     489        this->terminalWidth_  = screenBufferInfo.dwSize.X;
     490        this->terminalHeight_ = screenBufferInfo.dwSize.Y;
     491        this->lastTerminalWidth_  = this->terminalWidth_;
     492        this->lastTerminalHeight_ = this->terminalHeight_;
     493        // Determines where we are in respect to output already written with std::cout
     494        this->inputLineRow_ = screenBufferInfo.dwCursorPosition.Y;
     495
     496        // Cursor already at the end of the screen buffer?
     497        // (assuming the current input line height is 1)
     498        if (this->inputLineRow_ >= (int)this->terminalHeight_ - (int)this->statusLines_)
     499            this->moveCursor(0, -this->inputLineRow_ + this->terminalHeight_ - this->statusLines_ - 1);
     500
     501        // Prevent input line from overflowing
     502        int maxInputLength = (this->terminalHeight_ - this->statusLines_) * this->terminalWidth_ - 1 - this->promptString_.size();
     503        // Consider that the echo of a command might include the command plus some other characters (assumed max 80)
     504        // Also put a minimum so the config file parser is not overwhelmed with the command history
     505        this->shell_->getInputBuffer()->setMaxLength(std::min(8192, (maxInputLength - 80) / 2));
     506
     507        // Print input and status line and position cursor
     508        this->lastRefreshTime_ = Game::getInstance().getGameClock().getRealMicroseconds();
    495509        this->update(Game::getInstance().getGameClock());
     510        this->inputChanged();
     511        this->cursorChanged();
     512
     513        this->shell_->registerListener(this);
    496514    }
    497515
    498516    IOConsole::~IOConsole()
    499517    {
     518        this->shell_->unregisterListener(this);
    500519        // Empty all buffers
    501520        this->update(Game::getInstance().getGameClock());
    502521
    503         resetTerminalMode();
    504         this->shell_->destroy();
     522        // Erase input and status lines
     523        COORD pos = {0, this->inputLineRow_};
     524        this->writeText(std::string((this->inputLineHeight_ + this->statusLines_) * this->terminalWidth_, ' '), pos);
     525        // Move cursor to the beginning of the line
     526        SetConsoleCursorPosition(stdOutHandle_, pos);
    505527
    506528        // Restore this->cout_ redirection
     
    508530        // Enable standard this->cout_ logging again
    509531        OutputHandler::getInstance().enableCout();
     532
     533        resetTerminalMode();
     534        this->shell_->destroy();
    510535    }
    511536
    512537    void IOConsole::update(const Clock& time)
    513538    {
     539        // Process input
    514540        while (true)
    515541        {
     
    539565                {
    540566                case VK_BACK:   this->buffer_->buttonPressed(KeyEvent(KeyCode::Back,     asciiChar, modifiersOut)); break;
    541                 case VK_TAB:    this->buffer_->buttonPressed(KeyEvent(KeyCode::Back,     asciiChar, modifiersOut)); break;
    542                 case VK_RETURN: this->buffer_->buttonPressed(KeyEvent(KeyCode::Back,     asciiChar, modifiersOut)); break;
     567                case VK_TAB:    this->buffer_->buttonPressed(KeyEvent(KeyCode::Tab,      asciiChar, modifiersOut)); break;
     568                case VK_RETURN: this->buffer_->buttonPressed(KeyEvent(KeyCode::Return,   asciiChar, modifiersOut)); break;
    543569                case VK_PAUSE:  this->buffer_->buttonPressed(KeyEvent(KeyCode::Pause,    asciiChar, modifiersOut)); break;
    544570                case VK_ESCAPE: this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape,   asciiChar, modifiersOut)); break;
     
    559585        }
    560586
    561         // Get info about cursor and terminal size
    562         this->getTerminalSize();
    563 
    564         // Refresh status line
    565         this->printStatusLines();
     587        // TODO: Respect screen buffer size changes
     588        // The user can manually adjust the screen buffer size on Windows
     589        // And we don't want to screw the console because of that
     590        //this->lastTerminalWidth_ = this->terminalWidth_;
     591        //this->lastTerminalHeight_ = this->terminalHeight_;
     592        //this->getTerminalSize(); // Also sets this->inputLineRow_ according to the cursor position
     593        // Is there still enough space below the cursor for the status line(s)?
     594        //if (this->inputLineRow_ >= this->terminalHeight_ - this->statusLines_)
     595        //    this->moveCursor(0, -this->inputLineRow_ + this->terminalHeight_ - this->statusLines_ - 1);
     596
     597        // Refresh status line 5 times per second
     598        if (time.getMicroseconds() > this->lastRefreshTime_ + 1000000)
     599        {
     600            this->printStatusLines();
     601            this->lastRefreshTime_ = time.getMicroseconds();
     602        }
    566603
    567604        // Process output written to std::cout
     
    571608            this->origCout_.str("");
    572609        }
    573         this->cout_.flush();
    574     }
    575 
    576     void IOConsole::printLogText(const std::string& text)
     610    }
     611
     612    void IOConsole::printOutputLine(const std::string& text, const COORD& pos)
    577613    {
    578614        std::string output = text;
     
    580616
    581617        // Colour line
     618        WORD colour = 0;
    582619        switch (level)
    583620        {
    584         case  1: SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_RED | FOREGROUND_INTENSITY); break;
    585         case  2: SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY); break;
    586         case  3: SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_INTENSITY); break;
    587         case  4: SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_INTENSITY); break;
    588         default: break;
     621        case  1: colour = FOREGROUND_RED | FOREGROUND_INTENSITY; break;
     622        case  2: colour = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY; break;
     623        case  3: colour = FOREGROUND_INTENSITY; break;
     624        case  4: colour = FOREGROUND_INTENSITY; break;
     625        default: colour = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN; break;
    589626        }
    590627
    591628        // Print output line
    592         this->cout_ << output;
    593 
    594         // Reset colour to white
    595         SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
    596     }
    597 
    598     void IOConsole::printInputLine()
    599     {
    600         SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    601         this->moveCursorYAndHome(0);
    602         this->clearCurrentLine();
    603         this->cout_ << this->promptString_ << this->shell_->getInput();
    604         this->moveCursorYAndHome(0);
    605         this->moveCursor(this->promptString_.size() + this->buffer_->getCursorPosition(), 0);
    606         SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
     629        this->writeText(output, pos, colour);
    607630    }
    608631
    609632    void IOConsole::printStatusLines()
    610633    {
    611         if (this->willPrintStatusLines())
    612         {
    613             SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_GREEN);
    614             this->bStatusPrinted_ = true;
    615             // Put cursor on home position, one line down the input line
    616             this->moveCursorYAndHome(1);
    617             this->cout_ << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, ";
    618             this->cout_ <<               std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms tick time";
    619             // Clear rest of the line
    620             CONSOLE_SCREEN_BUFFER_INFO info;
    621             GetConsoleScreenBufferInfo(this->stdOutHandle_, &info);
    622             this->cout_ << std::string(info.dwSize.X - info.dwCursorPosition.X - 1, ' ');
    623             // Restore cursor position
    624             this->moveCursorYAndHome(-1);
    625             this->moveCursor(this->promptString_.size() + this->buffer_->getCursorPosition(), 0);
    626             SetConsoleTextAttribute(stdOutHandle_, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
    627         }
    628         else
    629             this->bStatusPrinted_ = false;
     634        // Prepare text to be written
     635        std::ostringstream oss;
     636        oss << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, ";
     637        oss <<               std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms tick time";
     638        // Clear rest of the line by inserting spaces
     639        oss << std::string(this->terminalWidth_ - oss.str().size(), ' ');
     640        COORD pos = {0, this->inputLineRow_ + this->inputLineHeight_};
     641        this->writeText(oss.str(), pos, FOREGROUND_GREEN);
    630642    }
    631643
     
    650662    }
    651663
    652     //! Moves the console cursor around and inserts new lines when reaching the end.
    653     //! Moving out on the right is just clamped though.
     664    //! Moves the console cursor around and clamps its position to fit into the screen buffer
    654665    void IOConsole::moveCursor(int dx, int dy)
    655666    {
     
    659670        x = clamp(x + dx, 0, info.dwSize.X - 1);
    660671        SHORT& y = info.dwCursorPosition.Y;
    661         if (y + dy >= info.dwSize.Y)
    662         {
    663             // Insert new lines
    664             this->cout_ << std::string(y + dy - info.dwSize.Y + 1, 'n');
    665             y = info.dwSize.Y - 1;
    666         }
    667         else if (y < 0)
    668             y = 0;
    669         else
    670             y += dy;
     672        y = clamp(y + dy, 0, info.dwSize.Y - 1);
    671673        SetConsoleCursorPosition(this->stdOutHandle_, info.dwCursorPosition);
    672     }
    673 
    674     void IOConsole::moveCursorYAndHome(int dy)
    675     {
    676         CONSOLE_SCREEN_BUFFER_INFO info;
    677         GetConsoleScreenBufferInfo(this->stdOutHandle_, &info);
    678         this->moveCursor(-info.dwCursorPosition.X, dy);
    679     }
    680 
    681     void IOConsole::clearCurrentLine()
    682     {
    683         CONSOLE_SCREEN_BUFFER_INFO info;
    684         GetConsoleScreenBufferInfo(this->stdOutHandle_, &info);
    685         info.dwCursorPosition.X = 0;
    686         DWORD count;
    687         FillConsoleOutputCharacter(this->stdOutHandle_, ' ', info.dwSize.X, info.dwCursorPosition, &count);;
    688674    }
    689675
     
    692678        CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo;
    693679        GetConsoleScreenBufferInfo(this->stdOutHandle_, &screenBufferInfo);
    694         // dwSize is the maximum size. If you resize you will simply see scroll bars.
    695         // And if you want to write outside these boundaries, you can't.
    696680        this->terminalWidth_  = screenBufferInfo.dwSize.X;
    697681        this->terminalHeight_ = screenBufferInfo.dwSize.Y;
     682    }
     683
     684    void IOConsole::writeText(const std::string& text, const COORD& coord, WORD attributes)
     685    {
     686        DWORD count;
     687        WriteConsoleOutputCharacter(stdOutHandle_, text.c_str(), text.size(), coord, &count);
     688        WORD* attributeBuf = new WORD[text.size()];
     689        for (unsigned int i = 0; i < text.size(); ++i)
     690            attributeBuf[i] = attributes;
     691        WriteConsoleOutputAttribute(stdOutHandle_, attributeBuf, text.size(), coord, &count);
     692    }
     693
     694    void IOConsole::createNewOutputLines(unsigned int lines)
     695    {
     696        CHAR_INFO fillChar = {' ', FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED};
     697        // Check whether we're already at the bottom
     698        if (this->inputLineRow_ + lines > this->terminalHeight_ - this->statusLines_ - this->inputLineHeight_)
     699        {
     700            // Scroll output up
     701            SMALL_RECT oldRect = {0, lines, this->terminalWidth_ - 1, this->inputLineRow_ - 1};
     702            COORD newPos = {0, 0};
     703            ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, newPos, &fillChar);
     704        }
     705        else
     706        {
     707            // Scroll input and status lines down
     708            SMALL_RECT oldRect = {0, this->inputLineRow_, this->terminalWidth_ - 1, this->inputLineRow_ + this->statusLines_ + this->inputLineHeight_ - 1};
     709            this->inputLineRow_ += lines;
     710            COORD newPos = {0, this->inputLineRow_};
     711            ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, newPos, &fillChar);
     712            // Move cursor down to the new bottom so the user can see the status lines
     713            COORD pos = {0, this->inputLineRow_ + this->inputLineHeight_ - 1 + this->statusLines_};
     714            SetConsoleCursorPosition(stdOutHandle_, pos);
     715            // Get cursor back to the right position
     716            this->cursorChanged();
     717        }
    698718    }
    699719
     
    702722    // ###############################
    703723
     724    //! Called if the text in the input-line has changed
     725    void IOConsole::inputChanged()
     726    {
     727        int inputLineLength = this->promptString_.size() + this->shell_->getInput().size();
     728        int lineHeight = 1 + inputLineLength / this->terminalWidth_;
     729        int newLines = lineHeight - this->inputLineHeight_;
     730        if (newLines > 0)
     731        {
     732            // Abuse this function to scroll the console
     733            this->createNewOutputLines(newLines);
     734            this->inputLineRow_ -= newLines; // Undo
     735        }
     736        else if (newLines < 0)
     737        {
     738            // Scroll status lines up
     739            SMALL_RECT oldRect = {0, this->inputLineRow_ + this->inputLineHeight_, this->terminalWidth_ - 1, this->inputLineRow_ + this->inputLineHeight_ + this->statusLines_};
     740            COORD newPos = {0, this->inputLineRow_ + this->inputLineHeight_ + newLines};
     741            CHAR_INFO fillChar = {' ', FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED};
     742            ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, newPos, &fillChar);
     743            // Clear potential leftovers
     744            if (-newLines - this->statusLines_ > 0)
     745            {
     746                COORD pos = {0, this->inputLineRow_ + lineHeight + this->statusLines_};
     747                this->writeText(std::string((-newLines - this->statusLines_) * this->terminalWidth_, ' '), pos);
     748            }
     749        }
     750        this->inputLineHeight_ = lineHeight;
     751
     752        // Print the whole line, including spaces to erase leftovers
     753        COORD pos = {0, this->inputLineRow_};
     754        WORD colour = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
     755        this->writeText(this->promptString_ + this->shell_->getInput() + std::string(this->terminalWidth_ - inputLineLength % this->terminalWidth_, ' '), pos, colour);
     756        // If necessary, move cursor
     757        if (newLines != 0)
     758            this->cursorChanged();
     759    }
     760
     761    //! Called if the position of the cursor in the input-line has changed
     762    void IOConsole::cursorChanged()
     763    {
     764        COORD pos;
     765        unsigned int total = this->promptString_.size() + this->buffer_->getCursorPosition();
     766        // Compensate for cursor further to the right than the terminal width
     767        pos.X = total % this->terminalWidth_;
     768        pos.Y = this->inputLineRow_ + total / this->terminalWidth_;
     769        SetConsoleCursorPosition(stdOutHandle_, pos);
     770    }
     771
    704772    //! Called if only the last output-line has changed
    705773    void IOConsole::onlyLastLineChanged()
    706774    {
    707         this->moveCursorYAndHome(-1);
    708         this->clearCurrentLine();
    709         this->printLogText(*(this->shell_->getNewestLineIterator()));
    710         this->moveCursorYAndHome(1);
    711         this->moveCursor(this->promptString_.size() + this->shell_->getInput().size(), 0);
    712         this->cout_.flush();
     775        int lineHeight = 1 + this->shell_->getNewestLineIterator()->size() / this->terminalWidth_;
     776        int newLines = lineHeight - this->lastOutputLineHeight_;
     777        this->lastOutputLineHeight_ = lineHeight;
     778        if (newLines > 0)
     779            this->createNewOutputLines(newLines);
     780        // Write text (assuming it is longer than the previous text)
     781        assert(newLines >= 0);
     782        COORD pos = {0, this->inputLineRow_ - lineHeight};
     783        this->printOutputLine(*(this->shell_->getNewestLineIterator()), pos);
    713784    }
    714785
     
    716787    void IOConsole::lineAdded()
    717788    {
    718         // Move cursor to the beginning of the new (last) output line
    719         this->moveCursorYAndHome(0);
    720         // Print the new output lines
    721         this->printLogText(*(this->shell_->getNewestLineIterator()));
    722         // Move cursor down
    723         this->moveCursorYAndHome(1);
    724         // Print status and input lines
    725         this->printInputLine();
    726         this->printStatusLines();
    727         this->cout_.flush();
     789        this->lastOutputLineHeight_ = 1 + this->shell_->getNewestLineIterator()->size() / this->terminalWidth_;
     790        if (this->lastOutputLineHeight_ > 0)
     791            this->createNewOutputLines(this->lastOutputLineHeight_);
     792        // Write the text
     793        COORD pos = {0, this->inputLineRow_ - this->lastOutputLineHeight_};
     794        this->printOutputLine(*(this->shell_->getNewestLineIterator()), pos);
    728795    }
    729796}
  • code/branches/presentation2/src/libraries/core/IOConsole.h

    r6172 r6177  
    4343#elif defined(ORXONOX_PLATFORM_WINDOWS)
    4444#define WIN32_LEAN_AND_MEAN
     45#define NOMINMAX
    4546#include <windows.h>
    4647#endif
     
    6061    private:
    6162        void setTerminalMode();
    62         static void resetTerminalMode();
    6363        void getTerminalSize();
    64         bool willPrintStatusLines();
    6564        int extractLogLevel(std::string* text);
    6665
    67         void printLogText(const std::string& line);
    68         void printInputLine();
    6966        void printStatusLines();
    7067
     
    8582        unsigned int            lastTerminalWidth_;
    8683        unsigned int            lastTerminalHeight_;
     84        const std::string       promptString_;
     85
     86#ifdef ORXONOX_PLATFORM_UNIX
     87        bool willPrintStatusLines();
     88        void printOutputLine(const std::string& line);
     89        void printInputLine();
     90        static void resetTerminalMode();
     91
    8792        bool                    bPrintStatusLine_;
    8893        bool                    bStatusPrinted_;
    8994        std::vector<unsigned>   statusLineWidths_;
    9095        unsigned int            statusLineMaxWidth_;
    91         const std::string       promptString_;
    9296        static const unsigned   minOutputLines_ = 3;
     97        termios*                originalTerminalSettings_;
    9398
    94 #ifdef ORXONOX_PLATFORM_UNIX
    95         termios*         originalTerminalSettings_;
    9699#elif defined(ORXONOX_PLATFORM_WINDOWS)
     100        void resetTerminalMode();
    97101        void moveCursor(int dx, int dy);
    98         void moveCursorYAndHome(int dy);
    99         void clearCurrentLine();
     102        void writeText(const std::string& text, const COORD& pos, WORD attributes = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
     103        void createNewOutputLines(unsigned int lines);
     104        void printOutputLine(const std::string& line, const COORD& pos);
    100105
    101106        DWORD                   originalTerminalSettings_;
    102107        HANDLE                  stdInHandle_;
    103108        HANDLE                  stdOutHandle_;
     109        int                     inputLineRow_;
     110        unsigned int            inputLineHeight_;
     111        const unsigned int      statusLines_;
     112        unsigned int            lastOutputLineHeight_;
     113        uint64_t                lastRefreshTime_;
    104114#endif
    105115
  • code/branches/presentation2/src/libraries/core/input/InputBuffer.cc

    r6105 r6177  
    4141        this->buffer_ = "";
    4242        this->cursor_ = 0;
     43        this->maxLength_ = 1024;
    4344        this->allowedChars_ = "abcdefghijklmnopqrstuvwxyz \
    4445                               ABCDEFGHIJKLMNOPQRSTUVWXYZ \
     
    5960        RegisterRootObject(InputBuffer);
    6061
     62        this->maxLength_ = 1024;
    6163        this->allowedChars_ = allowedChars;
    6264        this->buffer_ = "";
     
    9395    }
    9496
     97    void InputBuffer::setMaxLength(unsigned int length)
     98    {
     99        this->maxLength_ = length;
     100        if (this->buffer_.size() > length)
     101            this->buffer_.resize(length);
     102    }
     103
    95104    void InputBuffer::set(const std::string& input, bool update)
    96105    {
     
    117126        if (this->charIsAllowed(input))
    118127        {
     128            if (this->buffer_.size() >= this->maxLength_)
     129                return;
    119130            this->buffer_.insert(this->cursor_, 1, input);
    120131            ++this->cursor_;
  • code/branches/presentation2/src/libraries/core/input/InputBuffer.h

    r6105 r6177  
    8282
    8383            void setConfigValues();
     84
     85            unsigned int getMaxLength() const { return this->maxLength_; }
     86            void setMaxLength(unsigned int length);
    8487
    8588            template <class T>
     
    175178            std::list<BaseInputBufferListenerTuple*> listeners_;
    176179            std::string allowedChars_;
     180            unsigned int maxLength_;
    177181            unsigned int cursor_;
    178182
Note: See TracChangeset for help on using the changeset viewer.