--- rxvt-unicode/src/urxvt.pm 2006/02/06 05:40:15 1.132 +++ rxvt-unicode/src/urxvt.pm 2006/02/06 06:14:08 1.133 @@ -96,6 +96,23 @@ 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 @@ 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 @@ } } - 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 @@ $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",