Hi,

the attached patch fixes an issue in the matcher perl extension where
after a redraw of only parts of the line the custom renditions are still
applied even though the pattern doesn't match anymore, as discussed in
e.g. <[email protected]>.

It does so by storing the original rendition in the
urxvt::term::extension object and setting a custom rendition bit (that
has been arbitrarily chosen in the hope that no other extension uses it)
that is used to indicate that the rendition has been modified by matcher
and should be restored.

That's a similiar patch that I've posted to
<https://github.com/muennich/urxvt-perls/pull/59> earlier, FWIW.

This patch is against latest CVS version 1.35. (Do you really still use
CVS?)

Cheers,

    Sebastian
Index: src/perl/matcher
===================================================================
RCS file: /schmorpforge/rxvt-unicode/src/perl/matcher,v
retrieving revision 1.35
diff -u -r1.35 matcher
--- src/perl/matcher	17 Mar 2015 09:25:16 -0000	1.35
+++ src/perl/matcher	23 Mar 2015 20:49:50 -0000
@@ -90,6 +90,10 @@
 
 =cut
 
+# The custom rendition bit to use for indicating that this has cell has its
+# rendition set by us and its previous rendition should be restored.
+use constant REND_SET => 1<<2; # arbitrarily chosen
+
 my $url =
    qr{
       (?:https?://|ftp://|news://|mailto:|file://|\bwww\.)
@@ -272,22 +276,33 @@
    # fetch the line that has changed
    my $line = $self->line ($row);
    my $text = $line->t;
-   my $rend;
+   my $rend = $line->r;
+
+   # reset all renditions on characters that were not redrawed (i.e. have the
+   # RAND_SET custom bit set)
+   foreach my $col (0..$#$rend) {
+      if (urxvt::GET_CUSTOM($rend->[$col]) & REND_SET) {
+         $rend->[$col] = $self->{saved_rend}->[$row]->[$col];
+      }
+   }
 
    # find all urls (if any)
    for my $matcher (@{$self->{matchers}}) {
       while ($text =~ /$matcher->[0]/g) {
          #print "$&\n";
-         $rend ||= $line->r;
 
-         # mark all characters as underlined. we _must_ not toggle underline,
-         # as we might get called on an already-marked url.
-         &{$matcher->[2]}
-            for @{$rend}[$-[0] .. $+[0] - 1];
+         # store original rendition, apply each matcher's rendition setter and set
+         # the RAND_SET'th custom rendition bit so we can restore the rendition
+         # later above.
+         for my $col ($-[0] .. $+[0] - 1) {
+            $_ = $self->{saved_rend}->[$row]->[$col] = $rend->[$col];
+            &{$matcher->[2]}; # modifies $_
+            $rend->[$col] = urxvt::SET_CUSTOM($_, REND_SET);
+         }
       }
    }
 
-   $line->r ($rend) if $rend;
+   $line->r ($rend);
 
    ()
 }
_______________________________________________
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode

Reply via email to