Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 5106 was 5106, checked in by bensch, 20 years ago

orxonox/trunk: top-down shell, as proposed by patrick. This makes sense, becuase the general people knows only shells comming top down

File size: 4.2 KB
RevLine 
[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]15class Text;
16template<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]30class 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
[5106]38    void activate();
39    void deactivate();
[1853]40
[5106]41    void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1);
42    void rebuildText();
[3245]43
[5068]44    // BUFFER //
[5106]45    void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };
46    void setBufferDisplaySize(unsigned int bufferDisplaySize);
[5068]47    void flushBuffers();
[5075]48    static bool addBufferLineStatic(const char* line, ...);
49    void addBufferLine(const char* line, va_list arg);
[5068]50    void moveBuffer(int lineCount);
51    const char* getBufferLine(unsigned int lineNumber);
[3245]52
[5069]53    // InputLine
[5068]54    void flushInputLine();
55    void addCharacter(char character);
56    void addCharacters(const char* characters);
57    void removeCharacters(unsigned int characterCount = 1);
[5096]58    bool executeCommand();
[5068]59
[5097]60    void setRepeatDelay(float repeatDelay, float repeatRate);
[5068]61
[5069]62    // EventListener
63    virtual void process(const Event &event);
64
[5068]65    // Element2D-functions
[5095]66    void tick(float dt);
[5068]67    virtual void draw() const;
68
69    void debug() const;
70
71  private:
72    bool autoComplete();
[5102]73    bool classComplete(const char* classBegin);
[5105]74    bool objectComplete(const char* objectBegin, long classID);
[5102]75    bool functionComplete(const char* functionBegin);
[5068]76
[5105]77    bool generalComplete(const tList<const char>* stringList, const char* begin, const char* displayAs = "%s", const char* addBack = NULL, const char* addFront = NULL);
[5068]78
[5104]79    const tList<const char>* Shell::createCompleteList(const tList<const char>* inputList, const char* classNameBegin);
[5105]80    const tList<const char>* Shell::createCompleteList(const tList<BaseObject>* inputList, const char* classNameBegin);
[5103]81
82
[5068]83  private:
84    Shell();
[5072]85    static Shell*          singletonRef;           //!< The singleton-reference to the only memeber of this class.
[5068]86
[5072]87    unsigned int           bufferSize;             //!< The Size of the buffer
88    unsigned int           bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters)
[5068]89
[5095]90    Text*                  inputLineText;          //!< The inputLine of the Shell
[5072]91    char*                  inputLine;              //!< the Char-Array of the Buffer
[5097]92    float                  repeatRate;             //!< The Repeat-Delay.
93    float                  repeatDelay;            //!< The delay of the first Character of a given Character.
[5095]94    float                  delayed;                //!< how much of the delay is remaining.
95    int                    pressedKey;             //!< the pressed key that will be repeated.
[5068]96
[5072]97    tList<char>*           buffer;                 //!< A list of stored char-arrays(strings) to store the history
[5068]98
[5080]99    Text**                 bufferText;             //!< A list of stored bufferTexts for the display of the buffer
100    unsigned int           textSize;               //!< The size of the text.
101    unsigned int           lineSpacing;            //!< The Spacing between lines.
[5106]102    unsigned int           shellHeight;            //!< The hight of the Shell in Pixels
[5075]103
104    char                   bufferArray[10000];     //!< a BUFFER for fast writing
[5103]105
106    // completion
107    tList<const char>*    completionList;          //!< A list of completions, that are io.
[1853]108};
109
[5068]110#endif /* _SHELL_H */
Note: See TracBrowser for help on using the repository browser.