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.62 by root, Sat Apr 26 18:53:51 2014 UTC vs.
Revision 1.68 by root, Sat May 17 15:25:04 2014 UTC

89 delete keymap [i]; 89 delete keymap [i];
90 } 90 }
91} 91}
92 92
93void 93void
94keyboard_manager::register_user_translation (KeySym keysym, unsigned int state, const wchar_t *ws) 94keyboard_manager::register_action (KeySym keysym, unsigned int state, const wchar_t *ws)
95{ 95{
96 char *translation = rxvt_wcstoutf8 (ws); 96 char *translation = rxvt_wcstoutf8 (ws);
97 97
98 keysym_t *key = new keysym_t; 98 keysym_t *key = new keysym_t;
99 99
102 key->str = translation; 102 key->str = translation;
103 key->type = keysym_t::STRING; 103 key->type = keysym_t::STRING;
104 104
105 if (strncmp (translation, "builtin:", 8) == 0) 105 if (strncmp (translation, "builtin:", 8) == 0)
106 key->type = keysym_t::BUILTIN; 106 key->type = keysym_t::BUILTIN;
107 else if (strncmp (translation, "builtin-string:", 15) == 0)
108 key->type = keysym_t::BUILTIN_STRING;
107 109
108 if (keymap.size () == keymap.capacity ()) 110 if (keymap.size () == keymap.capacity ())
109 keymap.reserve (keymap.size () * 2); 111 keymap.reserve (keymap.size () * 2);
110 112
111 keymap.push_back (key); 113 keymap.push_back (key);
130 132
131 if (index >= 0) 133 if (index >= 0)
132 { 134 {
133 keysym_t *key = keymap [index]; 135 keysym_t *key = keymap [index];
134 136
137 if (key->type == keysym_t::BUILTIN_STRING)
138 {
139 term->tt_write_user_input (kbuf, len);
140 return true;
141 }
135 if (key->type != keysym_t::BUILTIN) 142 else if (key->type != keysym_t::BUILTIN)
136 { 143 {
137 wchar_t *ws = rxvt_utf8towcs (key->str); 144 wchar_t *ws = rxvt_utf8towcs (key->str);
138 char *str = rxvt_wcstombs (ws); 145 char *str = rxvt_wcstombs (ws);
139 // TODO: do (some) translations, unescaping etc, here (allow \u escape etc.) 146 // TODO: do (some) translations, unescaping etc, here (allow \u escape etc.)
140 free (ws); 147 free (ws);
141 148
142 if (char *colon = strchr (str, ':')) 149 if (char *colon = strchr (str, ':'))
143 { 150 {
144 if (strncmp (str, "command:", 8) == 0) 151 if (strncmp (str, "command:", 8) == 0)
145 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)
154 term->tt_write_user_input (colon + 1, strlen (colon + 1));
146 else if (strncmp (str, "perl:", 8) == 0) 155 else if (strncmp (str, "perl:", 5) == 0)
147 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));
148 else if (HOOK_INVOKE ((term, HOOK_KEYBOARD_DISPATCH, DT_STR_LEN, str, colon - str, DT_STR, colon + 1, DT_END)))
149 /* done */;
150 else 157 else
151 term->tt_write (str, strlen (str)); 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));
152 } 159 }
160 else
161 term->tt_write_user_input (str, strlen (str));
153 162
154 free (str); 163 free (str);
155 164
156 return true; 165 return true;
157 } 166 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines