From 3d4e49cca34c02608cf30b7abaea42db6f692da6 Mon Sep 17 00:00:00 2001
From: root
Date: Mon, 6 Feb 2006 06:14:08 +0000
Subject: [PATCH] *** empty log message ***
---
Changes | 2 +-
doc/rxvtperl.3.html | 34 +++++++++++++++++++++++++------
doc/rxvtperl.3.man.in | 35 ++++++++++++++++++++++++--------
doc/rxvtperl.3.txt | 29 ++++++++++++++++++++------
src/perl/option-popup | 10 +++++++--
src/perl/readline | 14 ++++++++++++-
src/perl/selection | 9 ++++++++
src/perl/selection-autotransform | 9 ++++++++
src/urxvt.pm | 35 ++++++++++++++++++++++++--------
9 files changed, 144 insertions(+), 33 deletions(-)
diff --git a/Changes b/Changes
index 35d2848f..b328ec99 100644
--- a/Changes
+++ b/Changes
@@ -4,7 +4,7 @@ TODO: event mechanism that replaces on_keyboard_command with something more scal
TODO: overlays collide with the way the out-of-focus cursor is being drawn
TODO: split perl documentation and urxvt.pm into separate files
TODO: harmonize --disable-options into position-dependent options.
-TODO: "slow" rendering mode for bidi and scripts
+TODO: "slow" rendering mode for bidi and scripts, pango!
TODO: read property sequence is broken with respect to utf-8 etc.
TODO: slow drag selection on remote display - other things seem fast (rxvt illness?)
WISH: look into XAddConnectionWatch, does anybody need that?
diff --git a/doc/rxvtperl.3.html b/doc/rxvtperl.3.html
index 2facb2ee..d960b45a 100644
--- a/doc/rxvtperl.3.html
+++ b/doc/rxvtperl.3.html
@@ -156,6 +156,28 @@ Rot-13 the selection when activated. Used via keyboard trigger:
Binds a popup menu to Ctrl-Button2 that lets you toggle (some) options at
runtime.
+
+Other extensions can extend this popup menu by pushing a code reference
+onto @{ $term-
{option_popup_hook} }>, which gets called whenever the
+popup is being displayed.
+
+
+It's sole argument is the popup menu, which can be modified. It should
+either return nothing or a string, the initial boolean value and a code
+reference. The string will be used as button text and the code reference
+will be called when the toggle changes, with the new boolean value as
+first argument.
+
+
+The following will add an entry myoption
that changes
+$self-
{myoption}>:
+
+
+
+ push @{ $self->{term}{option_popup_hook} }, sub {
+ ("my option" => $myoption, sub { $self->{myoption} = $_[0] })
+ };
+
selection-popup (enabled by default)
@@ -166,8 +188,8 @@ evaluation, web-browser starting etc.), depending on content.
Other extensions can extend this popup menu by pushing a code reference
-onto @{ $term-
{selection_popup_hook} }>, that is called whenever the
-popup is displayed.
+onto @{ $term-
{selection_popup_hook} }>, which gets called whenever the
+popup is being displayed.
It's sole argument is the popup menu, which can be modified. The selection
@@ -1641,12 +1663,12 @@ Adds a clickable button to the popup. $cb
is called whenever it is
selected.
-$popup->add_toggle ($text, $cb, $initial_value)
+$popup->add_toggle ($text, $initial_value, $cb)
-Adds a toggle/checkbox item to the popup. Teh callback gets called
-whenever it gets toggled, with a boolean indicating its value as its first
-argument.
+Adds a toggle/checkbox item to the popup. The callback gets called
+whenever it gets toggled, with a boolean indicating its new value as its
+first argument.
$popup->show
diff --git a/doc/rxvtperl.3.man.in b/doc/rxvtperl.3.man.in
index 9e752301..3eaf0fcd 100644
--- a/doc/rxvtperl.3.man.in
+++ b/doc/rxvtperl.3.man.in
@@ -236,6 +236,25 @@ Rot\-13 the selection when activated. Used via keyboard trigger:
.IX Item "option-popup (enabled by default)"
Binds a popup menu to Ctrl\-Button2 that lets you toggle (some) options at
runtime.
+.Sp
+Other extensions can extend this popup menu by pushing a code reference
+onto \f(CW\*(C`@{ $term\-\*(C'\fR{option_popup_hook} }>, which gets called whenever the
+popup is being displayed.
+.Sp
+It's sole argument is the popup menu, which can be modified. It should
+either return nothing or a string, the initial boolean value and a code
+reference. The string will be used as button text and the code reference
+will be called when the toggle changes, with the new boolean value as
+first argument.
+.Sp
+The following will add an entry \f(CW\*(C`myoption\*(C'\fR that changes
+\&\f(CW\*(C`$self\-\*(C'\fR{myoption}>:
+.Sp
+.Vb 3
+\& push @{ $self->{term}{option_popup_hook} }, sub {
+\& ("my option" => $myoption, sub { $self->{myoption} = $_[0] })
+\& };
+.Ve
.IP "selection-popup (enabled by default)" 4
.IX Item "selection-popup (enabled by default)"
Binds a popup menu to Ctrl\-Button3 that lets you convert the selection
@@ -243,8 +262,8 @@ text into various other formats/action (such as uri unescaping, perl
evaluation, web-browser starting etc.), depending on content.
.Sp
Other extensions can extend this popup menu by pushing a code reference
-onto \f(CW\*(C`@{ $term\-\*(C'\fR{selection_popup_hook} }>, that is called whenever the
-popup is displayed.
+onto \f(CW\*(C`@{ $term\-\*(C'\fR{selection_popup_hook} }>, which gets called whenever the
+popup is being displayed.
.Sp
It's sole argument is the popup menu, which can be modified. The selection
is in \f(CW$_\fR, which can be used to decide wether to add something or not.
@@ -1425,12 +1444,12 @@ Creates a separator, optionally using the character given as \f(CW$sepchr\fR.
.IX Item "$popup->add_button ($text, $cb)"
Adds a clickable button to the popup. \f(CW$cb\fR is called whenever it is
selected.
-.ie n .IP "$popup\->add_toggle ($text, $cb\fR, \f(CW$initial_value)" 4
-.el .IP "$popup\->add_toggle ($text, \f(CW$cb\fR, \f(CW$initial_value\fR)" 4
-.IX Item "$popup->add_toggle ($text, $cb, $initial_value)"
-Adds a toggle/checkbox item to the popup. Teh callback gets called
-whenever it gets toggled, with a boolean indicating its value as its first
-argument.
+.ie n .IP "$popup\->add_toggle ($text, $initial_value\fR, \f(CW$cb)" 4
+.el .IP "$popup\->add_toggle ($text, \f(CW$initial_value\fR, \f(CW$cb\fR)" 4
+.IX Item "$popup->add_toggle ($text, $initial_value, $cb)"
+Adds a toggle/checkbox item to the popup. The callback gets called
+whenever it gets toggled, with a boolean indicating its new value as its
+first argument.
.IP "$popup\->show" 4
.IX Item "$popup->show"
Displays the popup (which is initially hidden).
diff --git a/doc/rxvtperl.3.txt b/doc/rxvtperl.3.txt
index 10f69910..9a4b0cfe 100644
--- a/doc/rxvtperl.3.txt
+++ b/doc/rxvtperl.3.txt
@@ -81,6 +81,23 @@ PREPACKAGED EXTENSIONS
Binds a popup menu to Ctrl-Button2 that lets you toggle (some)
options at runtime.
+ Other extensions can extend this popup menu by pushing a code
+ reference onto "@{ $term-"{option_popup_hook} }>, which gets called
+ whenever the popup is being displayed.
+
+ It's sole argument is the popup menu, which can be modified. It
+ should either return nothing or a string, the initial boolean value
+ and a code reference. The string will be used as button text and the
+ code reference will be called when the toggle changes, with the new
+ boolean value as first argument.
+
+ The following will add an entry "myoption" that changes
+ "$self-"{myoption}>:
+
+ push @{ $self->{term}{option_popup_hook} }, sub {
+ ("my option" => $myoption, sub { $self->{myoption} = $_[0] })
+ };
+
selection-popup (enabled by default)
Binds a popup menu to Ctrl-Button3 that lets you convert the
selection text into various other formats/action (such as uri
@@ -88,8 +105,8 @@ PREPACKAGED EXTENSIONS
on content.
Other extensions can extend this popup menu by pushing a code
- reference onto "@{ $term-"{selection_popup_hook} }>, that is called
- whenever the popup is displayed.
+ reference onto "@{ $term-"{selection_popup_hook} }>, which gets
+ called whenever the popup is being displayed.
It's sole argument is the popup menu, which can be modified. The
selection is in $_, which can be used to decide wether to add
@@ -1069,10 +1086,10 @@ API DOCUMENTATION
Adds a clickable button to the popup. $cb is called whenever it is
selected.
- $popup->add_toggle ($text, $cb, $initial_value)
- Adds a toggle/checkbox item to the popup. Teh callback gets called
- whenever it gets toggled, with a boolean indicating its value as its
- first argument.
+ $popup->add_toggle ($text, $initial_value, $cb)
+ Adds a toggle/checkbox item to the popup. The callback gets called
+ whenever it gets toggled, with a boolean indicating its new value as
+ its first argument.
$popup->show
Displays the popup (which is initially hidden).
diff --git a/src/perl/option-popup b/src/perl/option-popup
index 30a1852c..1953bab4 100644
--- a/src/perl/option-popup
+++ b/src/perl/option-popup
@@ -29,8 +29,14 @@ sub on_button_press {
my $optval = $urxvt::OPTION{$name};
- $popup->add_toggle ($name => sub { $self->option ($optval, $_[0]) },
- $self->option ($optval));
+ $popup->add_toggle ($name => $self->option ($optval),
+ sub { $self->option ($optval, $_[0]) });
+ }
+
+ for my $hook (@{ $self->{term}{option_popup_hook} || [] }) {
+ if (my ($name, $value, $cb) = $hook->($popup)) {
+ $popup->add_toggle ($name => $value, sub { $cb->($_[0]) });
+ }
}
$popup->show;
diff --git a/src/perl/readline b/src/perl/readline
index a8b9b253..b824fc44 100644
--- a/src/perl/readline
+++ b/src/perl/readline
@@ -4,11 +4,23 @@ use POSIX ();
my $termios = new POSIX::Termios;
+sub on_init {
+ my ($self) = @_;
+
+ $self->{enabled} = 1;
+
+ push @{ $self->{term}{option_popup_hook} }, sub {
+ ("readline" => $self->{enabled}, sub { $self->{enabled} = shift })
+ };
+
+ ()
+}
+
sub on_button_press {
my ($self, $event) = @_;
return
- if $self->current_screen || $self->hidden_cursor;
+ if $self->current_screen || $self->hidden_cursor || !$self->{enabled};
$termios->getattr ($self->pty_fd)
or return;
diff --git a/src/perl/selection b/src/perl/selection
index 2a34fbce..d1cfc410 100644
--- a/src/perl/selection
+++ b/src/perl/selection
@@ -23,6 +23,12 @@ sub on_init {
push @{ $self->{patterns} }, qr/$res/;
}
+ $self->{enabled} = 1;
+
+ push @{ $self->{term}{option_popup_hook} }, sub {
+ ("new selection" => $self->{enabled}, sub { $self->{enabled} = shift })
+ };
+
()
}
@@ -64,6 +70,9 @@ my @simplify_patterns = (
sub on_sel_extend {
my ($self, $time) = @_;
+ $self->{enabled}
+ or return;
+
my ($row, $col) = $self->selection_mark;
my $line = $self->line ($row);
my $text = $line->t;
diff --git a/src/perl/selection-autotransform b/src/perl/selection-autotransform
index 699ce9a4..6d0f0463 100644
--- a/src/perl/selection-autotransform
+++ b/src/perl/selection-autotransform
@@ -25,12 +25,21 @@ sub on_init {
}
}
+ $self->{enabled} = 1;
+
+ push @{ $self->{term}{option_popup_hook} }, sub {
+ ("autotransform" => $self->{enabled}, sub { $self->{enabled} = shift })
+ };
+
()
}
sub on_sel_grab {
my ($self) = @_;
+ $self->{enabled}
+ or return;
+
my $text = $self->selection;
local $_ = $text;
diff --git a/src/urxvt.pm b/src/urxvt.pm
index da356cfb..8b11b787 100644
--- a/src/urxvt.pm
+++ b/src/urxvt.pm
@@ -96,6 +96,23 @@ Rot-13 the selection when activated. Used via keyboard trigger:
Binds a popup menu to Ctrl-Button2 that lets you toggle (some) options at
runtime.
+Other extensions can extend this popup menu by pushing a code reference
+onto C<@{ $term->{option_popup_hook} }>, which gets called whenever the
+popup is being displayed.
+
+It's sole argument is the popup menu, which can be modified. It should
+either return nothing or a string, the initial boolean value and a code
+reference. The string will be used as button text and the code reference
+will be called when the toggle changes, with the new boolean value as
+first argument.
+
+The following will add an entry C that changes
+C<$self->{myoption}>:
+
+ push @{ $self->{term}{option_popup_hook} }, sub {
+ ("my option" => $myoption, sub { $self->{myoption} = $_[0] })
+ };
+
=item selection-popup (enabled by default)
Binds a popup menu to Ctrl-Button3 that lets you convert the selection
@@ -103,8 +120,8 @@ text into various other formats/action (such as uri unescaping, perl
evaluation, web-browser starting etc.), depending on content.
Other extensions can extend this popup menu by pushing a code reference
-onto C<@{ $term->{selection_popup_hook} }>, that is called whenever the
-popup is displayed.
+onto C<@{ $term->{selection_popup_hook} }>, which gets called whenever the
+popup is being displayed.
It's sole argument is the popup menu, which can be modified. The selection
is in C<$_>, which can be used to decide wether to add something or not.
@@ -856,11 +873,11 @@ sub invoke {
}
}
- while (my ($ext, $argv) = each %ext_arg) {
+ for my $ext (sort keys %ext_arg) {
my @files = grep -f $_, map "$_/$ext", @dirs;
if (@files) {
- $TERM->register_package (extension_package $files[0], $argv);
+ $TERM->register_package (extension_package $files[0], $ext_arg{$ext});
} else {
warn "perl extension '$ext' not found in perl library search path\n";
}
@@ -1801,16 +1818,16 @@ sub add_button {
$self->add_item ({ type => "button", text => $text, activate => $cb});
}
-=item $popup->add_toggle ($text, $cb, $initial_value)
+=item $popup->add_toggle ($text, $initial_value, $cb)
-Adds a toggle/checkbox item to the popup. Teh callback gets called
-whenever it gets toggled, with a boolean indicating its value as its first
-argument.
+Adds a toggle/checkbox item to the popup. The callback gets called
+whenever it gets toggled, with a boolean indicating its new value as its
+first argument.
=cut
sub add_toggle {
- my ($self, $text, $cb, $value) = @_;
+ my ($self, $text, $value, $cb) = @_;
my $item; $item = {
type => "button",
--
2.34.1