*** empty log message ***
authorroot <root>
Mon, 6 Feb 2006 06:14:08 +0000 (06:14 +0000)
committerroot <root>
Mon, 6 Feb 2006 06:14:08 +0000 (06:14 +0000)
Changes
doc/rxvtperl.3.html
doc/rxvtperl.3.man.in
doc/rxvtperl.3.txt
src/perl/option-popup
src/perl/readline
src/perl/selection
src/perl/selection-autotransform
src/urxvt.pm

diff --git a/Changes b/Changes
index 35d2848fc05be5df61fd178fb05ff1741ee3009a..b328ec99077f1716ae2e9f80b19fc8a198944677 100644 (file)
--- 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?
index 2facb2ee1e2ffed4e49be5eb9ac5b5655d77e42d..d960b45abf54420dc6f2c975c9bf996dc42ee5ed 100644 (file)
@@ -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.
 </dd>
+<dd>
+<p>Other extensions can extend this popup menu by pushing a code reference
+onto <code>@{ $term-</code>{option_popup_hook} }&gt;, 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}&gt;:</p>
+</dd>
+<dd>
+<pre>
+   push @{ $self-&gt;{term}{option_popup_hook} }, sub {
+      (&quot;my option&quot; =&gt; $myoption, sub { $self-&gt;{myoption} = $_[0] })
+   };</pre>
+</dd>
 <p></p>
 <dt><strong>selection-popup (enabled by default)</strong><br />
 </dt>
@@ -166,8 +188,8 @@ evaluation, web-browser starting etc.), depending on content.
 </dd>
 <dd>
 <p>Other extensions can extend this popup menu by pushing a code reference
-onto <code>@{ $term-</code>{selection_popup_hook} }&gt;, that is called whenever the
-popup is displayed.</p>
+onto <code>@{ $term-</code>{selection_popup_hook} }&gt;, 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
@@ -1641,12 +1663,12 @@ Adds a clickable button to the popup. <code>$cb</code> is called whenever it is
 selected.
 </dd>
 <p></p>
-<dt><strong><a name="item_add_toggle">$popup-&gt;add_toggle ($text, $cb, $initial_value)</a></strong><br />
+<dt><strong><a name="item_add_toggle">$popup-&gt;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-&gt;show</strong><br />
index 9e7523011a6ad6a13c83df3f3e76812baf246074..3eaf0fcda3e54b9105ce92f4a30e60e605e5d854 100644 (file)
@@ -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).
index 10f699105dacd0e817202fb38ffb46d1b2ac1c98..9a4b0cfe2d3a856661785a0fc35626346db5fd21 100644 (file)
@@ -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).
index 30a1852c799730b8ae02a75d55a3519f72263f77..1953bab405ccecd9aa45befead13e3b9d09107e3 100644 (file)
@@ -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;
index a8b9b2531b04e7f86a7d88c6ce0271d3e00901f7..b824fc44f25874da618cef54a294fc8c5615064a 100644 (file)
@@ -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;
index 2a34fbcedb28793aa43d3fa3a49c8d297dedb607..d1cfc41048f75b1f06acd5f03f5aefebfe5670c9 100644 (file)
@@ -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;
index 699ce9a47687083c99dd215c28f9eadad89899e9..6d0f046330675096bc7eb9030aac679a7076a114 100644 (file)
@@ -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;
 
index da356cfb889b1ad31200216a7dad65c7336c9b30..8b11b78748b8126fb727ce0ebd5b01d07c11a876 100644 (file)
@@ -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",