Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/shell/shell.h @ 5179

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

orxonox/trunk: ShellInput is now almost perfectly extern.
ShellCompletion taken out.
Working again :)

File size: 3.5 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 <stdarg.h>
13
14// FORWARD DECLARATION
15class Text;
16class ShellInput;
17class ShellCommandBase;
18template<class T> class tList;
19template<class T> class tIterator;
20
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
29 * Each Class can tell check itself in to the Shell, and listen for commands.
30 *
31 * @todo implement what is written above :/
32 */
33class Shell : public Element2D, public EventListener {
34
35  public:
36    virtual ~Shell();
37    /** @returns a Pointer to the only object of this Class */
38    inline static Shell* getInstance() { if (!Shell::singletonRef) Shell::singletonRef = new Shell();  return Shell::singletonRef; };
39    /** @returns true if this class is instanciated, false otherwise */
40    inline static bool isInstanciated() { return (Shell::singletonRef == NULL)?false:true; };
41
42    void activate();
43    void deactivate();
44    inline bool isActive() const { return this->bActive; };
45
46    void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1);
47    void rebuildText();
48
49    // BUFFERS
50    void flush();
51    void setBufferDisplaySize(unsigned int bufferDisplaySize);
52    void printToDisplayBuffer(const char* text);
53
54    void clear();
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 help() const;
65    void debug() const;
66
67  private:
68
69    // helpers //
70    Vector calculateLinePosition(unsigned int lineNumber);
71//     void testI (int i);
72//     void testS (const char* s);
73//     void testB (bool b);
74//     void testF (float f);
75//     void testSF (const char* s, float f);
76
77  private:
78    Shell();
79    static Shell*            singletonRef;           //!< The singleton-reference to the only memeber of this class.
80
81    unsigned int             bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters)
82
83    // HANDLING TEXT INPUT
84    ShellInput*              shellInput;
85
86    float                    repeatRate;             //!< The Repeat-Delay.
87    float                    repeatDelay;            //!< The delay of the first Character of a given Character.
88    float                    delayed;                //!< how much of the delay is remaining.
89    int                      pressedKey;             //!< the pressed key that will be repeated.
90
91    tList<char>*             inputHistory;           //!< The history of given commands.
92
93    Text**                   bufferText;             //!< A list of stored bufferTexts for the display of the buffer
94    unsigned int             textSize;               //!< The size of the text.
95    unsigned int             lineSpacing;            //!< The Spacing between lines.
96    unsigned int             shellHeight;            //!< The hight of the Shell in Pixels
97    bool                     bActive;                //!< if the shell is active;
98
99    // completion
100    tList<const char>*       completionList;          //!< A list of completions, that are io.
101};
102
103#endif /* _SHELL_H */
Note: See TracBrowser for help on using the repository browser.