Commits

Anonymous committed 9d5f75c

Added support for reversing the order of numbered labels, so that the last link is always "1". Enable by setting resource "URxvt.url-picker.order" to "descending".

  • Participants
  • Parent commits ff493aa

Comments (0)

Files changed (2)

 Enter launches the URL associated with the number that has been typed, if
 that number matches one of the URL labels.  Otherwise, nothing happens.
 
+The labels are numbered in ascending order starting with 1 by default.  You can
+cause them to be numbered in reverse order (so that the last link is always
+number 1) by setting the resource "URxvt.url-picker.order" to "descending".
+
 When typing numbers, if the number typed so far uniquely identifies a
 URL, that URL is launched immediately.  Otherwise, the labels that do not
 match the numbers typed so far will be hidden.
 URxvt.url-picker.label.backgroundColor	Bg color for numbered labels
 URxvt.url-picker.label.foregroundColor	Fg color for numbered labels
 URxvt.url-picker.launcher		Browser override
+URXVT.url-picker.order			"descending" numbers in reverse
 URxvt.url-picker.prompt.backgroundColor	Bg color for "Follow:" prompt
 URxvt.url-picker.prompt.foregroundColor	Fg color for "Follow:" prompt
 URxvt.url-picker.status.backgroundColor	Bg color for status messages
     my $text = '';
     my $label_rend = $self->get_rend("label", urxvt::OVERLAY_RSTYLE);
     my $label_urls = sub {
+                       my @overlays;
                        while ($text =~ /$url/g) {
                          my $ndx = $-[0];
                          my $href = $&;
                              last;
                            }
                          }
-                         if ($row >= 0) {    # must be visible
-                            $num++;
-                            my $overlay = $self->overlay(
-                              $col, $row, $self->strwidth($num), 1, $label_rend, 0
-                            );
-                            $overlay->set(0,0,$num);
-                            $labels->{$num} = $overlay;
-                            $hrefs->{$num} = $href;
-                         }
+                         my @ov = ($col, $row, $href);
+                         push(@overlays, \@ov) if ($row >= 0);
+                       }
+                       @overlays = reverse @overlays if ($self->{descending});
+                       for my $ov (@overlays) {
+                         my ($col, $row, $href) = @$ov;
+                         $num++;
+                         my $overlay = $self->overlay(
+                           $col, $row, $self->strwidth($num), 1, $label_rend, 0
+                         );
+                         $overlay->set(0,0,$num);
+                         $labels->{$num} = $overlay;
+                         $hrefs->{$num} = $href;
                        }
                      };
     my ($brow, $bcol) = $self->selection_beg();
   $self->{launcher} = $self->my_resource("launcher") ||
                       $self->x_resource("urlLauncher") ||
                       "sensible-browser";
+  $self->{descending} = ($self->my_resource("order") eq "descending");
   $self->{url_picker} = ();
 }