Changeset 6105 for code/trunk/src/libraries/core/Shell.h
- Timestamp:
- Nov 20, 2009, 4:55:40 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/console (added) merged: 5941,5945,5968-5975,5983,5985-5986,5991-5992,5994-5996,5998,6000,6004-6007,6010-6017,6034,6037,6041,6043-6044,6089,6103-6104
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/Shell.h
r5781 r6105 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Reto Grieder 26 26 * 27 27 */ … … 32 32 #include "CorePrereqs.h" 33 33 34 #include <cassert>35 34 #include <list> 35 #include <sstream> 36 36 #include <string> 37 37 #include <vector> 38 38 39 #include "util/OutputBuffer.h" 40 #include "input/InputBuffer.h" 39 #include "util/OutputHandler.h" 41 40 #include "OrxonoxClass.h" 42 41 #include "ConfigFileManager.h" 42 #include "input/InputBuffer.h" 43 43 44 44 namespace orxonox … … 57 57 virtual void inputChanged() {} 58 58 virtual void cursorChanged() {} 59 virtual void executed() {} 59 60 virtual void exit() {} 60 61 }; 61 62 62 class _CoreExport Shell : public Singleton<Shell>, virtual public OrxonoxClass, public OutputBufferListener 63 64 class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener 63 65 { 64 friend class Singleton<Shell>;65 66 public: 66 Shell( );67 virtual~Shell();67 Shell(const std::string& consoleName, bool bScrollable, bool bPrependOutputLevel = false); 68 ~Shell(); 68 69 69 static void clearShell(); 70 static void history(); 71 72 virtual void setConfigValues(); 70 void setConfigValues(); 73 71 void commandHistoryOffsetChanged(); 74 72 void commandHistoryLengthChanged(); … … 79 77 inline InputBuffer* getInputBuffer() 80 78 { return this->inputBuffer_; } 81 inline OutputBuffer& getOutputBuffer()82 { return this->outputBuffer_; }83 79 84 80 void setCursorPosition(unsigned int cursor); … … 86 82 { return this->inputBuffer_->getCursorPosition(); } 87 83 88 void setInput(const std::string& input);89 90 inline void clearInput()91 { this->setInput(""); }92 84 inline std::string getInput() const 93 85 { return this->inputBuffer_->get(); } … … 96 88 std::list<std::string>::const_iterator getEndIterator() const; 97 89 98 void add Line(const std::string& line, int level = 0);99 void clear Lines();90 void addOutputLine(const std::string& line, int level = 0); 91 void clearOutput(); 100 92 101 93 inline unsigned int getNumLines() const 102 { return this-> lines_.size(); }94 { return this->outputLines_.size(); } 103 95 inline unsigned int getScrollPosition() const 104 96 { return this->scrollPosition_; } 105 97 106 inline void addOutputLevel(bool bAddOutputLevel)107 { this->bAddOutputLevel_ = bAddOutputLevel; }98 inline const std::string& getPromptPrefix() const { return this->promptPrefix_; } 99 void setPromptPrefix(const std::string& str); 108 100 109 101 private: 110 102 Shell(const Shell& other); 111 103 104 void addToHistory(const std::string& command); 105 std::string getFromHistory() const; 106 void clearInput(); 107 // OutputListener 108 void outputChanged(int level); 109 112 110 void configureInputBuffer(); 113 111 114 void addToHistory(const std::string& command); 115 std::string getFromHistory() const; 116 117 virtual void outputChanged(); 112 // InputBuffer callbacks 118 113 void inputChanged(); 119 114 void execute(); 120 void hint andcomplete();115 void hintAndComplete(); 121 116 void backspace(); 122 void deletechar(); 123 void clear(); 124 void cursor_right(); 125 void cursor_left(); 126 void cursor_end(); 127 void cursor_home(); 128 void history_up(); 129 void history_down(); 130 void scroll_up(); 131 void scroll_down(); 117 void deleteChar(); 118 void cursorRight(); 119 void cursorLeft(); 120 void cursorEnd(); 121 void cursorHome(); 122 void historyUp(); 123 void historyDown(); 124 void historySearchUp(); 125 void historySearchDown(); 126 void scrollUp(); 127 void scrollDown(); 132 128 void exit(); 133 129 130 template <void (ShellListener::*F)()> 131 void updateListeners() 132 { 133 for (std::list<ShellListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ) 134 ((*(it++))->*F)(); 135 } 136 134 137 std::list<ShellListener*> listeners_; 135 InputBuffer* inputBuffer_;136 OutputBufferoutputBuffer_;137 bool finishedLastLine_;138 std::list<std::string> lines_;138 InputBuffer* inputBuffer_; 139 std::stringstream outputBuffer_; 140 bool bFinishedLastLine_; 141 std::list<std::string> outputLines_; 139 142 std::list<std::string>::const_iterator scrollIterator_; 140 unsigned int scrollPosition_; 141 std::vector<std::string> commandHistory_; 142 unsigned int maxHistoryLength_; 143 unsigned int historyPosition_; 144 unsigned int historyOffset_; 145 bool bAddOutputLevel_; 143 unsigned int scrollPosition_; 144 unsigned int historyPosition_; 145 ConfigFileType commandHistoryConfigFileType_; 146 146 147 ConfigFileType commandHistoryConfigFileType_; 147 std::string promptPrefix_; 148 const std::string consoleName_; 149 const bool bPrependOutputLevel_; 150 const bool bScrollable_; 148 151 149 static Shell* singletonPtr_s; 152 // Config values 153 unsigned int maxHistoryLength_; 154 unsigned int historyOffset_; 155 std::vector<std::string> commandHistory_; 156 int softDebugLevel_; 150 157 }; 151 158 }
Note: See TracChangeset
for help on using the changeset viewer.