Changeset 7401 for code/trunk/src/libraries/core/command/Shell.h
- Timestamp:
- Sep 11, 2010, 12:34:00 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/doc (added) merged: 7290-7292,7296-7300,7302-7304,7306-7312,7315-7318,7323,7325,7327,7331-7332,7334-7335,7345-7347,7352-7353,7356-7357,7361,7363-7367,7371-7375,7388
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/command/Shell.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @defgroup ShellConsole Shell and console 31 @ingroup Command 32 */ 33 34 /** 35 @file 36 @ingroup Command ShellConsole 37 @brief Declaration of the Shell and ShellListener classes. 38 */ 39 29 40 #ifndef _Shell_H__ 30 41 #define _Shell_H__ … … 43 54 namespace orxonox 44 55 { 56 /** 57 @brief An interface, used to get a notification if the state of the Shell changes. 58 */ 45 59 class _CoreExport ShellListener 46 60 { … … 51 65 52 66 private: 53 virtual void linesChanged() {} 54 virtual void onlyLastLineChanged() {} 55 virtual void lineAdded() {} 56 virtual void inputChanged() {} 57 virtual void cursorChanged() {} 58 virtual void executed() {} 59 virtual void exit() {} 67 virtual void linesChanged() {} ///< Called if all output-lines have changed 68 virtual void onlyLastLineChanged() {} ///< Called if only the last output-line has changed 69 virtual void lineAdded() {} ///< Called if a new line was added to the output 70 virtual void inputChanged() {} ///< Called if the input has changed 71 virtual void cursorChanged() {} ///< Called if the cursor in the input line has changed 72 virtual void executed() {} ///< Called if a command from the input line was executed 73 virtual void exit() {} ///< Called if the console should be closed 60 74 }; 61 75 62 76 77 /** 78 @brief The Shell is the logical component of the console that displays output to the user and allows him to enter commands. 79 80 The Shell gathers output sent from OutputHandler by inheriting from OutputListener. 81 The output-lines are stored in the shell, so they can be displayed in a graphical 82 console. Additionally the Shell has an InputBuffer which is needed by the user to 83 enter commands. 84 85 Different graphical consoles build upon a Shell, for example InGameConsole and IOConsole. 86 */ 63 87 class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener 64 88 { 65 89 public: 90 /// Defines the type of a line of text in the Shell - some types depend on the output level, others are of internal use. 66 91 enum LineType 67 92 { … … 88 113 void unregisterListener(ShellListener* listener); 89 114 115 /// Returns the input buffer which is needed by the user to enter text into the shell. 90 116 inline InputBuffer* getInputBuffer() 91 117 { return this->inputBuffer_; } 92 118 93 119 void setCursorPosition(unsigned int cursor); 120 /// Returns the current position of the cursor in the input buffer. 94 121 inline unsigned int getCursorPosition() const 95 122 { return this->inputBuffer_->getCursorPosition(); } 96 123 124 /// Returns the current content of the input buffer (the text which was entered by the user) 97 125 inline const std::string& getInput() const 98 126 { return this->inputBuffer_->get(); } … … 105 133 void clearOutput(); 106 134 135 /// Returns the number of output-lines that are displayed in the shell. 107 136 inline unsigned int getNumLines() const 108 137 { return this->outputLines_.size(); } 138 /// Returns the line which is currently viewed if the user scrolls through the older output-lines in the shell. 109 139 inline unsigned int getScrollPosition() const 110 140 { return this->scrollPosition_; } 111 141 112 inline const std::string& getPromptPrefix() const { return this->promptPrefix_; } 113 void setPromptPrefix(const std::string& str); 114 142 /// Returns the cache size that is actually used in CommandExecutor, but placed here for better readability of the config file. 115 143 static inline unsigned int getCacheSize() 116 144 { return Shell::cacheSize_s; } … … 145 173 void exit(); 146 174 175 /// Iterates through all registered @ref ShellListener "shell listeners" and calls the function @a F. 147 176 template <void (ShellListener::*F)()> 148 177 void updateListeners() … … 152 181 } 153 182 154 std::list<ShellListener*> listeners_; 155 InputBuffer* inputBuffer_; 156 std::stringstream outputBuffer_; 157 bool bFinishedLastLine_; 158 LineList outputLines_; 159 LineList::const_iterator scrollIterator_; 160 unsigned int scrollPosition_; 161 unsigned int historyPosition_; 162 163 std::string promptPrefix_; 164 const std::string consoleName_; 165 const bool bScrollable_; 183 std::list<ShellListener*> listeners_; ///< The registered shell listeners 184 InputBuffer* inputBuffer_; ///< The input buffer that is needed by the user to enter text 185 std::stringstream outputBuffer_; ///< The output buffer that is used to retrieve lines of output from OutputListener 186 bool bFinishedLastLine_; ///< Stores if the most recent output-line was terminated with a line-break or if more output is expected for this line 187 LineList outputLines_; ///< A list of all output-lines that were displayed in the shell so far 188 LineList::const_iterator scrollIterator_; ///< An iterator to an entry of the list of output-lines, changes if the user scrolls through the output in the shell 189 unsigned int scrollPosition_; ///< The number of the line that is currently being referenced by scrollIterator_ 190 unsigned int historyPosition_; ///< If the user scrolls through the history of entered commands (stored in commandHistory_), this contains the currently viewed history entry 191 192 const std::string consoleName_; ///< The name of this shell - used to define the name of the soft-debug-level config-value 193 const bool bScrollable_; ///< If true, the user can scroll through the output-lines 166 194 167 195 // Config values 168 unsigned int maxHistoryLength_; 169 unsigned int historyOffset_; 170 std::vector<std::string> commandHistory_; 171 int softDebugLevel_; 172 static unsigned int cacheSize_s; 196 unsigned int maxHistoryLength_; ///< The maximum number of saved commands 197 unsigned int historyOffset_; ///< The command history is a circular buffer, this variable defines the current write-offset 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) 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 173 201 }; 174 202 }
Note: See TracChangeset
for help on using the changeset viewer.