url-select: Unset underline flag after partial redraw
This fixes the behaviour where after redraw of only parts of the line the underline flag was still being set even though the new line doesn't match anymore. This can be simulated for example by starting an editor, typing a URL and changing e.g. the http:// part to xttp:// without changing the line length (vim: rx) where the part beginning with ttp:// keeps being underlined. This commit sets the 3rd custom rendition bit (starting at 0) of a cell iff the underline was being added as a result of the cell being part of a match. If so, on a line update these underline flags get cleared again (together with the custom rendition bit) to be then re-set after a (possible) successful match.
This commit is contained in:
parent
10c64a552f
commit
cc8e579de0
21
url-select
21
url-select
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
# The custom rendition bit to use for marking the cell as being underlined
|
||||||
|
# by us so we can unset it again after a line has changed.
|
||||||
|
use constant UNDERLINED => 1<<3; # arbitrarily chosen in hope of no collision
|
||||||
|
|
||||||
sub on_start {
|
sub on_start {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
@ -94,17 +98,30 @@ sub line_update {
|
|||||||
my $text = $line->t;
|
my $text = $line->t;
|
||||||
my $rend = $line->r;
|
my $rend = $line->r;
|
||||||
|
|
||||||
|
# clear all underlines that were set by us
|
||||||
|
for (@$rend) {
|
||||||
|
if (urxvt::GET_CUSTOM($_) & UNDERLINED) {
|
||||||
|
$_ = urxvt::SET_CUSTOM($_, urxvt::GET_CUSTOM($_)
|
||||||
|
& ~UNDERLINED) & ~urxvt::RS_Uline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for my $pattern (@{$self->{pattern}}) {
|
for my $pattern (@{$self->{pattern}}) {
|
||||||
while ($text =~ /$pattern/g) {
|
while ($text =~ /$pattern/g) {
|
||||||
my $url = $&;
|
my $url = $&;
|
||||||
my ($beg, $end) = ($-[0], $+[0] - 1);
|
my ($beg, $end) = ($-[0], $+[0] - 1);
|
||||||
|
|
||||||
for (@{$rend}[$beg .. $end]) {
|
for (@{$rend}[$beg .. $end]) {
|
||||||
|
unless ($_ & urxvt::RS_Uline) {
|
||||||
|
$_ = urxvt::SET_CUSTOM($_, urxvt::GET_CUSTOM($_)
|
||||||
|
| UNDERLINED);
|
||||||
$_ |= urxvt::RS_Uline;
|
$_ |= urxvt::RS_Uline;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$line->r($rend);
|
$line->r($rend);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user