… | |
… | |
98 | hash [0] = 1; // hash[0] != 0 indicates uninitialized data |
98 | hash [0] = 1; // hash[0] != 0 indicates uninitialized data |
99 | } |
99 | } |
100 | |
100 | |
101 | keyboard_manager::~keyboard_manager () |
101 | keyboard_manager::~keyboard_manager () |
102 | { |
102 | { |
103 | hash [0] = 2; |
|
|
104 | |
|
|
105 | for (unsigned int i = 0; i < keymap.size (); ++i) |
103 | for (unsigned int i = 0; i < keymap.size (); ++i) |
106 | { |
104 | { |
107 | free (keymap [i]->str); |
105 | free (keymap [i]->str); |
108 | delete keymap [i]; |
106 | delete keymap [i]; |
109 | keymap [i] = 0; |
|
|
110 | } |
107 | } |
111 | |
|
|
112 | keymap.clear (); |
|
|
113 | } |
108 | } |
114 | |
109 | |
115 | // a wrapper for register_translation that converts the input string |
110 | // a wrapper for register_translation that converts the input string |
116 | // to utf-8 and expands 'list' syntax. |
111 | // to utf-8 and expands 'list' syntax. |
117 | void |
112 | void |
118 | keyboard_manager::register_user_translation (KeySym keysym, unsigned int state, const char *trans) |
113 | keyboard_manager::register_user_translation (KeySym keysym, unsigned int state, const char *trans) |
119 | { |
114 | { |
120 | wchar_t *wc = rxvt_mbstowcs (trans); |
115 | wchar_t *ws = rxvt_mbstowcs (trans); |
121 | char *translation = rxvt_wcstoutf8 (wc); |
116 | char *translation = rxvt_wcstoutf8 (ws); |
122 | free (wc); |
117 | free (ws); |
123 | |
118 | |
124 | if (strncmp (translation, "list", 4) == 0 && translation [4] |
119 | if (strncmp (translation, "list", 4) == 0 && translation [4] |
125 | && strlen (translation) < STRING_MAX) |
120 | && strlen (translation) < STRING_MAX) |
126 | { |
121 | { |
127 | char *prefix = translation + 4; |
122 | char *prefix = translation + 4; |
… | |
… | |
202 | { |
197 | { |
203 | keysym_t *key = keymap [index]; |
198 | keysym_t *key = keymap [index]; |
204 | |
199 | |
205 | if (key->type != keysym_t::BUILTIN) |
200 | if (key->type != keysym_t::BUILTIN) |
206 | { |
201 | { |
207 | wchar_t *wc = rxvt_utf8towcs (key->str); |
202 | wchar_t *ws = rxvt_utf8towcs (key->str); |
208 | char *str = rxvt_wcstombs (wc); |
203 | char *str = rxvt_wcstombs (ws); |
209 | // TODO: do (some) translations, unescaping etc, here (allow \u escape etc.) |
204 | // TODO: do (some) translations, unescaping etc, here (allow \u escape etc.) |
210 | free (wc); |
205 | free (ws); |
211 | |
206 | |
212 | output_string (term, str); |
207 | output_string (term, str); |
213 | |
208 | |
214 | free (str); |
209 | free (str); |
215 | |
210 | |