Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: fixed an error in ShellDisplay: did not show the last line on first open

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