-- 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: 9052eca6f969cd89652bd62225f5d8bdae4036c4:
path_to:
revision_to:

git.thebackupbox.net

rxvt-unicode-sixel

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

commit 9052eca6f969cd89652bd62225f5d8bdae4036c4
Author: Tim Pope <code@tpope.net>
Date:   Fri Aug 19 23:08:35 2011 +0000

    Keyboard accessible list of recent matches in matcher

diff --git a/Changes b/Changes

index 2720199c43bc8de44671c7fc45a77eafd6c621c3..

index ..efad21cace2953001fbd01dd0f0b6460a33da341 100644

--- a/Changes
+++ b/Changes
@@ -40,6 +40,8 @@ TODO: split ROW into a ROW_fast (0..total*2-1) and ROW macros?
 	- Fix compilation on systems with bsd style utmp and no utmpx,
 	  such as openbsd.
 	- consume button release event in matcher (exg).
+	- keyboard accessible list of recent matches in matcher
+	  (Bob Farrell).

 9.12 Wed Jun 29 14:34:28 CEST 2011
         - fix regression in processing of SelectionNotify events.
diff --git a/src/perl/matcher b/src/perl/matcher

index 22cb60ba37232a5a8e7101b5fbbc8aa0c837ea9a..

index ..136bb7ff645ed14d76bb558992c0fd58b758a0b7 100644

--- a/src/perl/matcher
+++ b/src/perl/matcher
@@ -1,6 +1,7 @@
 #! perl

 # Author: Tim Pope <rxvt-unicodeNOSPAM@tpope.info>
+#          Bob Farrell <robertanthonyfarrell@gmail.com>

 my $url =
    qr{
@@ -12,21 +13,107 @@ my $url =
       )+
    }x;

+sub on_key_press {
+   my ($self, $event, $keysym, $octets) = @_;
+
+   if (! $self->{showing} ) {
+      return;
+   }
+
+   my $i = ($keysym == 96 ? 0 : $keysym - 48);
+   if (($i > scalar(@{$self->{urls}})) || ($i < 0)) {
+      $self->matchlist();
+      return;
+   }
+
+   my @args = ($self->{urls}[ -$i-1 ]);
+   $self->matchlist();
+
+   $self->exec_async( $self->{launcher}, @args );
+}
+
 sub on_user_command {
    my ($self, $cmd) = @_;
-   if($cmd =~ s/^matcher\b//) {
-      $self->most_recent;
+
+   if($cmd =~ s/^matcher:list\b//) {
+      $self->matchlist();
+   } else {
+      if($cmd =~ s/^matcher:last\b//) {
+         $self->most_recent;
+      }
+   # For backward compatibility
+    else {
+      if($cmd =~ s/^matcher\b//) {
+         $self->most_recent;
+      }
    }
+  }
    ()
 }

+sub matchlist {
+   my ($self) = @_;
+   if ( $self->{showing} ) {
+     $self->{url_overlay}->hide();
+     $self->{showing} = 0;
+     return;
+   }
+  @{$self->{urls}} = ();
+  my $line;
+  for (my $i = 0; $i < $self->nrow; $i ++) {
+     $line = $self->line($i);
+     next if ($line->beg != $i);
+     for my $url ($self->get_urls_from_line($line->t)) {
+        if (scalar(@{$self->{urls}}) == 10) {
+            shift @{$self->{urls}};
+        }
+        push @{$self->{urls}}, $url;
+     }
+  }
+
+  if (! scalar(@{$self->{urls}})) {
+    return;
+  }
+
+  my $max = 0;
+  my $i = scalar( @{$self->{urls}} ) - 1 ;;
+
+  my @temp = ();
+
+  for my $url (@{$self->{urls}}) {
+     my $url = "$i-$url";
+     my $xpos = 0;
+
+     if ($self->ncol + (length $url) >= $self->ncol) {
+        $url = substr( $url, 0, $self->ncol );
+     }
+
+     push @temp, $url;
+
+     if( length $url > $max ) {
+        $max = length $url;
+     }
+
+     $i--;
+  }
+
+  @temp = reverse @temp;
+
+  $self->{url_overlay} = $self->overlay(0, 0, $max, scalar( @temp ), urxvt::OVERLAY_RSTYLE, 2);
+  my $i = 0;
+  for my $url (@temp) {
+     $self->{url_overlay}->set( 0, $i, $url, [(urxvt::OVERLAY_RSTYLE) x length $url]);
+	$self->{showing} = 1;
+     $i++;
+  }
+
+}
+
 sub most_recent {
    my ($self) = shift;
    my $row = $self->nrow;
    my @exec;
    while($row-- > $self->top_row) {
-      #my $line = $self->line ($row);
-      #my $text = $line->t;
       @exec = $self->command_for($row);
       last if(@exec);
    }
@@ -44,7 +131,7 @@ sub my_resource {
 # turn a rendition spec in the resource into a sub that implements it on $_
 sub parse_rend {
    my ($self, $str) = @_;
-   my ($mask, $fg, $bg, $failed) = $str ? urxvt::rend2mask($str)
+   my ($mask, $fg, $bg, $failed) = $str ? urxvt::rend2mask($str)
                                         : (urxvt::RS_Uline, undef, undef, []);
    warn "Failed to parse rendition string: " . join(',', @$failed) if @$failed;
    my @rend;
@@ -65,6 +152,8 @@ sub on_start {
                       $self->x_resource("urlLauncher") ||
                       "sensible-browser";

+   $self->{urls} = [];
+   $self->{showing} = 0;
    $self->{button}  = 2;
    $self->{state}   = 0;
    if($self->{argv}[0] || $self->my_resource("button")) {
@@ -99,6 +188,17 @@ sub on_start {
    ()
 }

+sub get_urls_from_line {
+   my ($self, $line) = @_;
+   my @urls;
+   for my $matcher (@{$self->{matchers}}) {
+     while ($line =~ /$matcher->[0]/g) {
+        push @urls, substr( $line, $-[0], $+[0] - $-[0] );
+     }
+   }
+   return @urls;
+}
+
 sub on_line_update {
    my ($self, $row) = @_;

diff --git a/src/urxvt.pm b/src/urxvt.pm

index 9ab5b311186325a1e43927cf3b0a54156921ce0f..

index ..2e0b05cbba600c038a51aa247d1a39d2bdb085ca 100644

--- a/src/urxvt.pm
+++ b/src/urxvt.pm
@@ -261,14 +261,16 @@ C<matcher.pattern.0> resource, and additional patterns can be specified
 with numbered patterns, in a manner similar to the "selection" extension.
 The launcher can also be overridden on a per-pattern basis.

-It is possible to activate the most recently seen match from the keyboard.
-Simply bind a keysym to "perl:matcher" as seen in the example below.
+It is possible to activate the most recently seen match or a list of matches
+from the keyboard.  Simply bind a keysym to "perl:matcher:last" or
+"perl:matcher:list" as seen in the example below.

 Example configuration:

     URxvt.perl-ext:           default,matcher
     URxvt.urlLauncher:        sensible-browser
-    URxvt.keysym.C-Delete:    perl:matcher
+    URxvt.keysym.C-Delete:    perl:matcher:last
+    URxvt.keysym.M-Delete:    perl:matcher:list
     URxvt.matcher.button:     1
     URxvt.matcher.pattern.1:  \\bwww\\.[\\w-]+\\.[\\w./?&@#-]*[\\w/-]
     URxvt.matcher.pattern.2:  \\B(/\\S+?):(\\d+)(?=:|$)

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

-- Response ended

-- Page fetched on Sun Jun 2 09:52:17 2024