Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6014 for code/branches/console


Ignore:
Timestamp:
Nov 2, 2009, 1:57:19 PM (15 years ago)
Author:
rgrieder
Message:

IOConsole: More line wrapping fixes

Location:
code/branches/console/src/libraries/core
Files:
2 edited

Legend:

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

    r6013 r6014  
    4545#ifdef ORXONOX_PLATFORM_UNIX
    4646#include <termios.h>
     47#include <sys/ioctl.h>
     48#include <sys/stat.h>
    4749#endif
    4850
     
    7476
    7577        // Manually set the widths of the individual status lines
    76         this->statusLineWidths_.push_back(20);
    77         this->statusLineMaxWidth_ = 20;
     78        this->statusLineWidths_.push_back(29);
     79        this->statusLineMaxWidth_ = 29;
     80
     81        this->getTerminalSize();
     82        this->lastTerminalWidth_ = this->terminalWidth_;
     83        this->lastTerminalHeight_ = this->terminalHeight_;
    7884    }
    7985
     
    192198
    193199        // Determine terminal width and height
     200        this->lastTerminalWidth_ = this->terminalWidth_;
     201        this->lastTerminalHeight_ = this->terminalHeight_;
    194202        this->getTerminalSize();
     203
     204        int heightDiff = this->terminalHeight_ - this->lastTerminalHeight_;
     205        if (this->bStatusPrinted_ && heightDiff < 0)
     206        {
     207            // Terminal width has shrinked. The cursor will still be on the input line,
     208            // but that line might very well be the last
     209            int newLines = std::min((int)this->statusLineWidths_.size(), -heightDiff);
     210            std::cout << std::string(newLines, '\n');
     211            // Move cursor up again
     212            std::cout << "\033[" << newLines << 'F';
     213        }
    195214
    196215        if (!this->bStatusPrinted_ && this->willPrintStatusLines())
     
    199218            std::cout << std::string(this->statusLineWidths_.size(), '\n');
    200219            // Move cursor up again
    201             std::cout << "\033[" << this->statusLineWidths_.size() << 'A';
     220            std::cout << "\033[" << this->statusLineWidths_.size() << 'F';
    202221            this->bStatusPrinted_ = true;
    203222        }
    204         // Move cursor horizontally and erase status and input lines
     223        // Erase status and input lines
    205224        std::cout << "\033[1G\033[J";
    206225        this->printInputLine();
     
    393412        if (this->bStatusPrinted_)
    394413            std::cout << "\033[" << this->statusLineWidths_.size() << 'E';
    395         // Create the new line on the screen
    396         std::cout << '\n';
     414        // Create new lines on the screen
     415        int newLines = this->shell_->getNewestLineIterator()->size() / this->terminalWidth_ + 1;
     416        std::cout << std::string(newLines, '\n');
    397417        // Move cursor to the beginning of the new (last) output line
    398         std::cout << "\033[" << (1 + this->statusLineWidths_.size()) << 'F';
     418        std::cout << "\033[" << (newLines + this->statusLineWidths_.size()) << 'F';
    399419        // Erase screen from here
    400420        std::cout << "\033[J";
    401421        // Print the new output line
    402         this->printLogText(*(this->shell_->getNewestLineIterator()));
     422        for (int i = 0; i < newLines; ++i)
     423            this->printLogText(this->shell_->getNewestLineIterator()->substr(i*this->terminalWidth_, this->terminalWidth_));
    403424        // Move cursor down
    404425        std::cout << "\033[1E";
  • code/branches/console/src/libraries/core/IOConsole.h

    r6013 r6014  
    7777        unsigned int            terminalWidth_;
    7878        unsigned int            terminalHeight_;
     79        unsigned int            lastTerminalWidth_;
     80        unsigned int            lastTerminalHeight_;
    7981        bool                    bPrintStatusLine_;
    8082        bool                    bStatusPrinted_;
Note: See TracChangeset for help on using the changeset viewer.