-- 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: be9380c0ec2f1c568152591faccbbfdb2d77dee5:
path_to:
revision_to:

git.thebackupbox.net

rxvt-unicode-sixel

git://git.thebackupbox.net/rxvt-unicode-sixel

commit be9380c0ec2f1c568152591faccbbfdb2d77dee5
Author: Marc Lehmann <schmorp@schmorp.de>
Date:   Wed Jan 18 10:11:03 2006 +0000

    *** empty log message ***

diff --git a/src/perl/selection-pastebin b/src/perl/selection-pastebin

index 64f4a3193a39417dd12b8bc387cc9718d2efd1cb..

index ..731dcff524e3f65ebb40e57ffc6389abfe6b9f2c 100644

--- a/src/perl/selection-pastebin
+++ b/src/perl/selection-pastebin
@@ -4,19 +4,6 @@ my $timers = {};
 my $pastebin_cmd;
 my $pastebin_url;

-sub on_start {
-   my ($self) = @_;
-   $pastebin_cmd =
-      $self->x_resource ("selection-pastebin.cmd")
-      or "scp -p % ruth:/var/www/www.ta-sa.org/files/txt/";
-
-   $pastebin_url =
-      $self->x_resource ("selection-pastebin.url")
-      or "http://www.ta-sa.org/files/txt/";
-
-   ()
-}
-
 sub upload_paste {
    my ($self) = @_;

@@ -61,11 +48,27 @@ sub upload_paste {
               ->cb (sub { delete $timers->{ov}; delete $timers->{t1}; });
 }

+sub on_start {
+   my ($self) = @_;
+   $pastebin_cmd = $self->x_resource ("selection-pastebin.cmd")
+                   || "scp -p % ruth:/var/www/www.ta-sa.org/files/txt/";
+
+   $pastebin_url = $self->x_resource ("selection-pastebin.url")
+                   || "http://www.ta-sa.org/files/txt/%";
+
+   push @urxvt::ext::selection_popup::hook, sub {
+      ("pastebin upload" => sub { $self->upload_paste })
+   };
+
+   ()
+}
+
 sub on_keyboard_command {
    my ($self, $cmd) = @_;

-   $cmd eq "selection-pastebin:remote-pastebin"
-      and upload_paste ($self);
+   if ($cmd eq "selection-pastebin:remote-pastebin") {
+      $self->upload_paste;
+   }

    ()
 }
diff --git a/src/perl/selection-popup b/src/perl/selection-popup

index c50d520ca80363bf568b017684f8798a844128ca..

index ..24c08eff9ad4eeffceb9948ed6fed7050d07138c 100644

--- a/src/perl/selection-popup
+++ b/src/perl/selection-popup
@@ -21,6 +21,8 @@ sub on_start {
    ()
 }

+our @hook;
+
 sub on_button_press {
    my ($self, $event) = @_;

@@ -71,6 +73,12 @@ sub on_button_press {
          /^(http|ftp|telnet|irc|news):\//
             and $add_button->("run $self->{browser}" => sub { urxvt::exec_async $self->{browser}, $_ });

+         for my $hook (@hook) {
+            if (my ($title, $cb) = $hook->($popup)) {
+               $add_button->($title, $cb);
+            }
+         }
+
          if (/^\s*((?:0x)?\d+)\s*$/) {
             $popup->add_title (sprintf "%20s", eval $1);
             $popup->add_title (sprintf "%20s", sprintf "0x%x", eval $1);
diff --git a/src/urxvt.pm b/src/urxvt.pm

index 0a32ee5217fc05c2ef6e8a2f70fa83f197d8aced..

index ..f332a1307d85af31c06189950e2c9dd101ed0cb9 100644

--- a/src/urxvt.pm
+++ b/src/urxvt.pm
@@ -91,6 +91,24 @@ Binds a popup menu to Ctrl-Button3 that lets you convert the selection
 text into various other formats/action (such as uri unescaping, perl
 evalution, web-browser starting etc.), depending on content.

+Other extensions can extend this popup menu by pushing a code reference onto
+C<@urxvt::ext::selection_popup::hook>, that is called whenever the popup is 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.
+It should either return nothing or a string and a code reference. The
+string will be used as button text and the code reference will be called
+when the button gets activated and should transform C<$_>.
+
+The following will add an entry C<a to b> that transforms all C<a>s in
+the selection to C<b>s, but only if the selection currently contains any
+C<a>s:
+
+   push urxvt::ext::selection_popup::hook, sub {
+      /a/ ? ("a to be" => sub { s/a/b/g }
+          : ()
+   };
+
 =item searchable-scrollback<hotkey> (enabled by default)

 Adds regex search functionality to the scrollback buffer, triggered

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 10:35:12 2024