"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/urxvt.pm" between
rxvt-unicode-9.26.tar.bz2 and rxvt-unicode-9.29.tar.bz2

About: rxvt-unicode is a clone of the terminal emulator rxvt.

urxvt.pm  (rxvt-unicode-9.26.tar.bz2):urxvt.pm  (rxvt-unicode-9.29.tar.bz2)
=encoding utf8 =encoding utf8
=head1 NAME =head1 NAME
urxvtperl - rxvt-unicode's embedded perl interpreter urxvtperl - rxvt-unicode's embedded perl interpreter
=head1 SYNOPSIS =head1 SYNOPSIS
# create a file grab_test in $HOME: # create a file grab_test in some directory:
sub on_sel_grab { sub on_sel_grab {
warn "you selected ", $_[0]->selection; warn "you selected ", $_[0]->selection;
() ()
} }
# start a urxvt using it: # start a urxvt instance using it:
urxvt --perl-lib $HOME -pe grab_test urxvt --perl-lib path/to/somedirectory -pe grab_test
=head1 DESCRIPTION =head1 DESCRIPTION
Every time a terminal object gets created, extension scripts specified via Every time a terminal object gets created, extension scripts specified via
the C<perl> resource are loaded and associated with it. the C<perl> resource are loaded and associated with it.
Scripts are compiled in a 'use strict "vars"' and 'use utf8' environment, and Scripts are compiled in a 'use strict qw(vars subs)' and 'use utf8'
thus must be encoded as UTF-8. environment, and thus must be encoded as UTF-8.
Each script will only ever be loaded once, even in urxvtd, where Each script will only ever be loaded once, even in urxvtd, where
scripts will be shared (but not enabled) for all terminals. scripts will be shared (but not enabled) for all terminals.
You can disable the embedded perl interpreter by setting both "perl-ext" You can disable the embedded perl interpreter by setting both "perl-ext"
and "perl-ext-common" resources to the empty string. and "perl-ext-common" resources to the empty string.
=head1 PREPACKAGED EXTENSIONS =head1 PREPACKAGED EXTENSIONS
A number of extensions are delivered with this release. You can find them A number of extensions are delivered with this release. You can find them
skipping to change at line 75 skipping to change at line 75
modified). modified).
When objects are destroyed on the C++ side, the perl object hashes are When objects are destroyed on the C++ side, the perl object hashes are
emptied, so its best to store related objects such as time watchers and emptied, so its best to store related objects such as time watchers and
the like inside the terminal object so they get destroyed as soon as the the like inside the terminal object so they get destroyed as soon as the
terminal is destroyed. terminal is destroyed.
Argument names also often indicate the type of a parameter. Here are some Argument names also often indicate the type of a parameter. Here are some
hints on what they mean: hints on what they mean:
=over 4 =over
=item $text =item $text
Rxvt-unicode's special way of encoding text, where one "unicode" character Rxvt-unicode's special way of encoding text, where one "unicode" character
always represents one screen cell. See L<ROW_t> for a discussion of this format. always represents one screen cell. See L<ROW_t> for a discussion of this format.
=item $string =item $string
A perl text string, with an emphasis on I<text>. It can store all unicode A perl text string, with an emphasis on I<text>. It can store all unicode
characters and is to be distinguished with text encoded in a specific characters and is to be distinguished with text encoded in a specific
skipping to change at line 124 skipping to change at line 124
Additional methods only supported for extension objects are described in Additional methods only supported for extension objects are described in
the C<urxvt::extension> section below. the C<urxvt::extension> section below.
=head2 META comments =head2 META comments
Rxvt-unicode recognizes special meta comments in extensions that define Rxvt-unicode recognizes special meta comments in extensions that define
different types of metadata. These comments are scanned whenever a different types of metadata. These comments are scanned whenever a
terminal is created and are typically used to autoload extensions when terminal is created and are typically used to autoload extensions when
their resources or command line parameters are used. 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 colons (C<:>), and should not contain colons themselves -
there is also currently no escaping mechanism provided for this.
=over 4 =over
=item #:META:RESOURCE:name:type:desc =item #:META:RESOURCE:name:type:desc
The RESOURCE comment defines a resource used by the extension, where The RESOURCE comment defines a resource used by the extension, where
C<name> is the resource name, C<type> is the resource type, C<boolean> C<name> is the resource name, C<type> is the resource type, C<boolean>
or C<string>, and C<desc> is the resource description. or C<string>, and C<desc> is the resource description.
The extension will be autoloaded when this resource is specified or used The extension will be autoloaded when this resource is specified or used
as a command line parameter. as a command line parameter.
Example: matcher provides the C<matcher.launcher> resource 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<number> is the
numerical OSC code and C<desc> 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 cannot really protect itself against malicious
sources of command sequences, therefore relying on the programs running
I<inside> 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<prefix> 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 =back
=head2 Hooks =head2 Hooks
The following subroutines can be declared in extension files, and will be The following subroutines can be declared in extension files, and will be
called whenever the relevant event happens. called whenever the relevant event happens.
The first argument passed to them is an extension object as described in The first argument passed to them is an extension object as described in
the in the C<Extension Objects> section. the in the C<Extension Objects> section.
B<All> of these hooks must return a boolean value. If any of the called B<All> of these hooks must return a boolean value. If any of the called
hooks returns true, then the event counts as being I<consumed>, and the hooks returns true, then the event counts as being I<consumed>, and the
relevant action might not be carried out by the C++ code. relevant action might not be carried out by the C++ code.
I<< When in doubt, return a false value (preferably C<()>). >> I<< When in doubt, return a false value (preferably C<()>). >>
=over 4 =over
=item on_init $term =item on_init $term
Called after a new terminal object has been initialized, but before Called after a new terminal object has been initialized, but before
windows are created or the command gets run. Most methods are unsafe to windows are created or the command gets run. Most methods are unsafe to
call or deliver senseless data, as terminal size and other characteristics call or deliver senseless data, as terminal size and other characteristics
have not yet been determined. You can safely query and change resources have not yet been determined. You can safely query and change resources
and options, though. For many purposes the C<on_start> hook is a better and options, though. For many purposes the C<on_start> hook is a better
place. place.
skipping to change at line 245 skipping to change at line 292
Called on every OSC sequence and can be used to suppress it or modify its Called on every OSC sequence and can be used to suppress it or modify its
behaviour. The default should be to return an empty list. A true value behaviour. The default should be to return an empty list. A true value
suppresses execution of the request completely. Make sure you don't get suppresses execution of the request completely. Make sure you don't get
confused by recursive invocations when you output an OSC sequence within confused by recursive invocations when you output an OSC sequence within
this callback. this callback.
C<on_osc_seq_perl> should be used for new behaviour. C<on_osc_seq_perl> should be used for new behaviour.
=item on_osc_seq_perl $term, $args, $resp =item on_osc_seq_perl $term, $args, $resp
Called whenever the B<ESC ] 777 ; string ST> command sequence (OSC = Called whenever the B<ESC ] 777 ; prefix ; string ST> command sequence
operating system command) is processed. Cursor position and other state (OSC = operating system command) is processed. Cursor position and other
information is up-to-date when this happens. For interoperability, the state information is up-to-date when this happens. For interoperability,
string should start with the extension name (sans -osc) and a semicolon, the argument should start with the extension name (sans -osc) or some
to distinguish it from commands for other extensions, and this might be other suitable prefix, and a semicolon, to distinguish it from commands
enforced in the future. for other extensions.
For example, C<overlay-osc> uses this: For example, C<overlay-osc> uses this:
sub on_osc_seq_perl { sub on_osc_seq_perl {
my ($self, $osc, $resp) = @_; my ($self, $osc, $resp) = @_;
return unless $osc =~ s/^overlay;//; return unless $osc =~ s/^overlay;//;
... process remaining $osc string ... process remaining $osc string
} }
skipping to change at line 405 skipping to change at line 452
Called on receipt of a bell character. Called on receipt of a bell character.
=back =back
=cut =cut
package urxvt; package urxvt;
use utf8; use utf8;
use strict 'vars'; use strict qw(vars subs);
use Carp (); use Carp ();
use Scalar::Util (); use Scalar::Util ();
use List::Util (); use List::Util ();
our $VERSION = 1; our $VERSION = 1;
our $TERM; our $TERM;
our @TERM_INIT; # should go, prevents async I/O etc. our @TERM_INIT; # should go, prevents async I/O etc.
our @TERM_EXT; # should go, prevents async I/O etc. our @TERM_EXT; # should go, prevents async I/O etc.
our @HOOKNAME; our @HOOKNAME;
our %HOOKTYPE = map +($HOOKNAME[$_] => $_), 0..$#HOOKNAME; our %HOOKTYPE = map +($HOOKNAME[$_] => $_), 0..$#HOOKNAME;
skipping to change at line 427 skipping to change at line 474
our $LIBDIR; our $LIBDIR;
our $RESNAME; our $RESNAME;
our $RESCLASS; our $RESCLASS;
our $RXVTNAME; our $RXVTNAME;
our $NOCHAR = chr 0xffff; our $NOCHAR = chr 0xffff;
=head2 Variables in the C<urxvt> Package =head2 Variables in the C<urxvt> Package
=over 4 =over
=item $urxvt::LIBDIR =item $urxvt::LIBDIR
The rxvt-unicode library directory, where, among other things, the perl The rxvt-unicode library directory, where, among other things, the perl
modules and scripts are stored. modules and scripts are stored.
=item $urxvt::RESCLASS, $urxvt::RESCLASS =item $urxvt::RESCLASS, $urxvt::RESCLASS
The resource class and name rxvt-unicode uses to look up X resources. The resource class and name rxvt-unicode uses to look up X resources.
skipping to change at line 467 skipping to change at line 514
=item @urxvt::TERM_EXT =item @urxvt::TERM_EXT
Works similar to C<@TERM_INIT>, but contains perl package/class names, which Works similar to C<@TERM_INIT>, but contains perl package/class names, which
get registered as normal extensions after calling the hooks in C<@TERM_INIT> get registered as normal extensions after calling the hooks in C<@TERM_INIT>
but before other extensions. Gets cleared just like C<@TERM_INIT>. but before other extensions. Gets cleared just like C<@TERM_INIT>.
=back =back
=head2 Functions in the C<urxvt> Package =head2 Functions in the C<urxvt> Package
=over 4 =over
=item urxvt::fatal $errormessage =item urxvt::fatal $errormessage
Fatally aborts execution with the given error message (which should Fatally aborts execution with the given error message (which should
include a trailing newline). Avoid at all costs! The only time this include a trailing newline). Avoid at all costs! The only time this
is acceptable (and useful) is in the init hook, where it prevents the is acceptable (and useful) is in the init hook, where it prevents the
terminal from starting up. terminal from starting up.
=item urxvt::warn $string =item urxvt::warn $string
skipping to change at line 546 skipping to change at line 593
=head2 RENDITION =head2 RENDITION
Rendition bitsets contain information about colour, font, font styles and Rendition bitsets contain information about colour, font, font styles and
similar information for each screen cell. similar information for each screen cell.
The following "macros" deal with changes in rendition sets. You should The following "macros" deal with changes in rendition sets. You should
never just create a bitset, you should always modify an existing one, never just create a bitset, you should always modify an existing one,
as they contain important information required for correct operation of as they contain important information required for correct operation of
rxvt-unicode. rxvt-unicode.
=over 4 =over
=item $rend = urxvt::DEFAULT_RSTYLE =item $rend = urxvt::DEFAULT_RSTYLE
Returns the default rendition, as used when the terminal is starting up or Returns the default rendition, as used when the terminal is starting up or
being reset. Useful as a base to start when creating renditions. being reset. Useful as a base to start when creating renditions.
=item $rend = urxvt::OVERLAY_RSTYLE =item $rend = urxvt::OVERLAY_RSTYLE
Return the rendition mask used for overlays by default. Return the rendition mask used for overlays by default.
skipping to change at line 671 skipping to change at line 718
} else { } else {
urxvt::log sprintf " -%-30s %s\n", "$pattern $type", $desc; urxvt::log sprintf " -%-30s %s\n", "$pattern $type", $desc;
} }
} else { } else {
$pattern =~ s/\.$/.*/g; $pattern =~ s/\.$/.*/g;
urxvt::log sprintf " %-31s %s\n", "$pattern:", $type; urxvt::log sprintf " %-31s %s\n", "$pattern:", $type;
} }
} }
} }
my $verbosity = $ENV{URXVT_PERL_VERBOSITY}; my $verbosity = $ENV{URXVT_PERL_VERBOSITY} // 2;
sub verbose { sub verbose {
my ($level, $msg) = @_; my ($level, $msg) = @_;
warn "$msg\n" if $level <= $verbosity; warn "$msg\n" if $level <= $verbosity;
} }
my %extension_pkg; my %extension_pkg;
# load a single script into its own package, once only # load a single script into its own package, once only
sub extension_package($) { sub extension_package($) {
skipping to change at line 698 skipping to change at line 745
$pkg = "urxvt::ext::$pkg"; $pkg = "urxvt::ext::$pkg";
verbose 3, "loading extension '$path' into package '$pkg'"; verbose 3, "loading extension '$path' into package '$pkg'";
(${"$pkg\::_NAME"} = $path) =~ s/^.*[\\\/]//; # hackish (${"$pkg\::_NAME"} = $path) =~ s/^.*[\\\/]//; # hackish
open my $fh, "<:raw", $path open my $fh, "<:raw", $path
or die "$path: $!"; or die "$path: $!";
my $source = 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" . "#line 1 \"$path\"\n{\n"
. (do { local $/; <$fh> }) . (do { local $/; <$fh> })
. "\n};\n1"; . "\n};\n1";
eval $source eval $source
or die "$path: $@"; or die "$path: $@";
$pkg $pkg
} }
} }
our $retval; # return value for urxvt our $retval; # return value for urxvt
# called by the rxvt core # called by the rxvt core
sub invoke { sub invoke {
local $TERM = shift; local $TERM = shift;
my $htype = shift; my $htype = shift;
if ($htype == HOOK_INIT) { if ($htype == HOOK_INIT) {
my @dirs = $TERM->perl_libdirs;
$TERM->scan_extensions; $TERM->scan_extensions;
my %ext_arg; my %ext_arg;
{ {
my @init = @TERM_INIT; my @init = @TERM_INIT;
@TERM_INIT = (); @TERM_INIT = ();
$_->($TERM) for @init; $_->($TERM) for @init;
my @pkg = @TERM_EXT; my @pkg = @TERM_EXT;
@TERM_EXT = (); @TERM_EXT = ();
$TERM->register_package ($_) for @pkg; $TERM->register_package ($_) for @pkg;
} }
for ( for (
@{ delete $TERM->{perl_ext_3} },
(grep $_, map { split /,/, $TERM->resource ("perl_ext_$_") } 1, 2), (grep $_, map { split /,/, $TERM->resource ("perl_ext_$_") } 1, 2),
@{ delete $TERM->{perl_ext_3} }
) { ) {
if ($_ eq "default") { if ($_ eq "default") {
$ext_arg{$_} = [] $ext_arg{$_} = []
for qw(selection option-popup selection-popup readline searchable -scrollback); for qw(selection option-popup selection-popup readline searchable -scrollback confirm-paste);
for ($TERM->_keysym_resources) { for ($TERM->_keysym_resources) {
next if /^(?:string|command|builtin|builtin-string|perl)/; next if /^(?:string|command|builtin|builtin-string|perl)/;
next unless /^([A-Za-z0-9_\-]+):/; next unless /^([A-Za-z0-9_\-]+):/;
my $ext = $1; my $ext = $1;
$ext_arg{$ext} = []; $ext_arg{$ext} = [];
} }
} elsif (/^-(.*)$/) { } elsif (/^-(.*)$/) { # remove from set
delete $ext_arg{$1}; delete $ext_arg{$1};
} elsif (/^([^<]+)<(.*)>$/) { } elsif (/^\/(.*)$/) { # prohibit loading
push @{ $ext_arg{$1} }, $2; 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 { } 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) { for my $ext (sort keys %ext_arg) {
my @files = grep -f $_, map "$_/$ext", @dirs; my $path = $TERM->extension_path ($ext);
if (@files) { if (defined $path) {
$TERM->register_package (extension_package $files[0], $ext_arg{$ext} $TERM->autoload_extension ($ext, $ext_arg{$ext});
);
} else { } else {
warn "perl extension '$ext' not found in perl library search path\n" ; verbose 2, "perl extension '$ext' not found in perl library search p ath";
} }
} }
eval "#line 1 \"--perl-eval resource/argument\"\n" . $TERM->resource ("per l_eval"); eval "#line 1 \"--perl-eval resource/argument\"\n" . $TERM->resource ("per l_eval");
warn $@ if $@; warn $@ if $@;
} }
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;
}
}
$retval = undef; $retval = undef;
if (my $cb = $TERM->{_hook}[$htype]) { if (my $cb = $TERM->{_hook}[$htype]) {
verbose 10, "$HOOKNAME[$htype] (" . (join ", ", $TERM, @_) . ")" verbose 10, "$HOOKNAME[$htype] (" . (join ", ", $TERM, @_) . ")"
if $verbosity >= 10; if $verbosity >= 10;
if ($htype == HOOK_ACTION) { if ($htype == HOOK_ACTION) {
# this hook is only sent to the extension with the name # this hook is only sent to the extension with the name
# matching the first arg # matching the first arg
my $pkg = shift; my $pkg = shift;
skipping to change at line 863 skipping to change at line 925
Each extension attached to a terminal object is represented by Each extension attached to a terminal object is represented by
a C<urxvt::term::extension> object. a C<urxvt::term::extension> object.
You can use these objects, which are passed to all callbacks to store any You can use these objects, which are passed to all callbacks to store any
state related to the terminal and extension instance. state related to the terminal and extension instance.
The methods (And data members) documented below can be called on extension The methods (And data members) documented below can be called on extension
objects, in addition to call methods documented for the <urxvt::term> objects, in addition to call methods documented for the <urxvt::term>
class. class.
=over 4 =over
=item $urxvt_term = $self->{term} =item $urxvt_term = $self->{term}
Returns the C<urxvt::term> object associated with this instance of the Returns the C<urxvt::term> object associated with this instance of the
extension. This member I<must not> be changed in any way. extension. This member I<must not> be changed in any way.
=cut =cut
our $AUTOLOAD; our $AUTOLOAD;
skipping to change at line 1114 skipping to change at line 1176
# only needed for AnyEvent < 6 compatibility # only needed for AnyEvent < 6 compatibility
sub one_event { sub one_event {
Carp::croak "AnyEvent->one_event blocking wait unsupported in urxvt, use a no n-blocking API"; Carp::croak "AnyEvent->one_event blocking wait unsupported in urxvt, use a no n-blocking API";
} }
package urxvt::term; package urxvt::term;
=head2 The C<urxvt::term> Class =head2 The C<urxvt::term> Class
=over 4 =over
=cut =cut
# find on_xxx subs in the package and register them # find on_xxx subs in the package and register them
# as hooks # as hooks
sub register_package { sub register_package {
my ($self, $pkg, $argv) = @_; my ($self, $pkg, $argv) = @_;
no strict 'refs'; no strict 'refs';
skipping to change at line 1145 skipping to change at line 1207
$self->{_pkg}{$pkg} = $proxy; $self->{_pkg}{$pkg} = $proxy;
for my $name (@HOOKNAME) { for my $name (@HOOKNAME) {
if (my $ref = $pkg->can ("on_" . lc $name)) { if (my $ref = $pkg->can ("on_" . lc $name)) {
$proxy->enable ($name => $ref); $proxy->enable ($name => $ref);
} }
} }
} }
# map extension name to filesystem 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 libr
ary search path (during autoload)";
$self->load_extension_file ($path, $argv);
}
sub perl_libdirs { sub perl_libdirs {
map { split /:/ } map { split /:/ }
$_[0]->resource ("perl_lib"), $_[0]->resource ("perl_lib"),
$ENV{URXVT_PERL_LIB}, $ENV{URXVT_PERL_LIB},
"$ENV{HOME}/.urxvt/ext", "$ENV{HOME}/.urxvt/ext",
"$LIBDIR/perl" "$LIBDIR/perl"
} }
# scan for available extensions and collect their metadata # scan for available extensions and collect their metadata
sub scan_extensions { sub scan_extensions {
my ($self) = @_; my ($self) = @_;
return if exists $self->{meta}; return if exists $self->{meta};
my @urxvtdirs = perl_libdirs $self; my @urxvtdirs = perl_libdirs $self;
# my @cpandirs = grep -d, map "$_/URxvt/Ext", @INC; # my @cpandirs = grep -d, map "$_/URxvt/Ext", @INC;
$self->{meta} = \my %meta; $self->{meta} = \my %allmeta;
# first gather extensions # first gather extensions
my $gather = sub { my $gather = sub {
my ($dir, $core) = @_; my ($dir, $core) = @_;
opendir my $fh, $dir opendir my $fh, $dir
or return; or return;
for my $ext (readdir $fh) { for my $ext (readdir $fh) {
skipping to change at line 1185 skipping to change at line 1271
open my $fh, "<", "$dir/$ext" open my $fh, "<", "$dir/$ext"
or next; or next;
-f $fh -f $fh
or next; or next;
$ext =~ s/\.uext$// or $core $ext =~ s/\.uext$// or $core
or next; or next;
my %ext = (dir => $dir); my %meta = (dir => $dir);
while (<$fh>) { while (<$fh>) {
if (/^#:META:(?:X_)?RESOURCE:(.*)/) { if (/^#:META:(?:X_)?RESOURCE:(.*)/) {
my ($pattern, $type, $desc) = split /:/, $1; my ($pattern, $type, $desc) = split /:/, $1;
$pattern =~ s/^%(\.|$)/$ext$1/g; # % in pattern == extension name $pattern =~ s/^%(\.|$)/$ext$1/g; # % in pattern == extension name
if ($pattern =~ /[^a-zA-Z0-9\-\.]/) { if ($pattern =~ /[^a-zA-Z0-9\-\.]/) {
warn "$dir/$ext: meta resource '$pattern' contains illegal cha racters (not alphanumeric nor . nor *)\n"; warn "$dir/$ext: meta resource '$pattern' contains illegal cha racters (not alphanumeric nor . nor *)\n";
} else { } 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*(?:#|$)/) { } elsif (/^\s*(?:#|$)/) {
# skip other comments and empty lines # skip other comments and empty lines
} else { } else {
last; # stop parsing on first non-empty non-comment line last; # stop parsing on first non-empty non-comment line
} }
} }
$meta{ext}{$ext} = \%ext; $allmeta{ext}{$ext} = \%meta;
} }
}; };
# $gather->($_, 0) for @cpandirs; # $gather->($_, 0) for @cpandirs;
$gather->($_, 1) for @urxvtdirs; $gather->($_, 1) for @urxvtdirs;
# and now merge resources # 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 #TODO: should check for extensions overriding each other
%resource = (%resource, %{ $v->{resource} }); %resource = (%resource, %{ $v->{resource} });
} }
} }
=item $term = new urxvt::term $envhashref, $rxvtname, [arg...] =item $term = new urxvt::term $envhashref, $rxvtname, [arg...]
Creates a new terminal, very similar as if you had started it with system Creates a new terminal, very similar as if you had started it with system
C<$rxvtname, arg...>. C<$envhashref> must be a reference to a C<%ENV>-like C<$rxvtname, arg...>. C<$envhashref> must be a reference to a C<%ENV>-like
hash which defines the environment of the new terminal. hash which defines the environment of the new terminal.
skipping to change at line 1289 skipping to change at line 1383
Here is a likely non-exhaustive list of option names, please see the Here is a likely non-exhaustive list of option names, please see the
source file F</src/optinc.h> to see the actual list: source file F</src/optinc.h> to see the actual list:
borderLess buffered console cursorBlink cursorUnderline hold iconic borderLess buffered console cursorBlink cursorUnderline hold iconic
insecure intensityStyles iso14755 iso14755_52 jumpScroll loginShell insecure intensityStyles iso14755 iso14755_52 jumpScroll loginShell
mapAlert meta8 mouseWheelScrollPage override_redirect pastableTabs mapAlert meta8 mouseWheelScrollPage override_redirect pastableTabs
pointerBlank reverseVideo scrollBar scrollBar_floating scrollBar_right pointerBlank reverseVideo scrollBar scrollBar_floating scrollBar_right
scrollTtyKeypress scrollTtyOutput scrollWithBuffer secondaryScreen scrollTtyKeypress scrollTtyOutput scrollWithBuffer secondaryScreen
secondaryScroll skipBuiltinGlyphs skipScroll transparent tripleclickwords secondaryScroll skipBuiltinGlyphs skipScroll transparent tripleclickwords
urgentOnBell utmpInhibit visualBell urgentOnBell utmpInhibit visualBell disablePasteBrackets
=item $value = $term->resource ($name[, $newval]) =item $value = $term->resource ($name[, $newval])
Returns the current resource value associated with a given name and Returns the current resource value associated with a given name and
optionally sets a new value. Setting values is most useful in the C<init> optionally sets a new value. Setting values is most useful in the C<init>
hook. Unset resources are returned and accepted as C<undef>. hook. Unset resources are returned and accepted as C<undef>.
The new value must be properly encoded to a suitable character encoding The new value must be properly encoded to a suitable character encoding
before passing it to this method. Similarly, the returned value may need before passing it to this method. Similarly, the returned value may need
to be converted from the used encoding to text. to be converted from the used encoding to text.
skipping to change at line 1325 skipping to change at line 1419
fade font geometry hold iconName iconfile imFont imLocale inputMethod fade font geometry hold iconName iconfile imFont imLocale inputMethod
insecure int_bwidth intensityStyles iso14755 iso14755_52 italicFont insecure int_bwidth intensityStyles iso14755 iso14755_52 italicFont
jumpScroll letterSpace lineSpace loginShell mapAlert meta8 modifier jumpScroll letterSpace lineSpace loginShell mapAlert meta8 modifier
mouseWheelScrollPage name override_redirect pastableTabs path perl_eval mouseWheelScrollPage name override_redirect pastableTabs path perl_eval
perl_ext_1 perl_ext_2 perl_lib pointerBlank pointerBlankDelay perl_ext_1 perl_ext_2 perl_lib pointerBlank pointerBlankDelay
preeditType print_pipe pty_fd reverseVideo saveLines scrollBar preeditType print_pipe pty_fd reverseVideo saveLines scrollBar
scrollBar_align scrollBar_floating scrollBar_right scrollBar_thickness scrollBar_align scrollBar_floating scrollBar_right scrollBar_thickness
scrollTtyKeypress scrollTtyOutput scrollWithBuffer scrollstyle scrollTtyKeypress scrollTtyOutput scrollWithBuffer scrollstyle
secondaryScreen secondaryScroll shade skipBuiltinGlyphs skipScroll secondaryScreen secondaryScroll shade skipBuiltinGlyphs skipScroll
term_name title transient_for transparent tripleclickwords urgentOnBell term_name title transient_for transparent tripleclickwords urgentOnBell
utmpInhibit visualBell utmpInhibit visualBell rewrapMode disablePasteBrackets
=cut =cut
sub resource($$;$) { sub resource($$;$) {
my ($self, $name) = (shift, shift); my ($self, $name) = (shift, shift);
unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0);
goto &urxvt::term::_resource goto &urxvt::term::_resource
} }
=item $value = $term->x_resource ($pattern) =item $value = $term->x_resource ($pattern)
skipping to change at line 1482 skipping to change at line 1576
around the box. around the box.
If either C<$x> or C<$y> is negative, then this is counted from the If either C<$x> or C<$y> is negative, then this is counted from the
right/bottom side, respectively. right/bottom side, respectively.
This method returns an urxvt::overlay object. The overlay will be visible This method returns an urxvt::overlay object. The overlay will be visible
as long as the perl object is referenced. as long as the perl object is referenced.
The methods currently supported on C<urxvt::overlay> objects are: The methods currently supported on C<urxvt::overlay> objects are:
=over 4 =over
=item $overlay->set ($x, $y, $text[, $rend]) =item $overlay->set ($x, $y, $text[, $rend])
Similar to C<< $term->ROW_t >> and C<< $term->ROW_r >> in that it puts Similar to C<< $term->ROW_t >> and C<< $term->ROW_r >> in that it puts
text in rxvt-unicode's special encoding and an array of rendition values text in rxvt-unicode's special encoding and an array of rendition values
at a specific position inside the overlay. at a specific position inside the overlay.
If C<$rend> is missing, then the rendition will not be changed. If C<$rend> is missing, then the rendition will not be changed.
=item $overlay->hide =item $overlay->hide
skipping to change at line 1536 skipping to change at line 1630
$popup $popup
} }
=item $cellwidth = $term->strwidth ($string) =item $cellwidth = $term->strwidth ($string)
Returns the number of screen-cells this string would need. Correctly Returns the number of screen-cells this string would need. Correctly
accounts for wide and combining characters. accounts for wide and combining characters.
=item $octets = $term->locale_encode ($string) =item $octets = $term->locale_encode ($string)
Convert the given text string into the corresponding locale encoding. Convert the given text string into the corresponding locale
encoding. Returns C<undef> if C<$string> is C<undef>.
=item $string = $term->locale_decode ($octets) =item $string = $term->locale_decode ($octets)
Convert the given locale-encoded octets into a perl string. Convert the given locale-encoded octets into a perl string. Returns
C<undef> if C<$octets> is C<undef>.
=item $term->scr_xor_span ($beg_row, $beg_col, $end_row, $end_col[, $rstyle]) =item $term->scr_xor_span ($beg_row, $beg_col, $end_row, $end_col[, $rstyle])
XORs the rendition values in the given span with the provided value XORs the rendition values in the given span with the provided value
(default: C<RS_RVid>), which I<MUST NOT> contain font styles. Useful in (default: C<RS_RVid>), which I<MUST NOT> contain font styles. Useful in
refresh hooks to provide effects similar to the selection. refresh hooks to provide effects similar to the selection.
=item $term->scr_xor_rect ($beg_row, $beg_col, $end_row, $end_col[, $rstyle1[, $ rstyle2]]) =item $term->scr_xor_rect ($beg_row, $beg_col, $end_row, $end_col[, $rstyle1[, $ rstyle2]])
Similar to C<scr_xor_span>, but xors a rectangle instead. Trailing Similar to C<scr_xor_span>, but xors a rectangle instead. Trailing
skipping to change at line 1727 skipping to change at line 1823
Returns a bitset with the state of DEC private modes. Returns a bitset with the state of DEC private modes.
Example: Example:
if ($term->priv_modes & urxvt::PrivMode_mouse_report) { if ($term->priv_modes & urxvt::PrivMode_mouse_report) {
# mouse reporting is turned on # mouse reporting is turned on
} }
=item $view_start = $term->view_start ([$newvalue]) =item $view_start = $term->view_start ([$newvalue])
Returns the row number of the topmost displayed line. Maximum value is Returns the row number of the topmost displayed line and changes it,
C<0>, which displays the normal terminal contents. Lower values scroll if an argument is given. Values greater than or equal to C<0> display
this many lines into the scrollback buffer. the terminal contents. Lower values scroll this many lines into the
scrollback buffer.
=item $term->want_refresh =item $term->want_refresh
Requests a screen refresh. At the next opportunity, rxvt-unicode will Requests a screen refresh. At the next opportunity, rxvt-unicode will
compare the on-screen display with its stored representation. If they compare the on-screen display with its stored representation. If they
differ, it redraws the differences. differ, it redraws the differences.
Used after changing terminal contents to display them. Used after changing terminal contents to display them.
=item $term->refresh_check =item $term->refresh_check
skipping to change at line 1797 skipping to change at line 1894
joined with the following row), which means all characters are in use joined with the following row), which means all characters are in use
and it is continued on the next row (and possibly a continuation of the and it is continued on the next row (and possibly a continuation of the
previous row(s)). previous row(s)).
=item $line = $term->line ($row_number) =item $line = $term->line ($row_number)
Create and return a new C<urxvt::line> object that stores information Create and return a new C<urxvt::line> object that stores information
about the logical line that row C<$row_number> is part of. It supports the about the logical line that row C<$row_number> is part of. It supports the
following methods: following methods:
=over 4 =over
=item $text = $line->t ([$new_text]) =item $text = $line->t ([$new_text])
Returns or replaces the full text of the line, similar to C<ROW_t> Returns or replaces the full text of the line, similar to C<ROW_t>
=item $rend = $line->r ([$new_rend]) =item $rend = $line->r ([$new_rend])
Returns or replaces the full rendition array of the line, similar to C<ROW_r> Returns or replaces the full rendition array of the line, similar to C<ROW_r>
=item $length = $line->l =item $length = $line->l
skipping to change at line 1911 skipping to change at line 2008
} }
=item $text = $term->special_encode $string =item $text = $term->special_encode $string
Converts a perl string into the special encoding used by rxvt-unicode, Converts a perl string into the special encoding used by rxvt-unicode,
where one character corresponds to one screen cell. See where one character corresponds to one screen cell. See
C<< $term->ROW_t >> for details. C<< $term->ROW_t >> for details.
=item $string = $term->special_decode $text =item $string = $term->special_decode $text
Converts rxvt-unicodes text representation into a perl string. See Converts rxvt-unicode's text representation into a perl string. See
C<< $term->ROW_t >> for details. C<< $term->ROW_t >> for details.
=item $success = $term->grab_button ($button, $modifiermask[, $window = $term->v t]) =item $success = $term->grab_button ($button, $modifiermask[, $window = $term->v t])
=item $term->ungrab_button ($button, $modifiermask[, $window = $term->vt]) =item $term->ungrab_button ($button, $modifiermask[, $window = $term->vt])
Register/unregister a synchronous button grab. See the XGrabButton Register/unregister a synchronous button grab. See the XGrabButton
manpage. manpage.
=item $success = $term->grab ($eventtime[, $sync]) =item $success = $term->grab ($eventtime[, $sync])
skipping to change at line 1987 skipping to change at line 2084
directly onto the X functions of the same name. directly onto the X functions of the same name.
=back =back
=cut =cut
package urxvt::popup; package urxvt::popup;
=head2 The C<urxvt::popup> Class =head2 The C<urxvt::popup> Class
=over 4 =over
=cut =cut
sub add_item { sub add_item {
my ($self, $item) = @_; my ($self, $item) = @_;
$item->{rend}{normal} = "\x1b[0;30;47m" unless exists $item->{rend}{normal}; $item->{rend}{normal} = "\x1b[0;30;47m" unless exists $item->{rend}{normal};
$item->{rend}{hover} = "\x1b[0;30;46m" unless exists $item->{rend}{hover}; $item->{rend}{hover} = "\x1b[0;30;46m" unless exists $item->{rend}{hover};
$item->{rend}{active} = "\x1b[m" unless exists $item->{rend}{active}; $item->{rend}{active} = "\x1b[m" unless exists $item->{rend}{active};
skipping to change at line 2133 skipping to change at line 2230
$term->{overlay} = $term->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0); $term->{overlay} = $term->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0);
$term->{timer} = urxvt::timer $term->{timer} = urxvt::timer
->new ->new
->interval (1) ->interval (1)
->cb (sub { ->cb (sub {
$term->{overlay}->set (0, 0, $term->{overlay}->set (0, 0,
sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0] ); sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0] );
}); });
=over 4 =over
=item $timer = new urxvt::timer =item $timer = new urxvt::timer
Create a new timer object in started state. It is scheduled to fire Create a new timer object in started state. It is scheduled to fire
immediately. immediately.
=item $timer = $timer->cb (sub { my ($timer) = @_; ... }) =item $timer = $timer->cb (sub { my ($timer) = @_; ... })
Set the callback to be called when the timer triggers. Set the callback to be called when the timer triggers.
skipping to change at line 2191 skipping to change at line 2288
->fd (fileno $term->{socket}) ->fd (fileno $term->{socket})
->events (urxvt::EV_READ) ->events (urxvt::EV_READ)
->start ->start
->cb (sub { ->cb (sub {
my ($iow, $revents) = @_; my ($iow, $revents) = @_;
# $revents must be 1 here, no need to check # $revents must be 1 here, no need to check
sysread $term->{socket}, my $buf, 8192 sysread $term->{socket}, my $buf, 8192
or end-of-file; or end-of-file;
}); });
=over 4 =over
=item $iow = new urxvt::iow =item $iow = new urxvt::iow
Create a new io watcher object in stopped state. Create a new io watcher object in stopped state.
=item $iow = $iow->cb (sub { my ($iow, $reventmask) = @_; ... }) =item $iow = $iow->cb (sub { my ($iow, $reventmask) = @_; ... })
Set the callback to be called when io events are triggered. C<$reventmask> Set the callback to be called when io events are triggered. C<$reventmask>
is a bitset as described in the C<events> method. is a bitset as described in the C<events> method.
skipping to change at line 2228 skipping to change at line 2325
Stop watching for events on the given file handle. Stop watching for events on the given file handle.
=back =back
=head2 The C<urxvt::iw> Class =head2 The C<urxvt::iw> Class
This class implements idle watchers, that get called automatically when This class implements idle watchers, that get called automatically when
the process is idle. They should return as fast as possible, after doing the process is idle. They should return as fast as possible, after doing
some useful work. some useful work.
=over 4 =over
=item $iw = new urxvt::iw =item $iw = new urxvt::iw
Create a new idle watcher object in stopped state. Create a new idle watcher object in stopped state.
=item $iw = $iw->cb (sub { my ($iw) = @_; ... }) =item $iw = $iw->cb (sub { my ($iw) = @_; ... })
Set the callback to be called when the watcher triggers. Set the callback to be called when the watcher triggers.
=item $timer = $timer->start =item $timer = $timer->start
skipping to change at line 2263 skipping to change at line 2360
my $pid = fork; my $pid = fork;
... ...
$term->{pw} = urxvt::pw $term->{pw} = urxvt::pw
->new ->new
->start ($pid) ->start ($pid)
->cb (sub { ->cb (sub {
my ($pw, $exit_status) = @_; my ($pw, $exit_status) = @_;
... ...
}); });
=over 4 =over
=item $pw = new urxvt::pw =item $pw = new urxvt::pw
Create a new process watcher in stopped state. Create a new process watcher in stopped state.
=item $pw = $pw->cb (sub { my ($pw, $exit_status) = @_; ... }) =item $pw = $pw->cb (sub { my ($pw, $exit_status) = @_; ... })
Set the callback to be called when the timer triggers. Set the callback to be called when the timer triggers.
=item $pw = $timer->start ($pid) =item $pw = $timer->start ($pid)
skipping to change at line 2290 skipping to change at line 2387
=back =back
=head1 ENVIRONMENT =head1 ENVIRONMENT
=head2 URXVT_PERL_VERBOSITY =head2 URXVT_PERL_VERBOSITY
This variable controls the verbosity level of the perl extension. Higher This variable controls the verbosity level of the perl extension. Higher
numbers indicate more verbose output. numbers indicate more verbose output.
=over 4 =over
=item == 0 - fatal messages only
=item == 0 - fatal messages =item >= 2 - general warnings (default level)
=item >= 3 - script loading and management =item >= 3 - script loading and management
=item >=10 - all called hooks =item >=10 - all called hooks
=item >=11 - hook return values =item >=11 - hook return values
=back =back
=head1 AUTHOR =head1 AUTHOR
 End of changes. 54 change blocks. 
59 lines changed or deleted 161 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)