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 \* ==================================================================== */
20 #define KB_PREALLOC 16
21 #define KB_HASHSIZE 128 // yes, yes - I know. 128 is not exactly prime :-)
22 // ... but we are dealing with ASCII chars mostly.
35 /// Keymap for prefix keys
38 /// Action for !prefix keys
43 /// Defines key maps and actions for key sequences
54 /// Bind a key-sequence to an action
55 /** Returns 0 on success. Otherwise, position in string where
57 int bind(char const* seq
, int action
);
60 int print(char* buf
, int maxlen
) const;
62 /// Look up a key in the keymap
63 int lookup(KeySym key
, unsigned mod
, kb_sequence
*seq
);
65 /// Given an action, find all keybindings.
66 string
findbinding(int action
) const;
68 /// Define a new key sequence
69 int defkey(kb_sequence
*seq
, int action
, int idx
= 0);
71 /// Size of the table (<0: hashtab)
74 /// Holds the defined keys
75 /** Both kinds of tables ends with NoSymbol */
78 /// Table for linear array
81 /// Hash table holding key lists
87 /// Holds a key sequence and the current and standard keymaps
94 modifiers
= staticmod
;
105 if (sequence
!= staticseq
) {
111 /// Add a key to the key sequence and look it up in the curmap
112 /** Add a key to the key sequence and look it up in the curmap
113 if the latter is defined. */
114 int addkey(KeySym key
, unsigned mod
, unsigned nmod
= 0);
117 int print(char *buf
, int maxlen
, bool when_defined
= false) const; //RVDK_PATCH_5
120 int printOptions(char *buf
, int maxlen
) const;
122 /// Make length negative to mark the sequence as deleted
135 int parse(char const *s
);
137 /// Keymap to use if a new sequence is starting
140 /// Keymap to use for the next key
143 /// Array holding the current key sequence
144 /** If sequence[length-1] < 0xff it can be used as ISO8859 char */
145 unsigned int *sequence
;
148 unsigned int *modifiers
;
150 /// Current length of key sequence
154 /// Static array preallocated for sequence
155 unsigned int staticseq
[KB_PREALLOC
];
158 unsigned int staticmod
[KB_PREALLOC
];
160 /// Physically allocated storage size