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?
Binds a popup menu to Ctrl-Button2 that lets you toggle (some) options at
runtime.
</dd>
+<dd>
+<p>Other extensions can extend this popup menu by pushing a code reference
+onto <code>@{ $term-</code>{option_popup_hook} }>, which gets called whenever the
+popup is being displayed.</p>
+</dd>
+<dd>
+<p>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.</p>
+</dd>
+<dd>
+<p>The following will add an entry <code>myoption</code> that changes
+<code>$self-</code>{myoption}>:</p>
+</dd>
+<dd>
+<pre>
+ push @{ $self->{term}{option_popup_hook} }, sub {
+ ("my option" => $myoption, sub { $self->{myoption} = $_[0] })
+ };</pre>
+</dd>
<p></p>
<dt><strong>selection-popup (enabled by default)</strong><br />
</dt>
</dd>
<dd>
<p>Other extensions can extend this popup menu by pushing a code reference
-onto <code>@{ $term-</code>{selection_popup_hook} }>, that is called whenever the
-popup is displayed.</p>
+onto <code>@{ $term-</code>{selection_popup_hook} }>, which gets called whenever the
+popup is being displayed.</p>
</dd>
<dd>
<p>It's sole argument is the popup menu, which can be modified. The selection
selected.
</dd>
<p></p>
-<dt><strong><a name="item_add_toggle">$popup->add_toggle ($text, $cb, $initial_value)</a></strong><br />
+<dt><strong><a name="item_add_toggle">$popup->add_toggle ($text, $initial_value, $cb)</a></strong><br />
</dt>
<dd>
-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.
</dd>
<p></p>
<dt><strong>$popup->show</strong><br />
.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
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.
.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).
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
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
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).
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;
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;
push @{ $self->{patterns} }, qr/$res/;
}
+ $self->{enabled} = 1;
+
+ push @{ $self->{term}{option_popup_hook} }, sub {
+ ("new selection" => $self->{enabled}, sub { $self->{enabled} = shift })
+ };
+
()
}
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;
}
}
+ $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;
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<myoption> 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
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.
}
}
- 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";
}
$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",