… | |
… | |
61 | * where hashkey of keymap[i]->keysym = keymap[i]->keysym & KEYSYM_HASH_MASK |
61 | * where hashkey of keymap[i]->keysym = keymap[i]->keysym & KEYSYM_HASH_MASK |
62 | * n(the number of groups) = the number of non-zero member of hash_bucket_size[]; |
62 | * n(the number of groups) = the number of non-zero member of hash_bucket_size[]; |
63 | * Ni(the size of group i) = hash_bucket_size[Ii]. |
63 | * Ni(the size of group i) = hash_bucket_size[Ii]. |
64 | */ |
64 | */ |
65 | |
65 | |
66 | static void |
|
|
67 | output_string (rxvt_term *term, const char *str) |
|
|
68 | { |
|
|
69 | if (strncmp (str, "command:", 8) == 0) |
|
|
70 | term->cmdbuf_append (str + 8, strlen (str) - 8); |
|
|
71 | else if (strncmp (str, "perl:", 5) == 0) |
|
|
72 | HOOK_INVOKE((term, HOOK_USER_COMMAND, DT_STR, str + 5, DT_END)); |
|
|
73 | else |
|
|
74 | term->tt_write (str, strlen (str)); |
|
|
75 | } |
|
|
76 | |
|
|
77 | // return: priority_of_a - priority_of_b |
66 | // return: priority_of_a - priority_of_b |
78 | static int |
67 | static int |
79 | compare_priority (keysym_t *a, keysym_t *b) |
68 | compare_priority (keysym_t *a, keysym_t *b) |
80 | { |
69 | { |
81 | // (the more '1's in state; the less range): the greater priority |
70 | // (the more '1's in state; the less range): the greater priority |
… | |
… | |
122 | keymap.push_back (key); |
111 | keymap.push_back (key); |
123 | hash[0] = 3; |
112 | hash[0] = 3; |
124 | } |
113 | } |
125 | |
114 | |
126 | bool |
115 | bool |
127 | keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state) |
116 | keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state, const char *kbuf, int len) |
128 | { |
117 | { |
129 | assert (("register_done() need to be called", hash[0] == 0)); |
118 | assert (("register_done() need to be called", hash[0] == 0)); |
130 | |
119 | |
131 | state &= OtherModMask; // mask out uninteresting modifiers |
120 | state &= OtherModMask; // mask out uninteresting modifiers |
132 | |
121 | |
… | |
… | |
148 | wchar_t *ws = rxvt_utf8towcs (key->str); |
137 | wchar_t *ws = rxvt_utf8towcs (key->str); |
149 | char *str = rxvt_wcstombs (ws); |
138 | char *str = rxvt_wcstombs (ws); |
150 | // TODO: do (some) translations, unescaping etc, here (allow \u escape etc.) |
139 | // TODO: do (some) translations, unescaping etc, here (allow \u escape etc.) |
151 | free (ws); |
140 | free (ws); |
152 | |
141 | |
153 | output_string (term, str); |
142 | if (char *colon = strchr (str, ':')) |
|
|
143 | { |
|
|
144 | if (strncmp (str, "command:", 8) == 0) |
|
|
145 | term->cmdbuf_append (str + 8, strlen (str) - 8); |
|
|
146 | else if (strncmp (str, "string:", 7) == 0) |
|
|
147 | term->tt_write (colon + 1, strlen (colon + 1)); |
|
|
148 | else if (strncmp (str, "perl:", 8) == 0) |
|
|
149 | HOOK_INVOKE ((term, HOOK_USER_COMMAND, DT_STR, colon + 1, DT_END)); |
|
|
150 | else |
|
|
151 | HOOK_INVOKE ((term, HOOK_KEYBOARD_DISPATCH, DT_STR_LEN, str, colon - str, DT_STR, colon + 1, DT_END)); |
|
|
152 | } |
|
|
153 | else |
|
|
154 | term->tt_write (str, strlen (str)); |
154 | |
155 | |
155 | free (str); |
156 | free (str); |
156 | |
157 | |
157 | return true; |
158 | return true; |
158 | } |
159 | } |