Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/bsp_model_old/src/lib/shell/shell_input.h @ 8264

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

oroxnox/trunk: ShellInput and ShellCompletion more c++-like

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