-- 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: eadc87340e98f56fb499e514708163cde40dbb01: path_to: revision_to:
commit eadc87340e98f56fb499e514708163cde40dbb01 Author: Marc Lehmann <schmorp@schmorp.de> Date: Sat May 17 15:25:04 2014 +0000 *** empty log message *** diff --git a/src/hookinc.h b/src/hookinc.h
--- a/src/hookinc.h +++ b/src/hookinc.h @@ -25,7 +25,7 @@ def (REFRESH_END) def (REGISTER_COMMAND) - def (KEYBOARD_DISPATCH) + def (ACTION) def (USER_COMMAND) def (ROOT_EVENT) diff --git a/src/keyboard.C b/src/keyboard.C
--- a/src/keyboard.C +++ b/src/keyboard.C @@ -155,7 +155,7 @@ keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state, else if (strncmp (str, "perl:", 5) == 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)); + 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)); } else term->tt_write_user_input (str, strlen (str)); diff --git a/src/perl/searchable-scrollback b/src/perl/searchable-scrollback
--- a/src/perl/searchable-scrollback +++ b/src/perl/searchable-scrollback @@ -3,7 +3,7 @@ # this extension implements scrollback buffer search #:META:RESOURCE:%:string:activation hotkey keysym -#:META:KEYSYM:M-s:searchable-scrollback:start +#:META:BINDING:M-s:start =head1 NAME @@ -35,20 +35,21 @@ See L<perlre> for more info about perl regular expression syntax. sub on_init { my ($self) = @_; + # only for backwards compatibility my $hotkey = $self->{argv}[0] || $self->x_resource ("%") || "M-s"; - $self->parse_keysym ($hotkey, "perl:searchable-scrollback:start") + $self->bind_action ($hotkey, "searchable-scrollback:start") # ugh or warn "unable to register '$hotkey' as scrollback search start hotkey\n"; () } -sub on_user_command { - my ($self, $cmd) = @_; +sub on_action { + my ($self, $action) = @_; - $cmd eq "searchable-scrollback:start" + $action eq "start" and $self->enter; () diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
--- a/src/rxvtperl.xs +++ b/src/rxvtperl.xs @@ -797,7 +797,7 @@ BOOT: # define const_iv(name) { # name, (IV)name } const_iv (HOOK_INIT), const_iv (HOOK_DESTROY), - const_iv (HOOK_KEYBOARD_DISPATCH), + const_iv (HOOK_ACTION), const_iv (NUM_RESOURCES), const_iv (DEFAULT_RSTYLE), diff --git a/src/urxvt.pm b/src/urxvt.pm
--- a/src/urxvt.pm +++ b/src/urxvt.pm @@ -559,7 +559,7 @@ sub parse_resource { $name =~ y/-/./ if $isarg; - $term->scan_meta; + $term->scan_extensions; my $r = $term->{meta}{resource}; keys %$r; # reset iterator @@ -589,7 +589,7 @@ sub parse_resource { sub usage { my ($term, $usage_type) = @_; - $term->scan_meta; + $term->scan_extensions; my $r = $term->{meta}{resource}; @@ -663,6 +663,8 @@ sub invoke { if ($htype == HOOK_INIT) { my @dirs = $TERM->perl_libdirs; + $TERM->scan_extensions; + my %ext_arg; { @@ -709,13 +711,20 @@ sub invoke { verbose 10, "$HOOKNAME[$htype] (" . (join ", ", $TERM, @_) . ")" if $verbosity >= 10; - for my $pkg ( + if ($htype == HOOK_ACTION) { # 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 $pkg = shift; + $pkg =~ y/-/_/; + $pkg = "urxvt::ext::$pkg"; + + $cb = $cb->{$pkg} + or return undef; #TODO: maybe warn user? + + $cb = { $pkg => $cb }; + } + + for my $pkg (keys %$cb) { my $retval_ = eval { $cb->{$pkg}->($TERM->{_pkg}{$pkg} || $TERM, @_) }; $retval ||= $retval_; @@ -1064,8 +1073,12 @@ sub perl_libdirs { "$LIBDIR/perl" } -sub scan_meta { +# scan for available extensions and collect their metadata +sub scan_extensions { my ($self) = @_; + + return if exists $self->{meta}; + my @libdirs = perl_libdirs $self; return if $self->{meta_libdirs} eq join "\x00", @libdirs; @@ -1075,6 +1088,9 @@ sub scan_meta { $self->{meta_libdirs} = join "\x00", @libdirs; $self->{meta} = \%meta; + my %ext; + + # first gather extensions for my $dir (reverse @libdirs) { opendir my $fh, $dir or next; @@ -1083,23 +1099,37 @@ sub scan_meta { and open my $fh, "<", "$dir/$ext" or next; + my %ext = (dir => $dir); + while (<$fh>) { - if (/^#:META:X_RESOURCE:(.*)/) { + if (/^#:META:(?:X_)?RESOURCE:(.*)/) { my ($pattern, $type, $desc) = split /:/, $1; $pattern =~ s/^%(\.|$)/$ext$1/g; # % in pattern == extension name if ($pattern =~ /[^a-zA-Z0-9\-\.]/) { warn "$dir/$ext: meta resource '$pattern' contains illegal characters (not alphanumeric nor . nor *)\n"; } else { - $meta{resource}{$pattern} = [$ext, $type, $desc]; + $ext{resource}{$pattern} = [$ext, $type, $desc]; } + } elsif (/^#:META:BINDING:(.*)/) { + my ($keysym, $action) = split /:/, $1; + $ext{binding}{$keysym} = $action; } elsif (/^\s*(?:#|$)/) { # skip other comments and empty lines } else { last; # stop parsing on first non-empty non-comment line } } + + $meta{$ext} = \%ext; } } + + # and now merge resources and bindings + while (my ($k, $v) = each %ext) { + #TODO: should check for extensions overriding each other + %{ $meta{resource} } = (%{ $meta{resource} }, %{ $v->{resource} }); + %{ $meta{binding} } = (%{ $meta{binding} }, %{ $v->{binding} }); + } } =item $term = new urxvt::term $envhashref, $rxvtname, [arg...] @@ -1256,7 +1286,7 @@ sub x_resource_boolean { =item $success = $term->bind_action ($key, $octets) -Adds a key binding exactly as specified via a resource. See the +Adds a key binding exactly as specified via a C<keysym> resource. See the C<keysym> resource in the urxvt(1) manpage. =item $rend = $term->rstyle ([$new_rstyle]) @@ -1448,6 +1478,14 @@ Write the octets given in C<$octets> to the tty (i.e. as program input). To pass characters instead of octets, you should convert your strings first to the locale-specific encoding using C<< $term->locale_encode >>. +=item $term->tt_write_user_input ($octets) + +Like C<tt_write>, but should be used when writing strings in response to +the user pressing a key, to invokes the additional actions requested by +the user for that case (C<tt_write> doesn't do that). + +The typical use case would be inside C<on_action> hooks. + =item $term->tt_paste ($octets) Write the octets given in C<$octets> to the tty as a paste, converting NL to
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 13:19:23 2024