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