--- rxvt-unicode/src/keyboard.h 2005/01/16 15:59:45 1.1 +++ rxvt-unicode/src/keyboard.h 2006/01/02 15:35:43 1.5 @@ -1,55 +1,62 @@ #ifndef KEYBOARD_H_ #define KEYBOARD_H_ +#ifdef KEYSYM_RESOURCE + +#include + #include "feature.h" #include "rxvtutil.h" -#ifdef KEYSYM_RESOURCE - -#define KEYSYM_HASH_BITS 9 /* lowest #bits of keysym is used as hash key */ +#define KEYSYM_HASH_BITS 4 /* lowest #bits of keysym is used as hash key */ #define KEYSYM_HASH_BUDGETS (1< 0xff +# error FATAL: X modifiers might clash with rxvt-unicode ones #endif struct rxvt_term; struct keysym_t; + typedef void (keyevent_handler) (rxvt_term *rt, keysym_t *key, KeySym keysym, unsigned int state); -typedef unsigned short u16; struct keysym_t { - KeySym keysym; + enum keysym_type { + NORMAL, RANGE, RANGE_META8, LIST, BUILTIN, + }; + + KeySym keysym; /* only the lower 8 bits of state are used for matching according to X.h */ /* the higher bits are preserved for Meta/NumLock keys */ /* which are mapped to corresponding lower bits at register time */ - u16 state; /* indicates each modifiers' DOWN/UP status */ - u16 range; /* =1: single keysym; >1: a of range keysyms */ - keyevent_handler *handler; /* event handler */ - const char *str; /* would normally be a keycode translation */ + uint16_t state; /* indicates each modifiers' DOWN/UP status */ + uint16_t range; /* =1: single keysym; >1: a of range keysyms */ + keysym_type type; + const char *str; /* would normally be a keycode translation in UTF-8 */ }; - class keyboard_manager { public: - keyboard_manager (rxvt_term *rt); + keyboard_manager (); ~keyboard_manager (); void clear (); void register_user_translation (KeySym keysym, unsigned int state, const char *trans); void register_done (); // call this to make newly registered keymaps take effect - bool dispatch (KeySym keysym, unsigned int state); + bool dispatch (rxvt_term *term, KeySym keysym, unsigned int state); private: void register_keymap (keysym_t *key); @@ -58,18 +65,16 @@ int find_keysym (KeySym keysym, unsigned int state); private: - rxvt_term * const term_; - - u16 hash_[KEYSYM_HASH_BUDGETS]; // - vector keymap_; + uint16_t hash[KEYSYM_HASH_BUDGETS]; + vector keymap; // stock keymaps are all static data - static keysym_t stock_keymap_[]; - // user keymaps and their .string are dynamicly allocated and freed - vector user_keymap_; - vector user_translations_; + static keysym_t stock_keymap[]; + // user keymaps and their .string are dynamicaly allocated and freed + vector user_keymap; + vector user_translations; }; #endif /* KEYSYM_RESOURCE */ + #endif /* KEYBOARD_H_ */ -// vim:et:ts=2:sw=2