ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/keyboard.h
Revision: 1.5
Committed: Mon Jan 2 15:35:43 2006 UTC (18 years, 4 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-6_3
Changes since 1.4: +3 -3 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #ifndef KEYBOARD_H_
2 #define KEYBOARD_H_
3
4 #ifdef KEYSYM_RESOURCE
5
6 #include <inttypes.h>
7
8 #include "feature.h"
9 #include "rxvtutil.h"
10
11 #define KEYSYM_HASH_BITS 4 /* lowest #bits of keysym is used as hash key */
12 #define KEYSYM_HASH_BUDGETS (1<<KEYSYM_HASH_BITS)
13 #define KEYSYM_HASH_MASK (KEYSYM_HASH_BUDGETS-1)
14
15 #define MetaMask 0x0100
16 #define NumLockMask 0x0200
17 #define AppKeypadMask 0x0400
18 #define Level3Mask 0x0800 // currently not supported
19 #define OtherModMask (ShiftMask | LockMask | ControlMask \
20 | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask)
21
22 #if OtherModMask > 0xff
23 # error FATAL: X modifiers might clash with rxvt-unicode ones
24 #endif
25
26 struct rxvt_term;
27 struct keysym_t;
28
29 typedef void (keyevent_handler) (rxvt_term *rt,
30 keysym_t *key,
31 KeySym keysym,
32 unsigned int state);
33
34 struct keysym_t
35 {
36 enum keysym_type {
37 NORMAL, RANGE, RANGE_META8, LIST, BUILTIN,
38 };
39
40 KeySym keysym;
41 /* only the lower 8 bits of state are used for matching according to X.h */
42 /* the higher bits are preserved for Meta/NumLock keys */
43 /* which are mapped to corresponding lower bits at register time */
44 uint16_t state; /* indicates each modifiers' DOWN/UP status */
45 uint16_t range; /* =1: single keysym; >1: a of range keysyms */
46 keysym_type type;
47 const char *str; /* would normally be a keycode translation in UTF-8 */
48 };
49
50 class keyboard_manager
51 {
52 public:
53 keyboard_manager ();
54 ~keyboard_manager ();
55
56 void clear ();
57 void register_user_translation (KeySym keysym, unsigned int state, const char *trans);
58 void register_done (); // call this to make newly registered keymaps take effect
59 bool dispatch (rxvt_term *term, KeySym keysym, unsigned int state);
60
61 private:
62 void register_keymap (keysym_t *key);
63 void purge_duplicate_keymap ();
64 void setup_hash ();
65 int find_keysym (KeySym keysym, unsigned int state);
66
67 private:
68 uint16_t hash[KEYSYM_HASH_BUDGETS];
69 vector<keysym_t *> keymap;
70
71 // stock keymaps are all static data
72 static keysym_t stock_keymap[];
73 // user keymaps and their .string are dynamicaly allocated and freed
74 vector<keysym_t *> user_keymap;
75 vector<const char *> user_translations;
76 };
77
78 #endif /* KEYSYM_RESOURCE */
79
80 #endif /* KEYBOARD_H_ */