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