… | |
… | |
6 | * Copyright (c) 2005 WU Fengguang |
6 | * Copyright (c) 2005 WU Fengguang |
7 | * Copyright (c) 2005-2006 Marc Lehmann <schmorp@schmorp.de> |
7 | * Copyright (c) 2005-2006 Marc Lehmann <schmorp@schmorp.de> |
8 | * |
8 | * |
9 | * This program is free software; you can redistribute it and/or modify |
9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by |
10 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or |
11 | * the Free Software Foundation; either version 3 of the License, or |
12 | * (at your option) any later version. |
12 | * (at your option) any later version. |
13 | * |
13 | * |
14 | * This program is distributed in the hope that it will be useful, |
14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
… | |
… | |
89 | delete keymap [i]; |
89 | delete keymap [i]; |
90 | } |
90 | } |
91 | } |
91 | } |
92 | |
92 | |
93 | void |
93 | void |
94 | keyboard_manager::register_user_translation (KeySym keysym, unsigned int state, const wchar_t *ws) |
94 | keyboard_manager::register_action (KeySym keysym, unsigned int state, const wchar_t *ws) |
95 | { |
95 | { |
96 | char *translation = rxvt_wcstoutf8 (ws); |
96 | char *action = rxvt_wcstoutf8 (ws); |
97 | |
97 | |
98 | keysym_t *key = new keysym_t; |
98 | keysym_t *key = new keysym_t; |
99 | |
99 | |
100 | key->keysym = keysym; |
100 | key->keysym = keysym; |
101 | key->state = state; |
101 | key->state = state; |
102 | key->str = translation; |
102 | key->str = action; |
103 | key->type = keysym_t::STRING; |
103 | key->type = keysym_t::STRING; |
104 | |
104 | |
105 | if (strncmp (translation, "builtin:", 8) == 0) |
105 | if (strncmp (action, "builtin:", 8) == 0) |
106 | key->type = keysym_t::BUILTIN; |
106 | key->type = keysym_t::BUILTIN; |
107 | else if (strncmp (translation, "builtin-string:", 15) == 0) |
107 | else if (strncmp (action, "builtin-string:", 15) == 0) |
108 | key->type = keysym_t::BUILTIN_STRING; |
108 | key->type = keysym_t::BUILTIN_STRING; |
109 | |
109 | |
110 | if (keymap.size () == keymap.capacity ()) |
110 | if (keymap.size () == keymap.capacity ()) |
111 | keymap.reserve (keymap.size () * 2); |
111 | keymap.reserve (keymap.size () * 2); |
112 | |
112 | |
… | |
… | |
150 | { |
150 | { |
151 | if (strncmp (str, "command:", 8) == 0) |
151 | if (strncmp (str, "command:", 8) == 0) |
152 | term->cmdbuf_append (str + 8, strlen (str) - 8); |
152 | term->cmdbuf_append (str + 8, strlen (str) - 8); |
153 | else if (strncmp (str, "string:", 7) == 0) |
153 | else if (strncmp (str, "string:", 7) == 0) |
154 | term->tt_write_user_input (colon + 1, strlen (colon + 1)); |
154 | term->tt_write_user_input (colon + 1, strlen (colon + 1)); |
155 | else if (strncmp (str, "perl:", 8) == 0) |
155 | else if (strncmp (str, "perl:", 5) == 0) |
156 | HOOK_INVOKE ((term, HOOK_USER_COMMAND, DT_STR, colon + 1, DT_END)); |
156 | HOOK_INVOKE ((term, HOOK_USER_COMMAND, DT_STR, colon + 1, DT_END)); |
157 | else |
157 | else |
158 | HOOK_INVOKE ((term, HOOK_KEYBOARD_DISPATCH, DT_STR_LEN, str, colon - str, DT_STR, colon + 1, DT_END)); |
158 | HOOK_INVOKE ((term, HOOK_ACTION, DT_STR_LEN, str, colon - str, DT_STR, colon + 1, DT_INT, 0, DT_STR_LEN, kbuf, len, DT_END)); |
159 | } |
159 | } |
160 | else |
160 | else |
161 | term->tt_write_user_input (str, strlen (str)); |
161 | term->tt_write_user_input (str, strlen (str)); |
162 | |
162 | |
163 | free (str); |
163 | free (str); |