[4838] | 1 | /*! |
---|
[5068] | 2 | * @file shell.h |
---|
| 3 | * Definition of a on-screen-shell |
---|
[3245] | 4 | */ |
---|
[1853] | 5 | |
---|
[5068] | 6 | #ifndef _SHELL_H |
---|
| 7 | #define _SHELL_H |
---|
[1853] | 8 | |
---|
[5068] | 9 | #include "element_2d.h" |
---|
[1853] | 10 | |
---|
[5068] | 11 | #include <stdio.h> |
---|
| 12 | #include <stdarg.h> |
---|
| 13 | |
---|
| 14 | |
---|
[4838] | 15 | // FORWARD DECLARATION |
---|
[5068] | 16 | class Text; |
---|
| 17 | template<class T> class tList; |
---|
[3543] | 18 | |
---|
[5068] | 19 | //! A class that is able to redirect all output to a openGL-Shell, and that one can use to input some commands |
---|
| 20 | /** |
---|
| 21 | * the major idea is, that all the Output can be redirected to the Shell, |
---|
| 22 | * and does not have to be displayed to the opening Shell, this is good, |
---|
| 23 | * for developers using Windows, where all output is otherwise redirected |
---|
| 24 | * to stdout.txt |
---|
| 25 | * |
---|
| 26 | * Furthermore the Shell should enable us, to input some simple commands |
---|
| 27 | * Each Class can tell check itself in to the Shell, and listen for commands. |
---|
| 28 | * |
---|
| 29 | * @todo implement what is written above :/ |
---|
| 30 | */ |
---|
| 31 | class Shell : public Element2D { |
---|
[3543] | 32 | |
---|
[5068] | 33 | public: |
---|
| 34 | virtual ~Shell(); |
---|
| 35 | /** @returns a Pointer to the only object of this Class */ |
---|
| 36 | inline static Shell* getInstance(void) { if (!Shell::singletonRef) Shell::singletonRef = new Shell(); return Shell::singletonRef; }; |
---|
[2036] | 37 | |
---|
[1853] | 38 | |
---|
[5068] | 39 | void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; }; |
---|
[1853] | 40 | |
---|
[5068] | 41 | void setBufferDisplaySize(unsigned int bufferDisplaySize); |
---|
[3245] | 42 | |
---|
[5068] | 43 | // BUFFER // |
---|
| 44 | void flushBuffers(); |
---|
| 45 | void addBufferLine(const char* Line, va_list args); |
---|
| 46 | void moveBuffer(int lineCount); |
---|
| 47 | const char* getBufferLine(unsigned int lineNumber); |
---|
[3245] | 48 | |
---|
[5068] | 49 | // inputLine |
---|
| 50 | void flushInputLine(); |
---|
| 51 | void addCharacter(char character); |
---|
| 52 | void addCharacters(const char* characters); |
---|
| 53 | void removeCharacters(unsigned int characterCount = 1); |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | // Element2D-functions |
---|
| 57 | void tick(float dt); |
---|
| 58 | virtual void draw() const; |
---|
| 59 | |
---|
| 60 | void debug() const; |
---|
| 61 | |
---|
| 62 | private: |
---|
| 63 | bool autoComplete(); |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | private: |
---|
| 67 | Shell(); |
---|
| 68 | static Shell* singletonRef; |
---|
| 69 | |
---|
| 70 | unsigned int bufferSize; |
---|
| 71 | unsigned int bufferDisplaySize; |
---|
| 72 | |
---|
| 73 | char* inputLine; |
---|
| 74 | |
---|
| 75 | tList<const char>* buffer; |
---|
| 76 | |
---|
| 77 | tList<Text>* bufferText; //!< A list of sored bufferLines of the Shell |
---|
| 78 | Text* inputLineText; //!< The inputLine of the Shell |
---|
[1853] | 79 | }; |
---|
| 80 | |
---|
[5068] | 81 | #endif /* _SHELL_H */ |
---|