2 /* ======================================================================= *\
3 File : kbmap.h, kbmap.h,v 1.3 1996/12/10 04:35:57 larsbj Exp
4 Author : chb, 30.Oct.1995
6 Purpose: class definitions for XKeyEvent keymap handling
7 \* ==================================================================== */
22 #define KB_PREALLOC 16
24 #define KB_HASHSIZE 128 // yes, yes - I know. 128 is not exactly prime :-)
25 // ... but we are dealing with ASCII chars mostly.
38 /// Keymap for prefix keys
41 /// Action for !prefix keys
46 /// Defines key maps and actions for key sequences
57 /// Bind a key-sequence to an action
58 /** Returns 0 on success. Otherwise, position in string where
60 int bind(char const * seq, int action);
63 void print(string & buf) const;
65 /// Look up a key in the keymap
66 int lookup(KeySym key, unsigned mod, kb_sequence * seq);
68 /// Given an action, find all keybindings.
69 string findbinding(int action) const;
71 /// Define a new key sequence
72 int defkey(kb_sequence * seq, int action, int idx = 0);
74 /// Size of the table (<0: hashtab)
77 /// Holds the defined keys
78 /** Both kinds of tables ends with NoSymbol */
83 /// Table for linear array
86 /// Hash table holding key lists
93 /// Holds a key sequence and the current and standard keymaps
100 modifiers = staticmod;
111 if (sequence != staticseq) {
117 /// Add a key to the key sequence and look it up in the curmap
118 /** Add a key to the key sequence and look it up in the curmap
119 if the latter is defined. */
120 int addkey(KeySym key, unsigned mod, unsigned nmod = 0);
123 int print(string & buf, bool when_defined = false) const;
126 int printOptions(string & buf) const;
128 /// Make length negative to mark the sequence as deleted
141 int parse(char const * s);
143 /// Keymap to use if a new sequence is starting
146 /// Keymap to use for the next key
149 /// Array holding the current key sequence
150 /** If sequence[length-1] < 0xff it can be used as ISO8859 char */
151 unsigned int * sequence;
154 unsigned int * modifiers;
156 /// Current length of key sequence
160 /// Static array preallocated for sequence
161 unsigned int staticseq[KB_PREALLOC];
164 unsigned int staticmod[KB_PREALLOC];
166 /// Physically allocated storage size