Changeset 1324 for code/branches/console/src/core/Shell.cc
- Timestamp:
- May 19, 2008, 2:58:22 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/Shell.cc
r1322 r1324 80 80 SetConfigValue(maxHistoryLength_, 100); 81 81 SetConfigValue(historyOffset_, 0); 82 SetConfigValueVector(commandHistory_, std::vector<std::string>()); 83 84 std::cout << "gaga1: " << this->commandHistory_[this->historyOffset_] << std::endl; 82 SetConfigValueVector(commandHistory_, std::vector<std::string>(1, "")); 85 83 86 84 if (this->historyOffset_ >= this->maxHistoryLength_) … … 93 91 ModifyConfigValue(commandHistory_, remove, index); 94 92 } 95 96 std::cout << "gaga2: " << this->commandHistory_[this->historyOffset_] << std::endl;97 93 } 98 94 … … 163 159 void Shell::addToHistory(const std::string& command) 164 160 { 165 std::cout << "command: " << command << std::endl;166 std::cout << "offset: " << this->historyOffset_ << std::endl;167 161 ModifyConfigValue(commandHistory_, set, this->historyOffset_, command); 168 // this->commandHistory_[this->historyOffset_] = command;169 162 this->historyPosition_ = 0; 170 std::cout << "gaga3: " << this->commandHistory_[this->historyOffset_] << std::endl;171 163 ModifyConfigValue(historyOffset_, set, (this->historyOffset_ + 1) % this->maxHistoryLength_); 172 std::cout << "offset new: " << this->historyOffset_ << std::endl;173 164 } 174 165 175 166 std::string Shell::getFromHistory() const 176 167 { 177 return this->commandHistory_[(this->historyOffset_ - this->historyPosition_) % this->maxHistoryLength_]; 168 unsigned int index = mod(((int)this->historyOffset_) - ((int)this->historyPosition_), this->maxHistoryLength_); 169 if (index < this->commandHistory_.size() && this->historyPosition_ != 0) 170 return this->commandHistory_[index]; 171 else 172 return ""; 178 173 } 179 174 … … 219 214 void Shell::execute() 220 215 { 221 //this->addToHistory(this->inputBuffer_.get());216 this->addToHistory(this->inputBuffer_.get()); 222 217 this->addLine(this->inputBuffer_.get(), 0); 223 218 … … 252 247 { 253 248 this->inputBuffer_.clear(); 249 this->historyPosition_ = 0; 254 250 SHELL_UPDATE_LISTENERS(inputChanged); 255 251 SHELL_UPDATE_LISTENERS(cursorChanged); … … 282 278 void Shell::history_up() 283 279 { 284 if (this->historyPosition_ < (this->commandHistory_.size() - 1))280 if (this->historyPosition_ < this->commandHistory_.size()) 285 281 { 286 282 this->historyPosition_++;
Note: See TracChangeset
for help on using the changeset viewer.