1 // This file is part of the utio library, a terminal I/O library.
3 // Copyright (C) 2004 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
9 #ifndef KB_H_70C9E93B05A3B0D527D942E351FEEE4B
10 #define KB_H_70C9E93B05A3B0D527D942E351FEEE4B
17 /// \class CKeyboard kb.h utio/kb.h
19 /// \brief Keyboard code preprocessor for terminals.
21 /// Takes raw codes from the input port and translates them into keycode events.
25 typedef CTerminfo::keystrings_t keymap_t
;
29 void Open (const CTerminfo
& rti
);
31 void EnterUIMode (void);
32 void LeaveUIMode (void);
33 wchar_t DecodeKey (istream
& is
) const;
34 inline bool IsInUIMode (void) const { return (s_bTermInUIMode
); }
35 inline void LoadKeymap (const CTerminfo
& rti
) { rti
.LoadKeystrings (m_Keymap
); }
36 wchar_t GetKey (bool bBlock
= true) const;
37 bool WaitForKeyData (long timeout
= 0) const;
39 void ReadKeyData (void) const;
41 keymap_t m_Keymap
; ///< Currently loaded keymap.
42 mutable string m_Keydata
; ///< Buffered keydata.
43 struct termios m_InitialTermios
; ///< What it was before we munged it.
44 static bool s_bTermInUIMode
; ///< Current terminal state, static because the terminal is process-global.