-- 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:

git.thebackupbox.net

rxvt-unicode-sixel

git://git.thebackupbox.net/rxvt-unicode-sixel

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

index 18b5c89b580f27a889189ab57697e539c8613481..

index ..90ed8c588c6cf20a7231e75118cd9738cdfb9d71 100644

--- 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

index e709cd41a2c212c62989f19ace488e35c685a142..

index ..0ad9bd0705b749195b6ca7db8db3d35132b83b39 100644

--- 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

index b27508c038810a892a8881a140ed087911121add..

index ..27708ab6f9108745efbea64b8fb06041243a329f 100644

--- 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

index 71e9a8524f24d6059c02dea880f47094daf5cbad..

index ..915106021a1aecc98ba5f8fe665786ac059645fd 100644

--- 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

index 18414d6741bc9d46d36927e3aa4bc8c40b3f161c..

index ..851be2e10c29941bc3be1496bfbb06404797f68d 100644

--- 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

index b9e4f9751f54d5451d8acaa5377ee09baa763d4a..

index ..79912be0afed75912dd0cdb171c2f4f327a45c30 100644

--- 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