ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/keyboard.C
(Generate patch)

Comparing rxvt-unicode/src/keyboard.C (file contents):
Revision 1.11 by root, Sun Feb 6 15:18:01 2005 UTC vs.
Revision 1.13 by root, Thu Feb 24 13:01:01 2005 UTC

6#include <cstring> 6#include <cstring>
7 7
8#include "keyboard.h" 8#include "keyboard.h"
9#include "command.h" 9#include "command.h"
10 10
11/* an intro to the data structure:
12 *
13 * vector keymap[] is grouped.
14 *
15 * inside each group, elements are sorted by the criteria given by compare_priority().
16 * the lookup of keysym is done in two steps:
17 * 1) locate the group corresponds to the keysym;
18 * 2) do a linear search inside the group.
19 *
20 * array hash[] effectively defines a map from a keysym to a group in keymap[].
21 *
22 * each group has its address(the index of first group element in keymap[]),
23 * which is computed and stored in hash[].
24 * hash[] stores the addresses in the form of:
25 * index: 0 I1 I2 I3 In
26 * value: 0...0, A1...A1, A2...A2, A3...A3, ..., An...An
27 * where
28 * A1 = 0;
29 * Ai+1 = N1 + N2 + ... + Ni.
30 * it is computed from hash_budget_size[]:
31 * index: 0 I1 I2 I3 In
32 * value: 0...0, N1, 0...0, N2, 0...0, N3, ..., Nn, 0...0
33 * 0...0, 0.......0, N1.....N1, N1+N2...N1+N2, ... (the compution of hash[])
34 * or we can say
35 * hash_budget_size[Ii] = Ni; hash_budget_size[elsewhere] = 0,
36 * where
37 * set {I1, I2, ..., In} = { hashkey of keymap[0]->keysym, ..., keymap[keymap.size-1]->keysym }
38 * where hashkey of keymap[i]->keysym = keymap[i]->keysym & KEYSYM_HASH_MASK
39 * n(the number of groups) = the number of non-zero member of hash_budget_size[];
40 * Ni(the size of group i) = hash_budget_size[Ii].
41 */
42
43#if STOCK_KEYMAP
11//////////////////////////////////////////////////////////////////////////////// 44////////////////////////////////////////////////////////////////////////////////
12// default keycode translation map and keyevent handlers 45// default keycode translation map and keyevent handlers
13 46
14keysym_t keyboard_manager::stock_keymap[] = { 47keysym_t keyboard_manager::stock_keymap[] = {
15 /* examples */ 48 /* examples */
32//{ '.', ControlMask, 1, keysym_t::NORMAL, "\033<C-.>"}, 65//{ '.', ControlMask, 1, keysym_t::NORMAL, "\033<C-.>"},
33//{ '0', ControlMask, 10, keysym_t::RANGE, "0" "\033<C-%c>"}, 66//{ '0', ControlMask, 10, keysym_t::RANGE, "0" "\033<C-%c>"},
34//{ '0', MetaMask|ControlMask, 10, keysym_t::RANGE, "0" "\033<M-C-%c>"}, 67//{ '0', MetaMask|ControlMask, 10, keysym_t::RANGE, "0" "\033<M-C-%c>"},
35//{ 'a', MetaMask|ControlMask, 26, keysym_t::RANGE, "a" "\033<M-C-%c>"}, 68//{ 'a', MetaMask|ControlMask, 26, keysym_t::RANGE, "a" "\033<M-C-%c>"},
36}; 69};
70#endif
37 71
38static void 72static void
39output_string (rxvt_term *rt, const char *str) 73output_string (rxvt_term *rt, const char *str)
40{ 74{
41 if (strncmp (str, "command:", 8) == 0) 75 if (strncmp (str, "command:", 8) == 0)
207} 241}
208 242
209void 243void
210keyboard_manager::register_done () 244keyboard_manager::register_done ()
211{ 245{
246#if STOCK_KEYMAP
212 unsigned int i, n = sizeof (stock_keymap) / sizeof (keysym_t); 247 int n = sizeof (stock_keymap) / sizeof (keysym_t);
213 248
249 //TODO: shield against repeated calls and empty keymap
214 if (keymap.back () != &stock_keymap[n - 1]) 250 //if (keymap.back () != &stock_keymap[n - 1])
215 for (i = 0; i < n; ++i) 251 for (int i = 0; i < n; ++i)
216 register_keymap (&stock_keymap[i]); 252 register_keymap (&stock_keymap[i]);
253#endif
217 254
218 purge_duplicate_keymap (); 255 purge_duplicate_keymap ();
219 256
220 setup_hash (); 257 setup_hash ();
221} 258}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines