Changeset 6103
- Timestamp:
- Nov 20, 2009, 4:05:32 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/libraries/core/IOConsole.cc
r6089 r6103 158 158 // Empty all buffers 159 159 this->update(Game::getInstance().getGameClock()); 160 // Goto last line and create a new one 161 if (this->bStatusPrinted_) 162 this->cout_ << "\033[" << this->statusLineWidths_.size() << 'E'; 163 this->cout_ << std::endl; 160 // Erase input and status lines 161 this->cout_ << "\033[1G\033[J"; 164 162 165 163 resetTerminalMode(); … … 175 173 void IOConsole::update(const Clock& time) 176 174 { 177 unsigned char c = 0;175 unsigned char c; 178 176 std::string escapeSequence; 179 177 EscapeMode::Value escapeMode = EscapeMode::None; … … 260 258 this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape, '\033', 0)); 261 259 262 // Process output written to std::cout263 if (!this->origCout_.str().empty())264 {265 this->shell_->addOutputLine(this->origCout_.str());266 this->origCout_.str("");267 }268 269 260 // Determine terminal width and height 270 261 this->lastTerminalWidth_ = this->terminalWidth_; … … 279 270 int newLines = std::min((int)this->statusLineWidths_.size(), -heightDiff); 280 271 // Scroll terminal to create new lines 281 this->cout_ << "\033[" << newLines << "S";272 this->cout_ << "\033[" << newLines << 'S'; 282 273 } 283 274 … … 285 276 { 286 277 // Scroll console to make way for status lines 287 this->cout_ << "\033[" << this->statusLineWidths_.size() << "S";278 this->cout_ << "\033[" << this->statusLineWidths_.size() << 'S'; 288 279 this->bStatusPrinted_ = true; 289 280 } 281 282 // We always assume that the cursor is on the inputline. 283 // But we cannot always be sure about that, esp. if we scroll the console 284 this->cout_ << "\033[" << this->statusLineWidths_.size() << 'B'; 285 this->cout_ << "\033[" << this->statusLineWidths_.size() << 'A'; 286 290 287 // Erase status and input lines 291 288 this->cout_ << "\033[1G\033[J"; … … 293 290 this->printStatusLines(); 294 291 this->cout_.flush(); 292 293 // Process output written to std::cout 294 if (!this->origCout_.str().empty()) 295 { 296 this->shell_->addOutputLine(this->origCout_.str()); 297 this->origCout_.str(""); 298 } 295 299 } 296 300 … … 298 302 { 299 303 std::string output = text; 300 int level =this->extractLogLevel(&output);304 /*int level =*/ this->extractLogLevel(&output); 301 305 302 306 /* … … 348 352 this->cout_ << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, "; 349 353 this->cout_ << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms tick time"; 350 // this->cout_ << "Terminal width: " << this->terminalWidth_ << ", height: " << this->terminalHeight_;351 354 // Restore cursor position 352 355 this->cout_ << "\033[u"; … … 425 428 void IOConsole::lineAdded() 426 429 { 427 // Move cursor to the bottom line428 if (this->bStatusPrinted_)429 this->cout_ << "\033[" << this->statusLineWidths_.size() << "B\033[1G";430 // Create new lines on the screen431 430 int newLines = this->shell_->getNewestLineIterator()->size() / this->terminalWidth_ + 1; 432 this->cout_ << std::string(newLines, '\n'); 431 // Create new lines by scrolling the screen 432 this->cout_ << "\033[" << newLines << 'S'; 433 433 // Move cursor to the beginning of the new (last) output line 434 this->cout_ << "\033[" << (newLines + this->statusLineWidths_.size())<< "A\033[1G";434 this->cout_ << "\033[" << newLines << "A\033[1G"; 435 435 // Erase screen from here 436 436 this->cout_ << "\033[J"; 437 // Print the new output line 437 // Print the new output lines 438 438 for (int i = 0; i < newLines; ++i) 439 439 this->printLogText(this->shell_->getNewestLineIterator()->substr(i*this->terminalWidth_, this->terminalWidth_));
Note: See TracChangeset
for help on using the changeset viewer.