--- rxvt-unicode/src/keyboard.C 2012/12/28 13:29:05 1.60 +++ rxvt-unicode/src/keyboard.C 2014/04/29 13:17:54 1.65 @@ -63,17 +63,6 @@ * Ni(the size of group i) = hash_bucket_size[Ii]. */ -static void -output_string (rxvt_term *term, const char *str) -{ - if (strncmp (str, "command:", 8) == 0) - term->cmdbuf_append (str + 8, strlen (str) - 8); - else if (strncmp (str, "perl:", 5) == 0) - HOOK_INVOKE((term, HOOK_USER_COMMAND, DT_STR, str + 5, DT_END)); - else - term->tt_write (str, strlen (str)); -} - // return: priority_of_a - priority_of_b static int compare_priority (keysym_t *a, keysym_t *b) @@ -115,6 +104,8 @@ if (strncmp (translation, "builtin:", 8) == 0) key->type = keysym_t::BUILTIN; + else if (strncmp (translation, "builtin-string:", 15) == 0) + key->type = keysym_t::BUILTIN_STRING; if (keymap.size () == keymap.capacity ()) keymap.reserve (keymap.size () * 2); @@ -124,7 +115,7 @@ } bool -keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state) +keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state, const char *kbuf, int len) { assert (("register_done() need to be called", hash[0] == 0)); @@ -143,14 +134,31 @@ { keysym_t *key = keymap [index]; - if (key->type != keysym_t::BUILTIN) + if (key->type == keysym_t::BUILTIN_STRING) + { + term->tt_write_user_input (kbuf, len); + return true; + } + else if (key->type != keysym_t::BUILTIN) { wchar_t *ws = rxvt_utf8towcs (key->str); char *str = rxvt_wcstombs (ws); // TODO: do (some) translations, unescaping etc, here (allow \u escape etc.) free (ws); - output_string (term, str); + if (char *colon = strchr (str, ':')) + { + if (strncmp (str, "command:", 8) == 0) + term->cmdbuf_append (str + 8, strlen (str) - 8); + else if (strncmp (str, "string:", 7) == 0) + term->tt_write_user_input (colon + 1, strlen (colon + 1)); + else if (strncmp (str, "perl:", 8) == 0) + HOOK_INVOKE ((term, HOOK_USER_COMMAND, DT_STR, colon + 1, DT_END)); + else + HOOK_INVOKE ((term, HOOK_KEYBOARD_DISPATCH, DT_STR_LEN, str, colon - str, DT_STR, colon + 1, DT_END)); + } + else + term->tt_write_user_input (str, strlen (str)); free (str);