Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/util/shell.h @ 5073

Last change on this file since 5073 was 5072, checked in by bensch, 19 years ago

orxonox/trunk: started function implementation for Shell

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