Changeset 6004 for code/branches/console/src/libraries/core/Shell.cc
- Timestamp:
- Oct 30, 2009, 12:39:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/libraries/core/Shell.cc
r5994 r6004 34 34 #include "CoreIncludes.h" 35 35 #include "ConfigValueIncludes.h" 36 #include "Core.h"37 36 #include "ConsoleCommand.h" 38 37 39 38 namespace orxonox 40 39 { 41 SetConsoleCommand(Shell, clearShell, true);42 SetConsoleCommand(Shell, history, true);43 44 40 SetConsoleCommandShortcut(OutputHandler, log); 45 41 SetConsoleCommandShortcut(OutputHandler, error); … … 48 44 SetConsoleCommandShortcut(OutputHandler, debug); 49 45 50 Shell* Shell::singletonPtr_s = 0; 51 52 Shell::Shell() 53 : OutputListener("shell") 46 Shell::Shell(const std::string& consoleName, bool bScrollable) 47 : inputBuffer_(new InputBuffer()) 48 , OutputListener(consoleName) 49 , consoleName_(consoleName) 50 , bScrollable_(bScrollable) 54 51 { 55 52 RegisterRootObject(Shell); … … 63 60 64 61 this->clearLines(); 65 66 this->inputBuffer_ = new InputBuffer();67 62 this->configureInputBuffer(); 68 63 … … 79 74 for (OutputHandler::OutputVectorIterator it = OutputHandler::getInstance().getOutputVectorBegin(); 80 75 it != OutputHandler::getInstance().getOutputVectorEnd(); ++it) 81 this->addLine(it->second, it->first); 76 { 77 if (it->first <= this->getSoftDebugLevel()) 78 { 79 this->outputBuffer_ << it->second; 80 this->outputChanged(it->first); 81 } 82 } 82 83 83 84 // Register the shell as output listener … … 93 94 void Shell::setConfigValues() 94 95 { 95 SetConfigValue Generic(commandHistoryConfigFileType_, maxHistoryLength_, "maxHistoryLength_", "Shell", 100)96 SetConfigValue(maxHistoryLength_, 100) 96 97 .callback(this, &Shell::commandHistoryLengthChanged); 97 SetConfigValue Generic(commandHistoryConfigFileType_, historyOffset_, "historyOffset_", "Shell", 0)98 SetConfigValue(historyOffset_, 0) 98 99 .callback(this, &Shell::commandHistoryOffsetChanged); 99 100 SetConfigValueVectorGeneric(commandHistoryConfigFileType_, commandHistory_, std::vector<std::string>()); … … 104 105 const unsigned int defaultLevel = 3; 105 106 #endif 106 SetConfigValueGeneric(ConfigFileType::Settings, softDebugLevel_, "softDebugLevel Shell", "OutputHandler", defaultLevel)107 SetConfigValueGeneric(ConfigFileType::Settings, softDebugLevel_, "softDebugLevel" + this->consoleName_, "OutputHandler", defaultLevel) 107 108 .description("The maximal level of debug output shown in the Shell"); 108 OutputHandler::getInstance().setSoftDebugLevel("shell",this->softDebugLevel_);109 this->setSoftDebugLevel(this->softDebugLevel_); 109 110 } 110 111 … … 149 150 } 150 151 151 void Shell::clearShell() 152 { 153 Shell::getInstance().clearLines(); 154 } 155 152 /* 156 153 void Shell::history() 157 154 { … … 163 160 instance.addLine(instance.commandHistory_[i], -1); 164 161 } 162 */ 165 163 166 164 void Shell::registerListener(ShellListener* listener) … … 195 193 { 196 194 if (level <= this->softDebugLevel_) 197 this-> lines_.push_front(line);195 this->outputLines_.push_front(line); 198 196 this->updateListeners<&ShellListener::lineAdded>(); 199 197 } … … 201 199 void Shell::clearLines() 202 200 { 203 this-> lines_.clear();204 this->scrollIterator_ = this-> lines_.begin();201 this->outputLines_.clear(); 202 this->scrollIterator_ = this->outputLines_.begin(); 205 203 206 204 this->scrollPosition_ = 0; … … 215 213 return this->scrollIterator_; 216 214 else 217 return this-> lines_.begin();215 return this->outputLines_.begin(); 218 216 } 219 217 220 218 std::list<std::string>::const_iterator Shell::getEndIterator() const 221 219 { 222 return this-> lines_.end();220 return this->outputLines_.end(); 223 221 } 224 222 … … 239 237 } 240 238 241 void Shell::outputChanged() 242 { 243 std::string output; 244 bool newline; 239 void Shell::outputChanged(int level) 240 { 241 bool newline = false; 245 242 do 246 243 { 244 std::string output; 247 245 std::getline(this->outputBuffer_, output); 248 246 … … 261 259 { 262 260 if (this->bAddOutputLevel_) 263 output.insert(0, 1, static_cast<char>( OutputHandler::getInstance().getOutputLevel()));264 265 this-> lines_.push_front(output);261 output.insert(0, 1, static_cast<char>(level)); 262 263 this->outputLines_.push_front(output); 266 264 267 265 if (this->scrollPosition_) 268 266 this->scrollPosition_++; 269 267 else 270 this->scrollIterator_ = this-> lines_.begin();268 this->scrollIterator_ = this->outputLines_.begin(); 271 269 272 270 this->finishedLastLine_ = newline; … … 279 277 else 280 278 { 281 (*this-> lines_.begin()) += output;279 (*this->outputLines_.begin()) += output; 282 280 this->finishedLastLine_ = newline; 283 281 this->updateListeners<&ShellListener::onlyLastLineChanged>(); … … 413 411 void Shell::scroll_up() 414 412 { 415 if (this->scrollIterator_ != this-> lines_.end())413 if (this->scrollIterator_ != this->outputLines_.end()) 416 414 { 417 415 ++this->scrollIterator_; … … 424 422 void Shell::scroll_down() 425 423 { 426 if (this->scrollIterator_ != this-> lines_.begin())424 if (this->scrollIterator_ != this->outputLines_.begin()) 427 425 { 428 426 --this->scrollIterator_; … … 443 441 this->clear(); 444 442 this->scrollPosition_ = 0; 445 this->scrollIterator_ = this-> lines_.begin();443 this->scrollIterator_ = this->outputLines_.begin(); 446 444 447 445 this->updateListeners<&ShellListener::exit>();
Note: See TracChangeset
for help on using the changeset viewer.