Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: added Shell Class to the utils.
This class should enable us to print all the output from orxonox directly onto the screen.
Also it should allow inputting some little Commands, so that we have more force over our little project :)

Also added a new Function to tList, removeLast, that is very quick in deleting the last element, as this is used inside of the Shell (deleting the Last Element is a major issue)

File size: 2.1 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
11#include <stdio.h>
12#include <stdarg.h>
13
14
15// FORWARD DECLARATION
16class Text;
17template<class T> class tList;
18
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 */
31class Shell : public Element2D {
32
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; };
37
38
39    void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };
40
41    void setBufferDisplaySize(unsigned int bufferDisplaySize);
42
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);
48
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
79};
80
81#endif /* _SHELL_H */
Note: See TracBrowser for help on using the repository browser.