Changeset 8729 for code/trunk/src/libraries/core/command
- Timestamp:
- Jul 4, 2011, 2:47:44 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/src/libraries/core/command/Functor.h
r8706 r8729 114 114 #define _Functor_H__ 115 115 116 #include "core/CorePrereqs.h" 117 116 118 #include <typeinfo> 117 118 #include "core/CorePrereqs.h"119 119 120 120 #include "util/Debug.h" -
code/trunk/src/libraries/core/command/IOConsolePOSIX.cc
r7422 r8729 236 236 void IOConsole::printOutputLine(const std::string& text, Shell::LineType type) 237 237 { 238 /*239 238 // Colour line 240 239 switch (type) 241 240 { 242 case Shell::None: this->cout_ << "\033[37m"; break;243 241 case Shell::Error: this->cout_ << "\033[91m"; break; 244 case Shell::Warning: this->cout_ << "\033[31m"; break; 245 case Shell::Info: this->cout_ << "\033[34m"; break; 246 case Shell::Debug: this->cout_ << "\033[36m"; break; 247 case Shell::Verbose: this->cout_ << "\033[35m"; break; 248 case Shell::Ultra: this->cout_ << "\033[37m"; break; 242 case Shell::Warning: this->cout_ << "\033[93m"; break; 243 case Shell::Info: this->cout_ << "\033[90m"; break; 244 case Shell::Debug: this->cout_ << "\033[90m"; break; 245 case Shell::Verbose: this->cout_ << "\033[90m"; break; 246 case Shell::Ultra: this->cout_ << "\033[90m"; break; 247 case Shell::Command: this->cout_ << "\033[36m"; break; 248 case Shell::Hint: this->cout_ << "\033[33m"; break; 249 case Shell::TDebug: this->cout_ << "\033[95m"; break; 249 250 default: break; 250 251 } 251 */252 252 253 253 // Print output line 254 254 this->cout_ << text; 255 255 256 // Reset colour to white257 // this->cout_ << "\033[37m";256 // Reset colour atributes 257 this->cout_ << "\033[0m"; 258 258 } 259 259 -
code/trunk/src/libraries/core/command/IOConsoleWindows.cc
r7287 r8729 208 208 case Shell::Command: colour = FOREGROUND_GREEN | FOREGROUND_BLUE; break; 209 209 case Shell::Hint: colour = FOREGROUND_GREEN | FOREGROUND_RED ; break; 210 case Shell::TDebug: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE; break; 210 211 default: colour = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE; break; 211 212 } -
code/trunk/src/libraries/core/command/IOConsoleWindows.h
r7401 r8729 39 39 #include <sstream> 40 40 #include <string> 41 #include <vector>42 41 #include "util/Singleton.h" 43 42 #include "Shell.h" -
code/trunk/src/libraries/core/command/Shell.cc
r8706 r8729 34 34 #include "Shell.h" 35 35 36 #include "util/Math.h" 36 37 #include "util/OutputHandler.h" 37 38 #include "util/StringUtils.h" … … 40 41 #include "core/ConfigFileManager.h" 41 42 #include "core/ConfigValueIncludes.h" 43 #include "core/PathConfig.h" 44 #include "core/input/InputBuffer.h" 42 45 #include "CommandExecutor.h" 43 46 #include "ConsoleCommand.h" … … 84 87 85 88 // Get the previous output and add it to the Shell 86 for (OutputHandler::OutputVectorIterator it = OutputHandler::getInstance().getOutputVectorBegin();87 it != OutputHandler::getInstance().getOutputVectorEnd(); ++it)88 { 89 if (it->first <= this->getSoftDebugLevel())89 OutputHandler::OutputVector::const_iterator it = OutputHandler::getInstance().getOutput().begin(); 90 for (;it != OutputHandler::getInstance().getOutput().end(); ++it) 91 { 92 if (it->first <= debugLevel_) 90 93 { 91 94 this->outputBuffer_ << it->second; … … 96 99 // Register the shell as output listener 97 100 OutputHandler::getInstance().registerOutputListener(this); 101 OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_); 98 102 } 99 103 … … 105 109 OutputHandler::getInstance().unregisterOutputListener(this); 106 110 this->inputBuffer_->destroy(); 111 } 112 113 namespace DefaultLogLevel 114 { 115 const OutputLevel::Value Dev = OutputLevel::Info; 116 const OutputLevel::Value User = OutputLevel::Error; 107 117 } 108 118 … … 119 129 SetConfigValue(cacheSize_s, 32); 120 130 121 #ifdef ORXONOX_RELEASE 122 const unsigned int defaultLevel = 1; 123 #else 124 const unsigned int defaultLevel = 3; 125 #endif 126 SetConfigValueExternal(softDebugLevel_, "OutputHandler", "softDebugLevel" + this->consoleName_, defaultLevel) 127 .description("The maximal level of debug output shown in the Shell"); 128 this->setSoftDebugLevel(this->softDebugLevel_); 131 // Choose the default level according to the path Orxonox was started (build directory or not) 132 OutputLevel::Value defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User); 133 SetConfigValueExternal(debugLevel_, "OutputHandler", "debugLevel" + consoleName_, defaultDebugLevel) 134 .description("The maximum level of debug output shown in the " + consoleName_); 135 OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_); 129 136 } 130 137 … … 150 157 this->commandHistory_.erase(this->commandHistory_.begin() + index); 151 158 ModifyConfigValue(commandHistory_, remove, index); 159 } 160 } 161 162 /** Called upon changes in the development mode (by Core) 163 Behaviour details see Core::devModeChanged. 164 */ 165 void Shell::devModeChanged(bool value) 166 { 167 bool isNormal = (value == PathConfig::buildDirectoryRun()); 168 if (isNormal) 169 { 170 ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, update); 171 } 172 else 173 { 174 OutputLevel::Value level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User); 175 ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, tset, level); 152 176 } 153 177 } … … 215 239 } 216 240 241 /// Returns the current position of the cursor in the input buffer. 242 unsigned int Shell::getCursorPosition() const 243 { 244 return this->inputBuffer_->getCursorPosition(); 245 } 246 247 /// Returns the current content of the input buffer (the text which was entered by the user) 248 const std::string& Shell::getInput() const 249 { 250 return this->inputBuffer_->get(); 251 } 252 217 253 /** 218 254 @brief Sends output to the internal output buffer. -
code/trunk/src/libraries/core/command/Shell.h
r7401 r8729 49 49 50 50 #include "util/OutputHandler.h" 51 #include "core/Core.h" 51 52 #include "core/OrxonoxClass.h" 52 #include "core/input/InputBuffer.h"53 53 54 54 namespace orxonox … … 85 85 Different graphical consoles build upon a Shell, for example InGameConsole and IOConsole. 86 86 */ 87 class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener87 class _CoreExport Shell : public OutputListener, public DevModeListener 88 88 { 89 89 public: … … 91 91 enum LineType 92 92 { 93 TDebug = OutputLevel::TDebug, 93 94 None = OutputLevel::None, 94 95 Warning = OutputLevel::Warning, … … 118 119 119 120 void setCursorPosition(unsigned int cursor); 120 /// Returns the current position of the cursor in the input buffer. 121 inline unsigned int getCursorPosition() const 122 { return this->inputBuffer_->getCursorPosition(); } 123 124 /// Returns the current content of the input buffer (the text which was entered by the user) 125 inline const std::string& getInput() const 126 { return this->inputBuffer_->get(); } 121 unsigned int getCursorPosition() const; 122 123 const std::string& getInput() const; 127 124 128 125 typedef std::list<std::pair<std::string, LineType> > LineList; … … 146 143 private: 147 144 Shell(const Shell& other); 145 146 // DevModeListener 147 void devModeChanged(bool value); 148 148 149 149 void addToHistory(const std::string& command); … … 197 197 unsigned int historyOffset_; ///< The command history is a circular buffer, this variable defines the current write-offset 198 198 std::vector<std::string> commandHistory_; ///< The history of commands that were entered by the user 199 int softDebugLevel_; ///< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)199 int debugLevel_; //!< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output) 200 200 static unsigned int cacheSize_s; ///< The maximum cache size of the CommandExecutor - this is stored here for better readability of the config file and because CommandExecutor is no OrxonoxClass 201 201 };
Note: See TracChangeset
for help on using the changeset viewer.