repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: 84fb35a1f1e9b1b632bcce6eddbd324086ac2954:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit 84fb35a1f1e9b1b632bcce6eddbd324086ac2954
Author: Marc Lehmann 
Date:   Sat Apr 26 20:51:12 2014 +0000

    for discussion

diff --git a/src/keyboard.C b/src/keyboard.C
index acbf00766beeaa2e952efc5022c146c947bb3a20..
index ..b5c9b5a9f6bdf3abcbb97c6451fa66c915c11ad4 100644
--- a/src/keyboard.C
+++ b/src/keyboard.C
@@ -143,13 +143,15 @@ keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state,
             {
               if (strncmp (str, "command:", 8) == 0)
                 term->cmdbuf_append (str + 8, strlen (str) - 8);
+              else if (strncmp (str, "string:", 7) == 0)
+                term->tt_write (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 if (HOOK_INVOKE ((term, HOOK_KEYBOARD_DISPATCH, DT_STR_LEN, str, colon - str, DT_STR, colon + 1, DT_END)))
-                /* done */;
               else
-                term->tt_write (str, strlen (str));
+                HOOK_INVOKE ((term, HOOK_KEYBOARD_DISPATCH, DT_STR_LEN, str, colon - str, DT_STR, colon + 1, DT_END));
             }
+          else
+            term->tt_write (str, strlen (str));

           free (str);

diff --git a/src/perl/selection b/src/perl/selection
index 35ec989345bdcb5ee12cdf0091ce9e84ba906eb6..
index ..c10c26cdf57e6801fe43c0131b82d2086c299a04 100644
--- a/src/perl/selection
+++ b/src/perl/selection
@@ -64,6 +64,10 @@ sub on_user_command {
    ()
 }

+sub on_keyboard_dispatch {
+   &on_user_command;
+}
+
 sub on_init {
    my ($self) = @_;

diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
index 92ad48ce93e09a68243160e89767765809fa0cd7..
index ..72c7db3d4a76063e3ff9ccfe9445bae91982a343 100644
--- a/src/rxvtperl.xs
+++ b/src/rxvtperl.xs
@@ -795,6 +795,10 @@ BOOT:
     IV iv;
   } *civ, const_iv[] = {
 #   define const_iv(name) { # name, (IV)name }
+    const_iv (HOOK_INIT),
+    const_iv (HOOK_DESTROY),
+    const_iv (HOOK_KEYBOARD_DISPATCH),
+
     const_iv (NUM_RESOURCES),
     const_iv (DEFAULT_RSTYLE),
     const_iv (OVERLAY_RSTYLE),
diff --git a/src/urxvt.pm b/src/urxvt.pm
index d61720cda6a068097200999ba8f7c551d4d59f77..
index ..a78c8bdc17f2948d2a8f4bff4fc477fa5a91b042 100644
--- a/src/urxvt.pm
+++ b/src/urxvt.pm
@@ -669,7 +669,7 @@ sub invoke {
    local $TERM = shift;
    my $htype = shift;

-   if ($htype == 0) { # INIT
+   if ($htype == HOOK_INIT) {
       my @dirs = $TERM->perl_libdirs;

       my %ext_arg;
@@ -718,7 +718,13 @@ sub invoke {
       verbose 10, "$HOOKNAME[$htype] (" . (join ", ", $TERM, @_) . ")"
          if $verbosity >= 10;

-      for my $pkg (keys %$cb) {
+      for my $pkg (
+         # this hook is only sent to the extension with the name
+         # matching the first arg
+         $htype == HOOK_KEYBOARD_DISPATCH
+         ? exists $cb->{"urxvt::ext::$_[0]"} ? "urxvt::ext::" . shift : return undef
+         : keys %$cb
+      ) {
          my $retval_ = eval { $cb->{$pkg}->($TERM->{_pkg}{$pkg} || $TERM, @_) };
          $retval ||= $retval_;

@@ -732,7 +738,7 @@ sub invoke {
          if $verbosity >= 11;
    }

-   if ($htype == 1) { # DESTROY
+   if ($htype == HOOK_DESTROY) {
       # clear package objects
       %$_ = () for values %{ $TERM->{_pkg} };

-----END OF PAGE-----