aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSterling Camden <sterling@camdensoftware.com>2010-11-24 15:58:01 -0800
committerSterling Camden <sterling@camdensoftware.com>2010-11-24 15:58:01 -0800
commitc5da709e41a5f7fe6ded2e4d4974e356b3e6633d (patch)
tree8b2bfee46d6385dbbc9b5d09ec869b7411273aaa
parentb398b6d6ad331c2b25fee97376f981adc7121251 (diff)
Correct search and labeling of URLs in visible scrollback region.
-rw-r--r--README4
-rw-r--r--url-picker16
2 files changed, 13 insertions, 7 deletions
diff --git a/README b/README
index fc12ca3..03a02d8 100644
--- a/README
+++ b/README
@@ -37,7 +37,7 @@ search for URLs will be restricted to that region. Otherwise, the visible
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.
@@ -46,7 +46,7 @@ The browser is determined by X resources url-picker.launcher if defined,
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
diff --git a/url-picker b/url-picker
index adb1831..027d966 100644
--- a/url-picker
+++ b/url-picker
@@ -14,6 +14,11 @@ my $url =
)+
}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//) {
@@ -38,25 +43,26 @@ sub on_user_command {
};
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 = {};