[4838] | 1 | /*! |
---|
[5068] | 2 | * @file shell.h |
---|
| 3 | * Definition of a on-screen-shell |
---|
[5204] | 4 | * |
---|
[5208] | 5 | * @todo Buffer Display in different Colors for different debug mode. |
---|
[5245] | 6 | * @todo move up and down in Buffer |
---|
[5204] | 7 | */ |
---|
[1853] | 8 | |
---|
[5068] | 9 | #ifndef _SHELL_H |
---|
| 10 | #define _SHELL_H |
---|
[1853] | 11 | |
---|
[5068] | 12 | #include "element_2d.h" |
---|
[5069] | 13 | #include "event_listener.h" |
---|
[1853] | 14 | |
---|
[5068] | 15 | #include <stdarg.h> |
---|
| 16 | |
---|
[4838] | 17 | // FORWARD DECLARATION |
---|
[5068] | 18 | class Text; |
---|
[5179] | 19 | class ShellInput; |
---|
[5141] | 20 | class ShellCommandBase; |
---|
[5068] | 21 | template<class T> class tList; |
---|
[5118] | 22 | template<class T> class tIterator; |
---|
[3543] | 23 | |
---|
[5068] | 24 | //! A class that is able to redirect all output to a openGL-Shell, and that one can use to input some commands |
---|
| 25 | /** |
---|
| 26 | * the major idea is, that all the Output can be redirected to the Shell, |
---|
| 27 | * and does not have to be displayed to the opening Shell, this is good, |
---|
| 28 | * for developers using Windows, where all output is otherwise redirected |
---|
| 29 | * to stdout.txt |
---|
| 30 | * |
---|
| 31 | * Furthermore the Shell should enable us, to input some simple commands |
---|
[5246] | 32 | * Each Class can check itself in to the Shell, and listen for commands. |
---|
[5068] | 33 | * |
---|
[5246] | 34 | * more info: @see ShellCommand |
---|
| 35 | * @see shell_command.h |
---|
| 36 | * @see shell_buffer.h |
---|
| 37 | * @see shell_input.h |
---|
| 38 | * |
---|
| 39 | * !! note in order to keep shellbuffer to a minimal (it is included with |
---|
| 40 | * !! debug.h) Display of it inside the Shell is located here !! |
---|
[5068] | 41 | */ |
---|
[5069] | 42 | class Shell : public Element2D, public EventListener { |
---|
[3543] | 43 | |
---|
[5068] | 44 | public: |
---|
[5206] | 45 | Shell(); |
---|
[5068] | 46 | virtual ~Shell(); |
---|
[2036] | 47 | |
---|
[5113] | 48 | void activate(); |
---|
| 49 | void deactivate(); |
---|
[5197] | 50 | /** @returns true if the Shell is active, false otherwise. */ |
---|
[5176] | 51 | inline bool isActive() const { return this->bActive; }; |
---|
[1853] | 52 | |
---|
[5113] | 53 | void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1); |
---|
| 54 | void rebuildText(); |
---|
[3245] | 55 | |
---|
[5175] | 56 | // BUFFERS |
---|
[5113] | 57 | void setBufferDisplaySize(unsigned int bufferDisplaySize); |
---|
[5118] | 58 | void printToDisplayBuffer(const char* text); |
---|
[5246] | 59 | void moveDisplayBuffer(int lineCount); |
---|
| 60 | |
---|
[5183] | 61 | void flush(); |
---|
[3245] | 62 | |
---|
[5130] | 63 | void clear(); |
---|
| 64 | |
---|
[5069] | 65 | // EventListener |
---|
| 66 | virtual void process(const Event &event); |
---|
[5068] | 67 | // Element2D-functions |
---|
| 68 | virtual void draw() const; |
---|
| 69 | |
---|
| 70 | void debug() const; |
---|
| 71 | |
---|
| 72 | private: |
---|
[5120] | 73 | // helpers // |
---|
| 74 | Vector calculateLinePosition(unsigned int lineNumber); |
---|
[5113] | 75 | |
---|
[5183] | 76 | // void testI (int i); |
---|
| 77 | // void testS (const char* s); |
---|
| 78 | // void testB (bool b); |
---|
| 79 | // void testF (float f); |
---|
| 80 | // void testSF (const char* s, float f); |
---|
| 81 | |
---|
[5068] | 82 | private: |
---|
[5180] | 83 | // GENERAL |
---|
[5246] | 84 | bool bActive; //!< If the shell is active. |
---|
| 85 | unsigned int shellHeight; //!< The hight of the Shell in Pixels. |
---|
[5180] | 86 | unsigned int lineSpacing; //!< The Spacing between lines. |
---|
| 87 | unsigned int textSize; //!< The size of the text. |
---|
[5208] | 88 | char* textFont; //!< The file containing the font. |
---|
[5068] | 89 | |
---|
[5175] | 90 | // HANDLING TEXT INPUT |
---|
[5197] | 91 | ShellInput* shellInput; //!< The inputLine of the Shell. |
---|
[5180] | 92 | // BUFFER |
---|
[5246] | 93 | unsigned int bufferDisplaySize; //!< The Size of the Display-buffer, in lines (not in characters). |
---|
| 94 | Text** bufferText; //!< A list of stored bufferTexts for the display of the buffer. |
---|
| 95 | int bufferOffset; //!< how many lines from the bottom up we display the Buffer. |
---|
[1853] | 96 | }; |
---|
| 97 | |
---|
[5068] | 98 | #endif /* _SHELL_H */ |
---|