[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" |
---|
[5069] | 10 | #include "event_listener.h" |
---|
[1853] | 11 | |
---|
[5068] | 12 | #include <stdarg.h> |
---|
| 13 | |
---|
[4838] | 14 | // FORWARD DECLARATION |
---|
[5068] | 15 | class Text; |
---|
| 16 | template<class T> class tList; |
---|
[3543] | 17 | |
---|
[5068] | 18 | //! A class that is able to redirect all output to a openGL-Shell, and that one can use to input some commands |
---|
| 19 | /** |
---|
| 20 | * the major idea is, that all the Output can be redirected to the Shell, |
---|
| 21 | * and does not have to be displayed to the opening Shell, this is good, |
---|
| 22 | * for developers using Windows, where all output is otherwise redirected |
---|
| 23 | * to stdout.txt |
---|
| 24 | * |
---|
| 25 | * Furthermore the Shell should enable us, to input some simple commands |
---|
| 26 | * Each Class can tell check itself in to the Shell, and listen for commands. |
---|
| 27 | * |
---|
| 28 | * @todo implement what is written above :/ |
---|
| 29 | */ |
---|
[5069] | 30 | class Shell : public Element2D, public EventListener { |
---|
[3543] | 31 | |
---|
[5068] | 32 | public: |
---|
| 33 | virtual ~Shell(); |
---|
| 34 | /** @returns a Pointer to the only object of this Class */ |
---|
[5072] | 35 | inline static Shell* getInstance() { if (!Shell::singletonRef) Shell::singletonRef = new Shell(); return Shell::singletonRef; }; |
---|
[2036] | 36 | |
---|
[1853] | 37 | |
---|
[5068] | 38 | void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; }; |
---|
[1853] | 39 | |
---|
[5068] | 40 | void setBufferDisplaySize(unsigned int bufferDisplaySize); |
---|
[3245] | 41 | |
---|
[5068] | 42 | // BUFFER // |
---|
| 43 | void flushBuffers(); |
---|
[5075] | 44 | static bool addBufferLineStatic(const char* line, ...); |
---|
| 45 | void addBufferLine(const char* line, va_list arg); |
---|
[5068] | 46 | void moveBuffer(int lineCount); |
---|
| 47 | const char* getBufferLine(unsigned int lineNumber); |
---|
[3245] | 48 | |
---|
[5069] | 49 | // InputLine |
---|
[5068] | 50 | void flushInputLine(); |
---|
| 51 | void addCharacter(char character); |
---|
| 52 | void addCharacters(const char* characters); |
---|
| 53 | void removeCharacters(unsigned int characterCount = 1); |
---|
| 54 | |
---|
| 55 | |
---|
[5069] | 56 | // EventListener |
---|
| 57 | virtual void process(const Event &event); |
---|
| 58 | |
---|
[5068] | 59 | // Element2D-functions |
---|
[5074] | 60 | // void tick(float dt); |
---|
[5068] | 61 | virtual void draw() const; |
---|
| 62 | |
---|
| 63 | void debug() const; |
---|
| 64 | |
---|
| 65 | private: |
---|
| 66 | bool autoComplete(); |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | private: |
---|
| 70 | Shell(); |
---|
[5072] | 71 | static Shell* singletonRef; //!< The singleton-reference to the only memeber of this class. |
---|
[5068] | 72 | |
---|
[5072] | 73 | unsigned int bufferSize; //!< The Size of the buffer |
---|
| 74 | unsigned int bufferDisplaySize; //!< The Size of the Display-buffer, in lines (not in characters) |
---|
[5068] | 75 | |
---|
[5072] | 76 | char* inputLine; //!< the Char-Array of the Buffer |
---|
[5068] | 77 | |
---|
[5072] | 78 | tList<char>* buffer; //!< A list of stored char-arrays(strings) to store the history |
---|
[5068] | 79 | |
---|
[5080] | 80 | Text** bufferText; //!< A list of stored bufferTexts for the display of the buffer |
---|
[5068] | 81 | Text* inputLineText; //!< The inputLine of the Shell |
---|
[5080] | 82 | unsigned int textSize; //!< The size of the text. |
---|
| 83 | unsigned int lineSpacing; //!< The Spacing between lines. |
---|
[5075] | 84 | |
---|
| 85 | char bufferArray[10000]; //!< a BUFFER for fast writing |
---|
[1853] | 86 | }; |
---|
| 87 | |
---|
[5068] | 88 | #endif /* _SHELL_H */ |
---|