-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 51d9a40d0d665664dee1a447c7cccc0630e27540: path_to: revision_to:
commit 51d9a40d0d665664dee1a447c7cccc0630e27540 Author: Marc Lehmann <schmorp@schmorp.de> Date: Mon Feb 6 06:14:08 2006 +0000 *** empty log message *** diff --git a/Changes b/Changes
--- a/Changes +++ b/Changes @@ -12,8 +12,6 @@ WISH: anyevent mouse notification / manage MotionMask better. WISH: http://www120.pair.com/mccarthy/nextstep/intro.htmld/Workspace.html is the correct nextstep look. DUMB: support tex fonts -TODO: option popup hook, make some exts switchable - - changed interpretation of [alpha] colour prefix. - +option now really sets the option to default, instead of using the resource value. @@ -22,6 +20,8 @@ TODO: option popup hook, make some exts switchable relevant tab window. - tab colours are now configurable and have sensible defaults (initial patch by hednod). + - option menu is extendable, readline, selection and + selection-autotransform can now be disabled/enabled at runtime. - forcing a configure event to tabbed subwindows with -pe tabbed, for the benefit of automove-background. - the automove-background extension added a wrong constant offset. diff --git a/src/perl/option-popup b/src/perl/option-popup
--- 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
--- 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
--- 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
--- 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
--- 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<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 @@ -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",
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 11:45:11 2024