Changeset 5969 for code/branches/console/src/libraries/core
- Timestamp:
- Oct 20, 2009, 6:47:40 PM (15 years ago)
- Location:
- code/branches/console/src/libraries/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/libraries/core/Shell.cc
r5929 r5969 35 35 #include "Core.h" 36 36 #include "ConsoleCommand.h" 37 38 #define SHELL_UPDATE_LISTENERS(function) \39 for (std::list<ShellListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ) \40 (*(it++))->function()41 37 42 38 namespace orxonox … … 153 149 void Shell::registerListener(ShellListener* listener) 154 150 { 155 this->listeners_. insert(this->listeners_.end(),listener);151 this->listeners_.push_back(listener); 156 152 } 157 153 … … 161 157 { 162 158 if ((*it) == listener) 163 this->listeners_.erase(it++);159 it = this->listeners_.erase(it); 164 160 else 165 161 ++it; … … 170 166 { 171 167 this->inputBuffer_->setCursorPosition(cursor); 172 SHELL_UPDATE_LISTENERS(cursorChanged);168 this->updateListeners<&ShellListener::cursorChanged>(); 173 169 } 174 170 … … 199 195 this->finishedLastLine_ = true; 200 196 201 SHELL_UPDATE_LISTENERS(linesChanged);197 this->updateListeners<&ShellListener::linesChanged>(); 202 198 } 203 199 … … 258 254 if (!this->scrollPosition_) 259 255 { 260 SHELL_UPDATE_LISTENERS(lineAdded);256 this->updateListeners<&ShellListener::lineAdded>(); 261 257 } 262 258 } … … 265 261 (*this->lines_.begin()) += output; 266 262 this->finishedLastLine_ = newline; 267 SHELL_UPDATE_LISTENERS(onlyLastLineChanged);263 this->updateListeners<&ShellListener::onlyLastLineChanged>(); 268 264 } 269 265 … … 273 269 void Shell::inputChanged() 274 270 { 275 SHELL_UPDATE_LISTENERS(inputChanged);276 SHELL_UPDATE_LISTENERS(cursorChanged);271 this->updateListeners<&ShellListener::inputChanged>(); 272 this->updateListeners<&ShellListener::cursorChanged>(); 277 273 } 278 274 … … 299 295 { 300 296 this->inputBuffer_->removeBehindCursor(); 301 SHELL_UPDATE_LISTENERS(inputChanged);302 SHELL_UPDATE_LISTENERS(cursorChanged);297 this->updateListeners<&ShellListener::inputChanged>(); 298 this->updateListeners<&ShellListener::cursorChanged>(); 303 299 } 304 300 … … 306 302 { 307 303 this->inputBuffer_->removeAtCursor(); 308 SHELL_UPDATE_LISTENERS(inputChanged);304 this->updateListeners<&ShellListener::inputChanged>(); 309 305 } 310 306 … … 313 309 this->inputBuffer_->clear(); 314 310 this->historyPosition_ = 0; 315 SHELL_UPDATE_LISTENERS(inputChanged);316 SHELL_UPDATE_LISTENERS(cursorChanged);311 this->updateListeners<&ShellListener::inputChanged>(); 312 this->updateListeners<&ShellListener::cursorChanged>(); 317 313 } 318 314 … … 320 316 { 321 317 this->inputBuffer_->increaseCursor(); 322 SHELL_UPDATE_LISTENERS(cursorChanged);318 this->updateListeners<&ShellListener::cursorChanged>(); 323 319 } 324 320 … … 326 322 { 327 323 this->inputBuffer_->decreaseCursor(); 328 SHELL_UPDATE_LISTENERS(cursorChanged);324 this->updateListeners<&ShellListener::cursorChanged>(); 329 325 } 330 326 … … 332 328 { 333 329 this->inputBuffer_->setCursorToEnd(); 334 SHELL_UPDATE_LISTENERS(cursorChanged);330 this->updateListeners<&ShellListener::cursorChanged>(); 335 331 } 336 332 … … 338 334 { 339 335 this->inputBuffer_->setCursorToBegin(); 340 SHELL_UPDATE_LISTENERS(cursorChanged);336 this->updateListeners<&ShellListener::cursorChanged>(); 341 337 } 342 338 … … 366 362 ++this->scrollPosition_; 367 363 368 SHELL_UPDATE_LISTENERS(linesChanged);364 this->updateListeners<&ShellListener::linesChanged>(); 369 365 } 370 366 } … … 377 373 --this->scrollPosition_; 378 374 379 SHELL_UPDATE_LISTENERS(linesChanged);375 this->updateListeners<&ShellListener::linesChanged>(); 380 376 } 381 377 } … … 393 389 this->scrollIterator_ = this->lines_.begin(); 394 390 395 SHELL_UPDATE_LISTENERS(exit);391 this->updateListeners<&ShellListener::exit>(); 396 392 } 397 393 } -
code/branches/console/src/libraries/core/Shell.h
r5781 r5969 132 132 void exit(); 133 133 134 template <void (ShellListener::*F)()> 135 void updateListeners() 136 { 137 for (std::list<ShellListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ) 138 ((*(it++))->*F)(); 139 } 140 134 141 std::list<ShellListener*> listeners_; 135 142 InputBuffer* inputBuffer_;
Note: See TracChangeset
for help on using the changeset viewer.