[4838] | 1 | /*! |
---|
[5178] | 2 | * @file shell_input.h |
---|
[5245] | 3 | * @brief Shell Input is an InputLine for the Shell. |
---|
[3245] | 4 | */ |
---|
[1853] | 5 | |
---|
[5178] | 6 | #ifndef _SHELL_INPUT_H |
---|
| 7 | #define _SHELL_INPUT_H |
---|
[1853] | 8 | |
---|
[5179] | 9 | #include "text_engine.h" |
---|
[5180] | 10 | #include "event_listener.h" |
---|
[5179] | 11 | |
---|
[4838] | 12 | // FORWARD DECLARATION |
---|
[5178] | 13 | template<class T> class tList; |
---|
[5243] | 14 | template<class T> class tIterator; |
---|
[5181] | 15 | class ShellCompletion; |
---|
[3543] | 16 | |
---|
[5245] | 17 | //! An InputLine for the Shell |
---|
| 18 | /** |
---|
| 19 | * The ShellInput has the ability to catch and display user input. |
---|
| 20 | * The ShellInput is auto-completed after the user presses [TAB] |
---|
| 21 | * The ShellInput is executed (and sent back to the Application) on Pressing [ENTER] |
---|
| 22 | * [UP] and [DOWN] move through the history of allready given commands. |
---|
| 23 | */ |
---|
[5180] | 24 | class ShellInput : public Text, public EventListener { |
---|
[1853] | 25 | |
---|
[1904] | 26 | public: |
---|
[5178] | 27 | ShellInput(); |
---|
| 28 | virtual ~ShellInput(); |
---|
[1853] | 29 | |
---|
[5185] | 30 | /** @returns the inputLine */ |
---|
| 31 | const char* getInput() const { return this->inputLine; }; |
---|
[3245] | 32 | |
---|
[5178] | 33 | // InputLine |
---|
| 34 | void flush(); |
---|
[5244] | 35 | void setInputText(const char* text); |
---|
[5178] | 36 | void addCharacter(char character); |
---|
| 37 | void addCharacters(const char* characters); |
---|
| 38 | void removeCharacters(unsigned int characterCount = 1); |
---|
| 39 | void setRepeatDelay(float repeatDelay, float repeatRate); |
---|
[5179] | 40 | bool executeCommand(); |
---|
[5243] | 41 | |
---|
[5245] | 42 | /** sets the count of the History's entries */ |
---|
| 43 | void setHistoryLength(unsigned int historyLength) { this->historyLength = historyLength; }; |
---|
[5243] | 44 | void historyMoveUp(); |
---|
| 45 | void historyMoveDown(); |
---|
| 46 | |
---|
[5204] | 47 | void help(const char* className = "", const char* function = ""); |
---|
[5178] | 48 | |
---|
[5180] | 49 | virtual void tick(float dt); |
---|
| 50 | virtual void process(const Event &event); |
---|
| 51 | |
---|
[3245] | 52 | private: |
---|
[5178] | 53 | // HANDLING TEXT INPUT |
---|
[5181] | 54 | ShellCompletion* completion; //!< The Completion Interface. |
---|
| 55 | |
---|
[5245] | 56 | char* inputLine; //!< the Char-Array of the Buffer |
---|
[5178] | 57 | float repeatRate; //!< The Repeat-Delay. |
---|
| 58 | float repeatDelay; //!< The delay of the first Character of a given Character. |
---|
| 59 | float delayed; //!< how much of the delay is remaining. |
---|
| 60 | int pressedKey; //!< the pressed key that will be repeated. |
---|
[3245] | 61 | |
---|
[5243] | 62 | tList<char>* history; //!< The history of given commands. |
---|
| 63 | tIterator<char>* historyIT; |
---|
| 64 | unsigned int historyLength; //!< The maximum length of the InputHistory. |
---|
| 65 | bool historyScrolling; //!< true if we are scrolling through the history. |
---|
[1853] | 66 | }; |
---|
| 67 | |
---|
[5178] | 68 | #endif /* _SHELL_INPUT_H */ |
---|