diff options
author | Sterling Camden <sterling@camdensoftware.com> | 2011-09-03 18:47:03 -0700 |
---|---|---|
committer | Sterling Camden <sterling@camdensoftware.com> | 2011-09-03 18:47:03 -0700 |
commit | 50d9193da2d1258f742d27b9e3b529ad610c48c3 (patch) | |
tree | 0c63e9f9cd1125c0c54cd95792d1d5f454b1d25b | |
parent | e58067a17b1ff52fb82a97e524b4c61dd252c11b (diff) |
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".
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | url-picker | 24 |
2 files changed, 20 insertions, 9 deletions
@@ -58,6 +58,10 @@ anything. 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. @@ -79,6 +83,7 @@ URxvt.url-picker.input.foregroundColor Fg color for numbers typed 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 @@ -26,6 +26,7 @@ sub on_user_command { 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 = $&; @@ -39,15 +40,19 @@ sub on_user_command { 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(); @@ -200,6 +205,7 @@ sub on_start { $self->{launcher} = $self->my_resource("launcher") || $self->x_resource("urlLauncher") || "sensible-browser"; + $self->{descending} = ($self->my_resource("order") eq "descending"); $self->{url_picker} = (); } |