Commits

Sterling Camden  committed 4c115ca

Correct search and labeling of URLs in visible scrollback region.

  • Participants
  • Parent commits d09a349

Comments (0)

Files changed (2)

 text of the termainl will be used.
 
 If no URLs are found,  url-picker just pops up an overlay window that
-warns "no URLs found on visible screen" or "no URLs found in selected
+warns "no URLs found on visible screen" or "no URLs found in visible selected
 text".  The overlay disappears after five seconds, but the terminal is
 immediately operable.
 
 otherwise URxvt.urlLauncher.  If neither of these are defined, the
 'sensible-browser' is used.  The URL will be passed as the first argument.
 
-If more than one URL available in the region, url-picker places numbered
+If more than one URL is available in the region, url-picker places numbered
 labels over the first characters of each URL on the screen.  A prompt
 "Follow: " appears at the bottom of the terminal window, at which you
 can type only numbers, backspace, enter, or escape (all other input is
       )+
    }x;
 
+sub on_view_change {
+  my ($self, $offset) = @_;
+  $self->{view_offset} = $offset;
+}
+
 sub on_user_command {
   my ($self, $cmd) = @_;
   if ($cmd =~ s/^url-picker\b//) {
                      };
     my ($brow, $bcol) = $self->selection_beg();
     my ($erow, $ecol) = $self->selection_end();
+    my $offset = $self->{view_offset} || 0;
     my $issel = ($ecol > $bcol) || ($erow > $brow);
     if ($issel) {         # restrict to selection if one exists
-      ($row, $base_col) = ($brow, $bcol);
+      ($row, $base_col) = ($brow - $offset, $bcol);
       for (split(/\n/, $self->selection())) {
         $text = $_;
-        $label_urls->();
+        $label_urls->() if $row >= 0;  # must be visible
         $base_col = 0;
         $row++;
       }
     } else {            # no selection, use visible terminal
-      for (0..$self->nrow) {
+      for (0..($self->nrow - 1)) {
         $row = $_;
-        $text = $self->ROW_t($row);
+        $text = $self->ROW_t($row + $offset);
         $label_urls->();
       }
     }
 
     if ($num < 1) {
-      my $desc = $issel ? "in selected text" : "on visible screen";
+      my $desc = $issel ? "in visible selected text" : "on visible screen";
       $self->status_msg("url-picker: no URLs found $desc");
     } else {
       my $url_picker = {};