repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: c1fd9a112e6da1639699bdf79e26bfb6f389e73d: path_to: revision_to:
commit c1fd9a112e6da1639699bdf79e26bfb6f389e73d Author: Marc LehmannDate: Sat Jul 24 11:58:27 2021 +0000 *** empty log message *** diff --git a/Changes b/Changes
--- a/Changes
+++ b/Changes
@@ -46,6 +46,8 @@ TODO: think about daemon delaying urxvt client exit.
IDEA: use harfbuzz to render combining sequences, maybe also complex scripts
TODO: https://github.com/bbidulock/icewm/issues/492 urxvt wrongfully(?) needa configurenotify after mapwindow? also, black border?
+ - enable confirm-paste extension by default, can be disabled by e.g.
+ URxvt.perl-ext: -confirm-paste
- Key bindings specified with the -keysym option or with resources of
the form URxvt*keysym work again. Such resources, as opposed to
resources of the form URxvt.keysym, were not officially allowed but
@@ -57,13 +59,6 @@ TODO: https://github.com/bbidulock/icewm/issues/492 urxvt wrongfully(?) needa co
abuse these sequences (typically in the name of security, but these
sequences are not improving security). Also, bracketed paste mode
is now under frills.
- - enable confirm-paste extension by default, can be disabled by e.g.
- URxvt.perl-ext: -confirm-paste
- - The view_start perl method now scrolls to the bottom also when the
- argument is greater than 0.
- - eval scroll actions now scroll to the bottom when scrolling down and
- there are less lines to scroll than the ones requested (reported by
- Stephen Talley).
- if urxvt cannot detect a good estimate for font width (because a font does
not contain latin characters at all for example), it will now fall
back to xft's max_advance_width, which works well with some fonts. It
@@ -83,6 +78,16 @@ TODO: https://github.com/bbidulock/icewm/issues/492 urxvt wrongfully(?) needa co
some cases (e.g. input mono).
- when checking for overlap/careful handling, take non-basefont
character shifts into account.
+ - extensions can now request autoloading on OSC and Perl OSC sequences,
+ implement this for the background, clipboard-osc and overlay-osc
+ extensions.
+ - the background extension will now be autoloaded when the OSC 20 or 705
+ sequence is received.
+ - The view_start perl method now scrolls to the bottom also when the
+ argument is greater than 0.
+ - eval scroll actions now scroll to the bottom when scrolling down and
+ there are less lines to scroll than the ones requested (reported by
+ Stephen Talley).
- allow perl-ext and perl-ext-common to override autoloaded extensions.
this allows tabbed to disable itself in subtabs, avoiding recursive
loading.
@@ -98,6 +103,9 @@ TODO: https://github.com/bbidulock/icewm/issues/492 urxvt wrongfully(?) needa co
- do not specify< indentation with =over in pod, this is no longer
needed with semi-modern pod tools and gives the formatter more
stylistic freedom.
+ - background extension did not set thre "size-sensitive" flag
+ when repeat mode wasn't normal.
+ - extensions are now subjected to "use strict 'subs'".
9.26 Fri May 14 19:14:14 CEST 2021
- ev_iouring.c was wrongly required during compilation, and wrongly
diff --git a/src/perl/background b/src/perl/background
--- a/src/perl/background
+++ b/src/perl/background
@@ -13,6 +13,8 @@
#:META:RESOURCE:shading:number:shade background by number %
#:META:RESOURCE:blr:HxV:gaussian-blur background with radii
#:META:RESOURCE:blurRadius:HxV:gaussian-blur background with radii
+#:META:OSC:20:change/query background image
+#:META:OSC:705:change transparent background tint colour
=head1 NAME
@@ -1347,7 +1349,7 @@ sub recalculate {
my $img = urxvt::bgdsl::merge @img;
- $frame->[FR_AGAIN]{size} = 1
+ $frame->[urxvt::bgdsl::FR_AGAIN]{size} = 1
if $img->repeat_mode != urxvt::RepeatNormal;
# if the expression is sensitive to external events, prepare reevaluation then
diff --git a/src/perl/clipboard-osc b/src/perl/clipboard-osc
--- a/src/perl/clipboard-osc +++ b/src/perl/clipboard-osc @@ -1,5 +1,7 @@ #! perl +#:META:OSC_PERL:clipboard:man clipboard-osc + =head1 NAME clipboard-osc - implement the clipboard operating system command sequence diff --git a/src/perl/overlay-osc b/src/perl/overlay-osc
--- a/src/perl/overlay-osc +++ b/src/perl/overlay-osc @@ -1,5 +1,7 @@ #! perl +#:META:OSC_PERL:overlay:man overlay-osc + =head1 NAME overlay-osc - implement OSC to manage overlays diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
--- a/src/rxvtperl.xs
+++ b/src/rxvtperl.xs
@@ -823,6 +823,8 @@ BOOT:
const_iv (HOOK_INIT),
const_iv (HOOK_DESTROY),
const_iv (HOOK_ACTION),
+ const_iv (HOOK_OSC_SEQ),
+ const_iv (HOOK_OSC_SEQ_PERL),
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 @@ -22,8 +22,8 @@ urxvtperl - rxvt-unicode's embedded perl interpreter Every time a terminal object gets created, extension scripts specified via the Cresource are loaded and associated with it. -Scripts are compiled in a 'use strict "vars"' and 'use utf8' environment, and -thus must be encoded as UTF-8. +Scripts are compiled in a 'use strict qw(vars subs)' and 'use utf8' +environment, and thus must be encoded as UTF-8. Each script will only ever be loaded once, even in urxvtd, where scripts will be shared (but not enabled) for all terminals. @@ -121,7 +121,9 @@ different types of metadata. These comments are scanned whenever a terminal is created and are typically used to autoload extensions when their resources or command line parameters are used. -Currently, it recognises only one such comment: +Currently, it recognises these comments below. Individual components are +separated by cololns (C<:>), and shoudl not contain colons themselves - +there is also currently no escaping mechanism provided for this. =over @@ -134,6 +136,51 @@ or C , and C is the resource description. The extension will be autoloaded when this resource is specified or used as a command line parameter. +Example: matcher provides the C ressource by having this +comment: + + #:META:RESOURCE:%.launcher:string:default launcher command + +Example: load this extension when the C<-tr> command line option or +resource name is used. + + #:META:RESOURCE:tr:boolean:set root pixmap as background + +=item #:META:OSC:number:desc + +The OSC comment specifies an OSC sequence, where C is the +numerical OSC code and C is a short description that is currently +unused. + +This will cause the extension to be autoloaded when the OSC sequence is +used for the first time. + +Note that autoloading carries some extra responsibilities with it: +although the terminal cnanot really protect itself against malicious +sources of command sequences, therefore relying on the programs running +I to sanitize data that they output, it is very common for +programs to emit command sequences from untrusted sources. + +While this means that extensions should, as a defense-in-depth mechanism, +always consider whether OSC sequences are safe, autoloading automatically +exposes any autoloaded extension in all terminal windows, so extra care +should be taken. + +Example: the background extension registers OSC C<20> like this: + + #:META:OSC:20:change/query background image + +=item #:META:OSC_PERL:prefix:desc + +The same as the OSC comment, but for the Perl OSC sequence (C<777>). The +C should be unique among extensions, of course, which is most +easily arranged by using the extension name, although this is not +required. + +Example: the overlay-osc extension registers its Perl OSC like this: + + #:META:OSC_PERL:overlay:man overlay-osc + =back =head2 Hooks @@ -242,12 +289,12 @@ C should be used for new behaviour. =item on_osc_seq_perl $term, $args, $resp -Called whenever the B command sequence (OSC = -operating system command) is processed. Cursor position and other state -information is up-to-date when this happens. For interoperability, the -string should start with the extension name (sans -osc) and a semicolon, -to distinguish it from commands for other extensions, and this might be -enforced in the future. +Called whenever the B command sequence +(OSC = operating system command) is processed. Cursor position and other +state information is up-to-date when this happens. For interoperability, +the argument should start with the extension name (sans -osc) or some +other suitable prefix, and a semicolon, to distinguish it from commands +for other extensions. For example, C uses this: @@ -402,7 +449,7 @@ Called on receipt of a bell character. package urxvt; use utf8; -use strict 'vars'; +use strict qw(vars subs); use Carp (); use Scalar::Util (); use List::Util (); @@ -668,7 +715,7 @@ sub usage { } } -my $verbosity = $ENV{URXVT_PERL_VERBOSITY}; +my $verbosity = $ENV{URXVT_PERL_VERBOSITY} // 2; sub verbose { my ($level, $msg) = @_; @@ -695,7 +742,7 @@ sub extension_package($) { or die "$path: $!"; my $source = - "package $pkg; use strict 'vars'; use utf8; no warnings 'utf8';\n" + "package $pkg; use strict qw(vars subs); use utf8; no warnings 'utf8';\n" . "#line 1 \"$path\"\n{\n" . (do { local $/; <$fh> }) . "\n};\n1"; @@ -715,8 +762,6 @@ sub invoke { my $htype = shift; if ($htype == HOOK_INIT) { - my @dirs = $TERM->perl_libdirs; - $TERM->scan_extensions; my %ext_arg; @@ -748,24 +793,31 @@ sub invoke { $ext_arg{$ext} = []; } - } elsif (/^-(.*)$/) { + } elsif (/^-(.*)$/) { # remove from set delete $ext_arg{$1}; - } elsif (/^([^<]+)<(.*)>$/) { - push @{ $ext_arg{$1} }, $2; + } elsif (/^\/(.*)$/) { # prohibit loading + undef $TERM->{ext_prohibit}{$1}; + + } elsif (/^([^<]+)(?:<(.*)>)?$/) { # add to set, clear prohibit status + delete $TERM->{ext_prohibit}{$1}; + push @{ $ext_arg{$1} }, defined $2 ? $2 : (); } else { - $ext_arg{$_} ||= []; + verbose 2, "cannot parse extension specification '$_', ignoring."; } } + $TERM->set_should_invoke (HOOK_OSC_SEQ , +1) if $TERM->{meta}{autoload_osc}; + $TERM->set_should_invoke (HOOK_OSC_SEQ_PERL, +1) if $TERM->{meta}{autoload_osc_perl}; + for my $ext (sort keys %ext_arg) { - my @files = grep -f $_, map "$_/$ext", @dirs; + my $path = $TERM->extension_path ($ext); - if (@files) { - $TERM->register_package (extension_package $files[0], $ext_arg{$ext}); + if (defined $path) { + $TERM->autoload_extension ($ext, $ext_arg{$ext}); } else { - warn "perl extension '$ext' not found in perl library search path\n"; + verbose 2, "perl extension '$ext' not found in perl library search path"; } } @@ -775,6 +827,16 @@ sub invoke { $retval = undef; + if ($htype == HOOK_OSC_SEQ) { + if (my $exts = delete $TERM->{meta}{autoload_osc}{$_[0]}) { + $TERM->autoload_extension ($_->[0]) for @$exts; + } + } elsif ($htype == HOOK_OSC_SEQ_PERL) { + if ($_[0] =~ /^([^;]+)/ and (my $exts = delete $TERM->{meta}{autoload_osc_perl}{$1})) { + $TERM->autoload_extension ($_->[0]) for @$exts; + } + } + if (my $cb = $TERM->{_hook}[$htype]) { verbose 10, "$HOOKNAME[$htype] (" . (join ", ", $TERM, @_) . ")" if $verbosity >= 10; @@ -1142,6 +1204,30 @@ sub register_package { } } +# map extension name to filesyystem path +sub extension_path { + (grep -f $_, map "$_/$_[1]", $_[0]->perl_libdirs)[0] +} + +# load an extension by name +sub load_extension_file { + my ($self, $path, $argv) = @_; + + $self->register_package (urxvt::extension_package $path, $argv); +} + +# autoload an extension unless loading it is prohibited +sub autoload_extension { + my ($self, $name, $argv) = @_; + + return if exists $self->{ext_prohibit}{$name}; + + my $path = $self->extension_path ($name) + // return urxvt::verbose 2, "perl extension '$name' not found in perl library search path (during autoload)"; + + $self->load_extension_file ($path, $argv); +} + sub perl_libdirs { map { split /:/ } $_[0]->resource ("perl_lib"), @@ -1159,7 +1245,7 @@ sub scan_extensions { my @urxvtdirs = perl_libdirs $self; # my @cpandirs = grep -d, map "$_/URxvt/Ext", @INC; - $self->{meta} = \my %meta; + $self->{meta} = \my %allmeta; # first gather extensions @@ -1182,7 +1268,7 @@ sub scan_extensions { $ext =~ s/\.uext$// or $core or next; - my %ext = (dir => $dir); + my %meta = (dir => $dir); while (<$fh>) { if (/^#:META:(?:X_)?RESOURCE:(.*)/) { @@ -1191,16 +1277,24 @@ sub scan_extensions { if ($pattern =~ /[^a-zA-Z0-9\-\.]/) { warn "$dir/$ext: meta resource '$pattern' contains illegal characters (not alphanumeric nor . nor *)\n"; } else { - $ext{resource}{$pattern} = [$ext, $type, $desc]; + $meta{resource}{$pattern} = [$ext, $type, $desc]; } + + } elsif (/^#:META:OSC:([0-9]+):(.*)/) { + push @{$allmeta{autoload_osc}{$1}}, [$ext, $2]; + + } elsif (/^#:META:OSC_PERL:([^:]+):(.*)/) { + push @{$allmeta{autoload_osc_perl}{$1}}, [$ext, $2]; + } elsif (/^\s*(?:#|$)/) { # skip other comments and empty lines + } else { last; # stop parsing on first non-empty non-comment line } } - $meta{ext}{$ext} = \%ext; + $allmeta{ext}{$ext} = \%meta; } }; @@ -1209,9 +1303,9 @@ sub scan_extensions { # and now merge resources - $meta{resource} = \my %resource; + $allmeta{resource} = \my %resource; - while (my ($k, $v) = each %{ $meta{ext} }) { + while (my ($k, $v) = each %{ $allmeta{ext} }) { #TODO: should check for extensions overriding each other %resource = (%resource, %{ $v->{resource} }); } @@ -2291,7 +2385,9 @@ numbers indicate more verbose output. =over -=item == 0 - fatal messages +=item == 0 - fatal messages only + +=item >= 2 - general warnings (default level) =item >= 3 - script loading and management
-----END OF PAGE-----