ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/keyboard.h
Revision: 1.6
Committed: Mon Jan 9 22:41:41 2006 UTC (18 years, 4 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-7_3, rel-7_2, rel-7_1, rel-7_0, rel-7_6, rel-7_5, rel-7_4, rel-7_3a
Changes since 1.5: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #ifndef KEYBOARD_H_
2     #define KEYBOARD_H_
3    
4 root 1.5 #ifdef KEYSYM_RESOURCE
5    
6 root 1.2 #include <inttypes.h>
7    
8 root 1.1 #include "feature.h"
9     #include "rxvtutil.h"
10    
11 root 1.2 #define KEYSYM_HASH_BITS 4 /* lowest #bits of keysym is used as hash key */
12 root 1.1 #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 root 1.2 #define AppKeypadMask 0x0400
18 root 1.3 #define Level3Mask 0x0800 // currently not supported
19 root 1.2 #define OtherModMask (ShiftMask | LockMask | ControlMask \
20 root 1.1 | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask)
21    
22 root 1.3 #if OtherModMask > 0xff
23     # error FATAL: X modifiers might clash with rxvt-unicode ones
24 root 1.1 #endif
25    
26     struct rxvt_term;
27     struct keysym_t;
28 root 1.2
29 root 1.1 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 root 1.2 enum keysym_type {
37 root 1.6 STRING, RANGE, RANGE_META8, LIST, BUILTIN,
38 root 1.2 };
39    
40     KeySym keysym;
41 root 1.1 /* 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 root 1.2 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 root 1.1 };
49    
50     class keyboard_manager
51     {
52     public:
53 root 1.2 keyboard_manager ();
54 root 1.1 ~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 root 1.2 bool dispatch (rxvt_term *term, KeySym keysym, unsigned int state);
60 root 1.1
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 root 1.2 uint16_t hash[KEYSYM_HASH_BUDGETS];
69     vector<keysym_t *> keymap;
70 root 1.1
71     // stock keymaps are all static data
72 root 1.2 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 root 1.1 };
77    
78     #endif /* KEYSYM_RESOURCE */
79 root 1.5
80 root 1.1 #endif /* KEYBOARD_H_ */