Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: key-repeat in the Shell is smoother now

File size: 2.5 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 <list>
15
16// FORWARD DECLARATION
17class ShellCompletion;
18
19//! An InputLine for the Shell
20/**
21 * The ShellInput has the ability to catch and display user input.
22 * The ShellInput is auto-completed after the user presses [TAB]
23 * The ShellInput is executed (and sent back to the Application) on Pressing [ENTER]
24 * [UP] and [DOWN] move through the history of allready given commands.
25 */
26class ShellInput : public Text,  public EventListener {
27
28 public:
29  ShellInput();
30  virtual ~ShellInput();
31
32  /** @returns the inputLine */
33  const char* getInput() const { return this->inputLine; };
34
35  // InputLine
36  void flush();
37  void setInputText(const char* text);
38  void addCharacter(char character);
39  void addCharacters(const char* characters);
40  void removeCharacters(unsigned int characterCount = 1);
41  void setRepeatDelay(float repeatDelay, float repeatRate);
42  bool executeCommand();
43
44  /** sets the count of the History's entries */
45  void setHistoryLength(unsigned int historyLength) { this->historyLength = historyLength; };
46  void historyMoveUp();
47  void historyMoveDown();
48
49  void help(const char* className = "", const char* function = "");
50
51  virtual void tick(float dt);
52  virtual void process(const Event &event);
53
54 private:
55    // HANDLING TEXT INPUT
56   ShellCompletion*            completion;             //!< The Completion Interface.
57
58   char*                       inputLine;              //!< the Char-Array of the Buffer
59   float                       repeatRate;             //!< The Repeat-Delay.
60   float                       repeatDelay;            //!< The delay of the first Character of a given Character.
61   float                       delayed;                //!< how much of the delay is remaining.
62   Uint16                      pressedKey;             //!< the pressed key that will be repeated.
63
64   std::list<char*>            history;                //!< The history of given commands.
65   std::list<char*>::iterator  historyIT;
66   unsigned int                historyLength;          //!< The maximum length of the InputHistory.
67   bool                        historyScrolling;       //!< true if we are scrolling through the history.
68};
69
70#endif /* _SHELL_INPUT_H */
Note: See TracBrowser for help on using the repository browser.