Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

ConsoleInput Class Reference

Inheritance diagram for ConsoleInput:

Inheritance graph
[legend]
Collaboration diagram for ConsoleInput:

Collaboration graph
[legend]

Detailed Description

Debug console input handler.

Definition at line 13 of file ConsoleInput.h.

Public Member Functions

 ConsoleInput (KeyConsole *console)

Protected Member Functions

virtual void enableConsole ()
 Toggle console.
virtual void enableSubtitles ()
virtual void specStroke (const KeyStroke &stroke)
virtual void specKey (int keyIndex)


Constructor & Destructor Documentation

ConsoleInput::ConsoleInput KeyConsole console  ) 
 

Definition at line 21 of file ConsoleInput.cpp.

00022     : StateInput(console)
00023 {
00024     KeyDesc key_history(KEY_HISTORY, "input history");
00025     KeyDesc key_backspace(KEY_BACKSPACE, "backspace");
00026     KeyDesc key_clear(KEY_CLEAR, "clear");
00027     KeyDesc key_enter(KEY_ENTER, "enter");
00028 
00029     m_keymap->registerKey(KeyStroke(SDLK_UP, KMOD_NONE), key_history);
00030     m_keymap->registerKey(KeyStroke(SDLK_BACKSPACE, KMOD_NONE), key_backspace);
00031     m_keymap->registerKey(KeyStroke(SDLK_u, KMOD_LCTRL), key_clear);
00032     m_keymap->registerKey(KeyStroke(SDLK_u, KMOD_RCTRL), key_clear);
00033     m_keymap->registerKey(KeyStroke(SDLK_RETURN, KMOD_NONE), key_enter);
00034 }


Member Function Documentation

void ConsoleInput::enableConsole  )  [protected, virtual]
 

Toggle console.

Reimplemented from StateInput.

Definition at line 46 of file ConsoleInput.cpp.

00047 {
00048     quitState();
00049 }

virtual void ConsoleInput::enableSubtitles  )  [inline, protected, virtual]
 

Reimplemented from StateInput.

Definition at line 22 of file ConsoleInput.h.

00022 {}

void ConsoleInput::specKey int  keyIndex  )  [protected, virtual]
 

Reimplemented from StateInput.

Definition at line 52 of file ConsoleInput.cpp.

00053 {
00054     //TODO: simulate key repeat in console
00055     switch (keyIndex) {
00056         case KEY_HISTORY:
00057             getConsole()->setInput(m_history);
00058             break;
00059         case KEY_BACKSPACE:
00060             {
00061                 std::string input = getConsole()->getInput();
00062                 if (!input.empty()) {
00063                     input.erase(input.end() - 1);
00064                     getConsole()->setInput(input);
00065                 }
00066             }
00067             break;
00068         case KEY_CLEAR:
00069             getConsole()->setInput("");
00070             break;
00071         case KEY_ENTER:
00072             {
00073                 std::string input = getConsole()->getInput();
00074                 if (!input.empty()) {
00075                     if (getConsole()->sendCommand()) {
00076                         m_history = input;
00077                         getConsole()->setInput("");
00078                     }
00079                 }
00080                 else {
00081                     quitState();
00082                 }
00083             }
00084             break;
00085         default:
00086             StateInput::specKey(keyIndex);
00087             break;
00088     }
00089 }

void ConsoleInput::specStroke const KeyStroke stroke  )  [protected, virtual]
 

Reimplemented from StateInput.

Definition at line 92 of file ConsoleInput.cpp.

00093 {
00094     //TODO: support UTF-8
00095     char c = stroke.getUnicode() & 0x7F;
00096     if (isprint(c)) {
00097         std::string input = getConsole()->getInput();
00098         input.push_back(c);
00099         getConsole()->setInput(input);
00100     }
00101 }


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:54:43 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2