Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/atmospheric_engine/src/lib/shell/shell_input.h @ 7981

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

orxonox/trunk: better debug names
As DEBUG and ERROR are already given to windows.h and other files:
DEBUG is renamed to DEBUG_LEVEL
and all
NO, ERR, WARN, INFO, DEBUG, vDEBUG
are renamed to
ORX_NONE, ORX_ERR, ORX_WARN, ORX_INFO, ORX_DEBUG, ORX_vDEBUG

File size: 2.7 KB
Line 
1/*!
2 * @file shell_input.h
3 * @brief Shell Input is an InputLine for the Shell.
4 *
5 * @todo move around in the InputText with the cursor (SDLK_LEFT/SDLK_RIGHT)
6 * @todo blinking curson (can blink with the speed of the RepeatDelay)
7*/
8
9#ifndef _SHELL_INPUT_H
10#define _SHELL_INPUT_H
11
12#include "text.h"
13#include "event_listener.h"
14#include "shell_completion.h"
15
16#include <list>
17
18namespace OrxShell
19{
20  // FORWARD DECLARATION
21  class ShellCompletion;
22
23  //! An InputLine for the Shell
24  /**
25   * The ShellInput has the ability to catch and display user input.
26   * The ShellInput is auto-completed after the user presses [TAB]
27   * The ShellInput is executed (and sent back to the Application) on Pressing [ENTER]
28   * [UP] and [DOWN] move through the history of allready given commands.
29   */
30  class ShellInput : public Text,  public EventListener
31  {
32
33  public:
34    ShellInput();
35    virtual ~ShellInput();
36
37    /** @returns the inputLine */
38    const std::string& getInput() const { return this->inputLine; };
39
40    // InputLine
41    void setInputText(const std::string& text);
42    void addCharacter(char character);
43    void addCharacters(const std::string& characters);
44    void removeCharacters(unsigned int characterCount = 1);
45    void flush();
46
47    void setRepeatDelay(float repeatDelay, float repeatRate);
48
49    bool executeCommand();
50
51    /** sets the count of the History's entries */
52    void setHistoryLength(unsigned int historyLength) { this->historyLength = historyLength; };
53    void historyMoveUp();
54    void historyMoveDown();
55
56    void help(const std::string& className = "", const std::string& function = "");
57
58    virtual void tick(float dt);
59    virtual void process(const Event &event);
60
61  private:
62    // HANDLING TEXT INPUT
63    ShellCompletion                   completion;       //!< The Completion Interface.
64
65    std::string                       inputLine;        //!< the Char-Array of the Buffer
66    float                             repeatRate;       //!< The Repeat-Delay.
67    float                             repeatDelay;      //!< The delay of the first Character of a given Character.
68    float                             delayed;          //!< how much of the delay is remaining.
69    Uint16                            pressedKey;       //!< the pressed key that will be repeated.
70
71    static std::list<std::string>     history;          //!< The history of given commands.
72    std::list<std::string>::iterator  historyIT;        //!< The locator that tells us, where we are in the history.
73    unsigned int                      historyLength;    //!< The maximum length of the InputHistory.
74    bool                              historyScrolling; //!< true if we are scrolling through the history.
75  };
76
77}
78
79#endif /* _SHELL_INPUT_H */
Note: See TracBrowser for help on using the repository browser.