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