-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 212dc5e079c68bfbc3689e3f23f705fc8a65688b: path_to: revision_to:
commit 212dc5e079c68bfbc3689e3f23f705fc8a65688b Author: Emanuele Giaquinta <emanuele.giaquinta@gmail.com> Date: Fri Dec 2 09:03:43 2011 +0000 Add on_register_command hook and register_command method. diff --git a/src/hookinc.h b/src/hookinc.h
--- a/src/hookinc.h +++ b/src/hookinc.h @@ -26,6 +26,7 @@ def (REFRESH_END) def (USER_COMMAND) + def (REGISTER_COMMAND) def (ROOT_EVENT) def (X_EVENT) diff --git a/src/init.C b/src/init.C
--- a/src/init.C +++ b/src/init.C @@ -647,6 +647,10 @@ rxvt_term::init_resources (int argc, const char *const *argv) } #endif + // must be called after initialising the perl interpreter as it + // may invoke the `on_register_command' hook + extract_keysym_resources (); + /* * set any defaults not already set */ diff --git a/src/rxvt.h b/src/rxvt.h
--- a/src/rxvt.h +++ b/src/rxvt.h @@ -1575,6 +1575,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen int parse_keysym (const char *str, const char *arg); const char *x_resource (const char *name); void extract_resources (); + void extract_keysym_resources (); }; #endif /* _RXVT_H_ */ diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
--- a/src/rxvtperl.xs +++ b/src/rxvtperl.xs @@ -1586,6 +1586,13 @@ rxvt_term::parse_keysym (char *keysym, char *str) OUTPUT: RETVAL +void +rxvt_term::register_command (int keysym, unsigned int state, SV *str) + CODE: + wchar_t *wstr = sv2wcs (str); + THIS->keyboard->register_user_translation (keysym, state, wstr); + free (wstr); + void rxvt_term::screen_cur (...) PROTOTYPE: $;$$ diff --git a/src/urxvt.pm b/src/urxvt.pm
--- a/src/urxvt.pm +++ b/src/urxvt.pm @@ -674,6 +674,13 @@ resource in the @@RXVT_NAME@@(1) manpage). The event is simply the action string. This interface is assumed to change slightly in the future. +=item on_register_command $term, $keysym, $modifiermask, $string + +Called after parsing a keysym resource but before registering the +associated binding. If this hook returns TRUE the binding is not +registered. It can be used to modify a binding by calling +C<register_command>. + =item on_resize_all_windows $term, $new_width, $new_height Called just after the new window size has been calculated, but before @@ -1395,6 +1402,13 @@ the wrong resources. Adds a key binding exactly as specified via a resource. See the C<keysym> resource in the @@RXVT_NAME@@(1) manpage. +=item $term->register_command ($keysym, $modifiermask, $string) + +Adds a key binding. This is a lower level api compared to +C<parse_keysym>, as it expects a parsed key description, and can be +used only inside either the C<on_init> hook, to add a binding, or the +C<on_register_command> hook, to modify a parsed binding. + =item $rend = $term->rstyle ([$new_rstyle]) Return and optionally change the current rendition. Text that is output by diff --git a/src/xdefaults.C b/src/xdefaults.C
--- a/src/xdefaults.C +++ b/src/xdefaults.C @@ -693,7 +693,8 @@ rxvt_term::parse_keysym (const char *str, const char *arg) } wchar_t *ws = rxvt_mbstowcs (arg); - keyboard->register_user_translation (sym, state, ws); + if (!HOOK_INVOKE ((this, HOOK_REGISTER_COMMAND, DT_INT, sym, DT_INT, state, DT_WCS_LEN, ws, wcslen (ws), DT_END))) + keyboard->register_user_translation (sym, state, ws); free (ws); return 1; } @@ -777,11 +778,18 @@ rxvt_term::extract_resources () } } } +#endif /* NO_RESOURCES */ +} +void +rxvt_term::extract_keysym_resources () +{ +#ifndef NO_RESOURCES /* * [R5 or later]: enumerate the resource database */ # ifdef KEYSYM_RESOURCE + XrmDatabase database = XrmGetDatabase (dpy); XrmName name_prefix[3]; XrmClass class_prefix[3];
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 13:56:33 2024