Changeset 5973 for code/branches/console
- Timestamp:
- Oct 20, 2009, 10:32:06 PM (15 years ago)
- Location:
- code/branches/console/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/CMakeLists.txt
r5781 r5973 98 98 ADD_SUBDIRECTORY(libraries) 99 99 ADD_SUBDIRECTORY(orxonox) 100 ADD_SUBDIRECTORY(modules)100 #ADD_SUBDIRECTORY(modules) 101 101 102 102 ################ Executable ################ -
code/branches/console/src/libraries/core/Core.cc
r5929 r5973 64 64 #include "Identifier.h" 65 65 #include "Language.h" 66 #include "IOConsole.h" 66 67 #include "LuaState.h" 67 68 #include "ScopedSingletonManager.h" … … 265 266 // create a shell 266 267 this->shell_.reset(new Shell()); 268 // create persistent io console 269 this->ioConsole_.reset(new IOConsole()); 267 270 268 271 // Create singletons that always exist (in other libraries) … … 444 447 ScopedSingletonManager::update<ScopeID::Graphics>(time); 445 448 } 449 // process console text 450 this->ioConsole_->update(time); 446 451 // process thread commands 447 452 this->tclThreadManager_->update(time); -
code/branches/console/src/libraries/core/Core.h
r5929 r5973 43 43 { 44 44 class CoreConfiguration; 45 class IOConsole; 45 46 46 47 /** … … 97 98 scoped_ptr<TclThreadManager> tclThreadManager_; 98 99 scoped_ptr<Shell> shell_; 100 scoped_ptr<IOConsole> ioConsole_; 99 101 // graphical 100 102 scoped_ptr<GraphicsManager> graphicsManager_; //!< Interface to OGRE -
code/branches/console/src/libraries/core/IOConsole.cc
r5972 r5973 57 57 IOConsole::IOConsole() 58 58 : shell_(Shell::getInstance()) 59 , cleanLine_(true)60 59 , bEscapeMode_(false) 61 60 , buffer_(Shell::getInstance().getInputBuffer()) 62 , inputIterator_(0)63 , cursorX_(0)64 , cursorY_(0)65 61 { 66 62 this->originalTerminalSettings_ = new termios; … … 81 77 termios new_settings; 82 78 83 tcgetattr(0, this->originalTerminalSettings_);79 tcgetattr(0, this->originalTerminalSettings_); 84 80 new_settings = *this->originalTerminalSettings_; 85 new_settings.c_lflag &= ~( ICANON | ECHO);81 new_settings.c_lflag &= ~(ICANON | ECHO); 86 82 // new_settings.c_lflag |= ( ISIG | IEXTEN ); 87 83 new_settings.c_cc[VTIME] = 1; 88 new_settings.c_cc[VMIN] = 0;89 tcsetattr(0, TCSANOW,&new_settings);84 new_settings.c_cc[VMIN] = 0; 85 tcsetattr(0, TCSANOW, &new_settings); 90 86 COUT(0) << endl; 91 87 // atexit(&IOConsole::resetTerminalMode); … … 99 95 void IOConsole::update(const Clock& time) 100 96 { 101 unsigned c ;97 unsigned char c; 102 98 while (read(STDIN_FILENO, &c, 1) == 1) 103 99 { … … 105 101 { 106 102 this->escapeSequence_ += c; 107 bool clear = true; 108 if (this->escapeSequence_ == "\033") 109 this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape, 0, 0)); 110 else if (this->escapeSequence_ == "[A") 103 bool endOfSeq = true; 104 if (this->escapeSequence_ == "[A") 111 105 this->buffer_->buttonPressed(KeyEvent(KeyCode::Up, 0, 0)); 112 106 else if (this->escapeSequence_ == "[B") … … 120 114 else if (this->escapeSequence_ == "[2~") 121 115 this->buffer_->buttonPressed(KeyEvent(KeyCode::Insert, 0, 0)); 116 else if (this->escapeSequence_ == "[3~") 117 this->buffer_->buttonPressed(KeyEvent(KeyCode::Delete, 0, 0)); 122 118 else if (this->escapeSequence_ == "[4~") 123 119 this->buffer_->buttonPressed(KeyEvent(KeyCode::End, 0, 0)); … … 130 126 this->buffer_->buttonPressed(KeyEvent(KeyCode::Tab, '\t', KeyboardModifier::Alt)); 131 127 else if (this->escapeSequence_.size() > 4) 132 clear= true; // Something went wrong, start over128 endOfSeq = true; // Something went wrong, start over 133 129 else 134 clear = false; 135 136 if (clear) 137 this->escapeSequence_.clear(); 130 endOfSeq = false; 131 132 //this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape, 0, 0)); 133 134 if (endOfSeq) 135 this->bEscapeMode_ = false; 138 136 } 139 137 else // not in an escape sequence 140 138 { 141 139 if (c == '\033') 140 { 142 141 this->bEscapeMode_ = true; 142 this->escapeSequence_.clear(); 143 } 143 144 else 144 145 { … … 147 148 { 148 149 case '\n': code = KeyCode::Return; break; 149 case 127: code = KeyCode::Delete; break; 150 case '\r': code = KeyCode::Return; break; 151 case 127: code = KeyCode::Back; break; 150 152 case '\b': code = KeyCode::Back; break; 151 153 case '\t': code = KeyCode::Tab; break; … … 160 162 } 161 163 } 164 165 // Print input line 166 this->printInputLine(); 162 167 } 163 168 164 169 void IOConsole::printOutputLine(const std::string& line) 165 170 { 171 COUT(0) << "print output" << std::endl; 166 172 // Save cursor position 167 173 std::cout << "\033[s"; … … 199 205 std::cout << "\033[u"; 200 206 std::cout.flush(); 207 208 this->printInputLine(); 201 209 } 202 210 … … 206 214 std::cout << "\033[0G\033[K"; 207 215 // print status line 208 std::cout << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, " << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms avg ticktime # "; 216 //std::cout << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, " << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms avg ticktime # "; 217 // Show an arrow to indicate a command prompt 218 std::cout << ">"; 209 219 // save cursor position 210 220 std::cout << "\033[s"; 211 221 // print commandLine buffer 212 222 std::cout << this->shell_.getInput(); 213 // restore cursor position and move it cursorX_to the right223 // restore cursor position and move it to the right 214 224 std::cout << "\033[u"; 215 225 if (this->buffer_->getCursorPosition() > 0) -
code/branches/console/src/libraries/core/IOConsole.h
r5971 r5973 58 58 void printOutputLine(const std::string& line); 59 59 void printInputLine(); 60 void insertCharacter(unsigned int position, char c);61 void deleteCharacter(unsigned int position);62 60 63 61 // Methods from ShellListener … … 70 68 71 69 Shell& shell_; 72 bool cleanLine_;73 70 bool bEscapeMode_; 74 71 std::string escapeSequence_; 75 72 InputBuffer* buffer_; 76 unsigned char* commandLine_;77 unsigned int inputIterator_;78 73 static termios* originalTerminalSettings_; 79 80 unsigned int cursorX_;81 unsigned int cursorY_;82 74 83 75 static IOConsole* singletonPtr_s; -
code/branches/console/src/libraries/core/Shell.cc
r5969 r5973 118 118 this->inputBuffer_->registerListener(this, &Shell::inputChanged, true); 119 119 this->inputBuffer_->registerListener(this, &Shell::execute, '\r', false); 120 this->inputBuffer_->registerListener(this, &Shell::execute, '\n', false); 120 121 this->inputBuffer_->registerListener(this, &Shell::hintandcomplete, '\t', true); 121 122 this->inputBuffer_->registerListener(this, &Shell::backspace, '\b', true); 123 this->inputBuffer_->registerListener(this, &Shell::backspace, static_cast<char>(127), true); 122 124 this->inputBuffer_->registerListener(this, &Shell::deletechar, KeyCode::Delete); 123 125 this->inputBuffer_->registerListener(this, &Shell::exit, static_cast<char>(27), true); -
code/branches/console/src/orxonox/gamestates/GSIOConsole.cc
r5929 r5973 58 58 void GSIOConsole::update(const Clock& time) 59 59 { 60 /* 60 61 std::cout << ">"; 61 62 std::string command; 62 63 std::getline(std::cin, command); 63 64 CommandExecutor::execute(command, true); 65 */ 64 66 } 65 67
Note: See TracChangeset
for help on using the changeset viewer.