Changeset 3122 for code/branches/netp4/src
- Timestamp:
- Jun 9, 2009, 1:11:55 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp4/src/orxonox/gamestates/GSDedicated.cc
r3121 r3122 131 131 if ( inputIterator_>=MAX_COMMAND_LENGTH-1 && c!='\n' ) 132 132 continue; 133 this->commandLine_[this->inputIterator_++] = c; 134 if( c == '\n' ) 133 switch (c) 135 134 { 136 this->cleanLine_ = true; 137 boost::recursive_mutex::scoped_lock(this->inputQueueMutex_); 138 this->commandQueue_.push( std::string((const char*)this->commandLine_,inputIterator_) ); 139 memset( this->commandLine_, 0, inputIterator_ ); 140 inputIterator_ = 0; 141 } 142 else if( c == 0x8 ) // Backspace 143 { 144 boost::recursive_mutex::scoped_lock(this->inputQueueMutex_); 145 commandLine_[inputIterator_--]=0; 135 case '\n': 136 this->cleanLine_ = true; 137 { 138 boost::recursive_mutex::scoped_lock(this->inputQueueMutex_); 139 boost::recursive_mutex::scoped_lock(this->inputLineMutex_); 140 this->commandQueue_.push( std::string((const char*)this->commandLine_,inputIterator_) ); 141 } 142 memset( this->commandLine_, 0, inputIterator_ ); 143 inputIterator_ = 0; 144 std::cout << endl; 145 break; 146 case 127: // backspace 147 case '\b': 148 { 149 boost::recursive_mutex::scoped_lock(this->inputLineMutex_); 150 if(inputIterator_>0) 151 --inputIterator_; 152 break; 153 } 154 case '\t': 155 { 156 boost::recursive_mutex::scoped_lock(this->inputLineMutex_); 157 COUT(0) << endl << CommandExecutor::hint( std::string((const char*)this->commandLine_,inputIterator_) ) << endl; 158 strncpy((char*)this->commandLine_, CommandExecutor::complete( std::string((const char*)this->commandLine_,inputIterator_) ).c_str(), MAX_COMMAND_LENGTH); 159 inputIterator_ = strlen((const char*)this->commandLine_); 160 break; 161 } 162 default: 163 { 164 boost::recursive_mutex::scoped_lock(this->inputLineMutex_); 165 this->commandLine_[this->inputIterator_++] = c; 166 break; 167 } 146 168 } 147 169 } … … 155 177 std::cout << "\033[0G\033[K"; 156 178 boost::recursive_mutex::scoped_lock(this->inputLineMutex_); 157 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 # " << this->commandLine_;179 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 # " << std::string((const char*)this->commandLine_,inputIterator_); 158 180 //if ( this->cleanLine_ ) 159 181 // this->cleanLine_ = false; … … 186 208 void GSDedicated::setTerminalMode() 187 209 { 188 termios new_settings;210 termios new_settings; 189 211 190 tcgetattr(0,this->originalTerminalSettings_); 191 new_settings = *this->originalTerminalSettings_; 192 new_settings.c_lflag &= (~ICANON); 193 new_settings.c_cc[VTIME] = 0; 194 new_settings.c_cc[VMIN] = 1; 195 tcsetattr(0,TCSANOW,&new_settings); 196 COUT(0) << endl; 197 atexit(&GSDedicated::resetTerminalMode); 212 tcgetattr(0,this->originalTerminalSettings_); 213 new_settings = *this->originalTerminalSettings_; 214 new_settings.c_lflag &= ~( ICANON | ECHO ); 215 // new_settings.c_lflag |= ( ISIG | IEXTEN ); 216 new_settings.c_cc[VTIME] = 0; 217 new_settings.c_cc[VMIN] = 1; 218 tcsetattr(0,TCSANOW,&new_settings); 219 COUT(0) << endl; 220 // atexit(&GSDedicated::resetTerminalMode); 198 221 } 199 222 … … 201 224 { 202 225 #ifndef ORXONOX_PLATFORM_WINDOWS 203 tcsetattr(0, TCSANOW, GSDedicated::originalTerminalSettings_);226 tcsetattr(0, TCSANOW, GSDedicated::originalTerminalSettings_); 204 227 #endif 205 228 }
Note: See TracChangeset
for help on using the changeset viewer.