repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 3c7928ef765702733562cf78061abd0f05f4ac59: path_to: revision_to:
commit 3c7928ef765702733562cf78061abd0f05f4ac59 Author: Marc LehmannDate: Sun Jun 10 13:58:06 2012 +0000 *** empty log message *** diff --git a/src/perl/background b/src/perl/background
--- a/src/perl/background
+++ b/src/perl/background
@@ -858,13 +858,13 @@ sub recalculate {
sub on_start {
my ($self) = @_;
- my $expr = $self->x_resource ("background.expr")
+ my $expr = $self->x_resource ("%.expr")
or return;
$self->set_expr (parse_expr $expr);
- $self->{border} = $self->x_resource_boolean ("background.border");
+ $self->{border} = $self->x_resource_boolean ("%.border");
- $MIN_INTERVAL = $self->x_resource ("background.interval");
+ $MIN_INTERVAL = $self->x_resource ("%.interval");
()
}
diff --git a/src/perl/matcher b/src/perl/matcher
--- a/src/perl/matcher
+++ b/src/perl/matcher
@@ -130,8 +130,7 @@ sub most_recent {
}
sub my_resource {
- my $self = shift;
- $self->x_resource ("$self->{name}.$_[0]");
+ $_[0]->x_resource ("%.$_[1]")
}
# turn a rendition spec in the resource into a sub that implements it on $_
@@ -152,8 +151,6 @@ sub parse_rend {
sub on_start {
my ($self) = @_;
- ($self->{name} = __PACKAGE__) =~ s/.*:://;
- $self->{name} =~ tr/_/-/;
$self->{launcher} = $self->my_resource ("launcher") || $self->x_resource("url-launcher") || "sensible-browser";
$self->{urls} = [];
@@ -172,7 +169,7 @@ sub on_start {
} elsif($mod eq "M") {
$self->{state} |= $self->ModMetaMask;
} elsif($mod ne "-" && $mod ne " ") {
- warn("$mod is invalid in $self->{name}<$self->{argv}[0]>\n");
+ warn("$mod is invalid in $self->{_name}<$self->{argv}[0]>\n");
}
}
}
diff --git a/src/perl/remote-clipboard b/src/perl/remote-clipboard
--- a/src/perl/remote-clipboard
+++ b/src/perl/remote-clipboard
@@ -87,10 +87,10 @@ sub fetch {
sub on_start {
my ($self) = @_;
- $self->{store_cmd} = $self->x_resource ("remote-selection.store")
+ $self->{store_cmd} = $self->x_resource ("%.store")
|| "rsh ruth 'cat >/tmp/distributed-selection'";
- $self->{fetch_cmd} = $self->x_resource ("remote-selection.fetch")
+ $self->{fetch_cmd} = $self->x_resource ("%.fetch")
|| "rsh ruth 'cat /tmp/distributed-selection'";
push @{ $self->{term}{selection_popup_hook} }, sub {
diff --git a/src/perl/searchable-scrollback b/src/perl/searchable-scrollback
--- a/src/perl/searchable-scrollback
+++ b/src/perl/searchable-scrollback
@@ -8,7 +8,7 @@ sub on_init {
my ($self) = @_;
my $hotkey = $self->{argv}[0]
- || $self->x_resource ("searchable-scrollback")
+ || $self->x_resource ("%")
|| "M-s";
$self->parse_keysym ($hotkey, "perl:searchable-scrollback:start")
diff --git a/src/perl/selection-autotransform b/src/perl/selection-autotransform
--- a/src/perl/selection-autotransform
+++ b/src/perl/selection-autotransform
@@ -16,7 +16,7 @@ sub msg {
sub on_init {
my ($self) = @_;
- for (my $idx = 0; defined (my $res = $self->x_resource ("selection-autotransform.$idx")); $idx++) {
+ for (my $idx = 0; defined (my $res = $self->x_resource ("%.$idx")); $idx++) {
$res = $self->locale_decode ($res);
my $transform = eval "sub { $res }";
diff --git a/src/perl/selection-pastebin b/src/perl/selection-pastebin
--- a/src/perl/selection-pastebin
+++ b/src/perl/selection-pastebin
@@ -62,10 +62,10 @@ sub upload_paste {
sub on_start {
my ($self) = @_;
- $self->{pastebin_cmd} = $self->x_resource ("selection-pastebin.cmd")
+ $self->{pastebin_cmd} = $self->x_resource ("%.cmd")
|| "rcp -p % ruth:/var/www/www.ta-sa.org/files/txt/";
- $self->{pastebin_url} = $self->x_resource ("selection-pastebin.url")
+ $self->{pastebin_url} = $self->x_resource ("%.url")
|| "http://www.ta-sa.org/files/txt/%";
push @{ $self->{term}{selection_popup_hook} }, sub {
diff --git a/src/urxvt.pm b/src/urxvt.pm
--- a/src/urxvt.pm
+++ b/src/urxvt.pm
@@ -1026,6 +1026,8 @@ sub extension_package($) {
verbose 3, "loading extension '$path' into package '$pkg'";
+ (${"$pkg\::_NAME"} = $path) =~ s/^.*[\\\/]//; # hackish
+
open my $fh, "<:raw", $path
or die "$path: $!";
@@ -1152,8 +1154,6 @@ sub rend2mask {
($mask, @color{qw(fg bg)}, \@failed)
}
-# urxvt::term::extension
-
package urxvt::term::extension;
sub enable {
@@ -1217,6 +1217,18 @@ sub urxvt::destroy_hook(&) {
bless \shift, urxvt::destroy_hook::
}
+sub x_resource {
+ my ($self, $name) = @_;
+ $name =~ s/^%(\.|$)/$_[0]{_name}$1/;
+ $self->{term}->x_resource ($name)
+}
+
+sub x_resource_boolean {
+ my ($self, $name) = @_;
+ $name =~ s/^%(\.|$)/$_[0]{_name}$1/;
+ $self->{term}->x_resource_boolean ($name)
+}
+
package urxvt::anyevent;
=head2 The C Class
@@ -1321,8 +1333,9 @@ sub register_package {
@{"$pkg\::ISA"} = urxvt::term::extension::;
my $proxy = bless {
- _pkg => $pkg,
- argv => $argv,
+ _pkg => $pkg,
+ _name => ${"$pkg\::_NAME"}, # hackish
+ argv => $argv,
}, $pkg;
Scalar::Util::weaken ($proxy->{term} = $self);
@@ -1504,6 +1517,16 @@ class name, i.e. C<< $term->x_resource ("boldFont") >> should return the
same value as used by this instance of rxvt-unicode. Returns C if no
resource with that pattern exists.
+Extensions that define extra resource or command line arguments also need
+to call this method to access their values.
+
+If the method is called on an extension object (basically, from an
+extension), then the special prefix C<%.> will be replaced by the name of
+the extension and a dot, and the lone string C<%> will be replcaed by the
+extension name itself. This makes it possible to code extensions so you
+can rename them and get a new set of commandline switches and resources
+without having to change the actual code.
+
This method should only be called during the C hook, as there is
only one resource database per display, and later invocations might return
the wrong resources.
-----END OF PAGE-----