Changeset 6014 for code/branches/console
- Timestamp:
- Nov 2, 2009, 1:57:19 PM (15 years ago)
- Location:
- code/branches/console/src/libraries/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/libraries/core/IOConsole.cc
r6013 r6014 45 45 #ifdef ORXONOX_PLATFORM_UNIX 46 46 #include <termios.h> 47 #include <sys/ioctl.h> 48 #include <sys/stat.h> 47 49 #endif 48 50 … … 74 76 75 77 // 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_; 78 84 } 79 85 … … 192 198 193 199 // Determine terminal width and height 200 this->lastTerminalWidth_ = this->terminalWidth_; 201 this->lastTerminalHeight_ = this->terminalHeight_; 194 202 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 } 195 214 196 215 if (!this->bStatusPrinted_ && this->willPrintStatusLines()) … … 199 218 std::cout << std::string(this->statusLineWidths_.size(), '\n'); 200 219 // Move cursor up again 201 std::cout << "\033[" << this->statusLineWidths_.size() << ' A';220 std::cout << "\033[" << this->statusLineWidths_.size() << 'F'; 202 221 this->bStatusPrinted_ = true; 203 222 } 204 // Move cursor horizontally and erase status and input lines223 // Erase status and input lines 205 224 std::cout << "\033[1G\033[J"; 206 225 this->printInputLine(); … … 393 412 if (this->bStatusPrinted_) 394 413 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'); 397 417 // 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'; 399 419 // Erase screen from here 400 420 std::cout << "\033[J"; 401 421 // 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_)); 403 424 // Move cursor down 404 425 std::cout << "\033[1E"; -
code/branches/console/src/libraries/core/IOConsole.h
r6013 r6014 77 77 unsigned int terminalWidth_; 78 78 unsigned int terminalHeight_; 79 unsigned int lastTerminalWidth_; 80 unsigned int lastTerminalHeight_; 79 81 bool bPrintStatusLine_; 80 82 bool bStatusPrinted_;
Note: See TracChangeset
for help on using the changeset viewer.