ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/matcher
(Generate patch)

Comparing rxvt-unicode/src/perl/matcher (file contents):
Revision 1.32 by sf-exg, Wed Jul 30 15:22:51 2014 UTC vs.
Revision 1.34 by sf-exg, Tue Oct 14 09:00:43 2014 UTC

1#! perl 1#! perl
2 2
3# Author: Tim Pope <rxvt-unicodeNOSPAM@tpope.org> 3# Author: Tim Pope <rxvt-unicodeNOSPAM@tpope.org>
4# Bob Farrell <robertanthonyfarrell@gmail.com> 4# Bob Farrell <robertanthonyfarrell@gmail.com>
5# Emanuele Giaquinta
5 6
6#:META:RESOURCE:%.launcher:string:default launcher command 7#:META:RESOURCE:%.launcher:string:default launcher command
7#:META:RESOURCE:%.button:string:the button, yeah 8#:META:RESOURCE:%.button:string:the mouse button used to activate a match
8#:META:RESOURCE:%.pattern.:string:extra pattern to match 9#:META:RESOURCE:%.pattern.:string:extra pattern to match
9#:META:RESOURCE:%.launcher.:string:custom launcher for pattern 10#:META:RESOURCE:%.launcher.:string:custom launcher for pattern
10#:META:RESOURCE:%.rend.:string:custom rendition for pattern 11#:META:RESOURCE:%.rend.:string:custom rendition for pattern
11 12
12=head1 NAME 13=head1 NAME
113 114
114# backwards compat 115# backwards compat
115sub on_user_command { 116sub on_user_command {
116 my ($self, $cmd) = @_; 117 my ($self, $cmd) = @_;
117 118
118 if ($cmd =~ s/^matcher:list\b//) { 119 if ($cmd eq "matcher:list") {
119 $self->matchlist; 120 $self->matchlist;
120 } else { 121 } elsif ($cmd eq "matcher:last") {
121 if ($cmd =~ s/^matcher:last\b//) {
122 $self->most_recent; 122 $self->most_recent;
123 } elsif ($cmd eq "matcher:select") {
124 $self->select_enter;
123 } elsif ($cmd =~ s/^matcher\b//) { 125 } elsif ($cmd eq "matcher") {
124 # for backward compatibility 126 # for backward compatibility
125 $self->most_recent; 127 $self->most_recent;
126 }
127 } 128 }
128 129
129 () 130 ()
130} 131}
131 132
266 my ($self, $row) = @_; 267 my ($self, $row) = @_;
267 268
268 # fetch the line that has changed 269 # fetch the line that has changed
269 my $line = $self->line ($row); 270 my $line = $self->line ($row);
270 my $text = $line->t; 271 my $text = $line->t;
272 my $rend;
271 273
272 # find all urls (if any) 274 # find all urls (if any)
273 for my $matcher (@{$self->{matchers}}) { 275 for my $matcher (@{$self->{matchers}}) {
274 while ($text =~ /$matcher->[0]/g) { 276 while ($text =~ /$matcher->[0]/g) {
275 #print "$&\n"; 277 #print "$&\n";
276 my $rend = $line->r; 278 $rend ||= $line->r;
277 279
278 # mark all characters as underlined. we _must_ not toggle underline, 280 # mark all characters as underlined. we _must_ not toggle underline,
279 # as we might get called on an already-marked url. 281 # as we might get called on an already-marked url.
280 &{$matcher->[2]} 282 &{$matcher->[2]}
281 for @{$rend}[$-[0] .. $+[0] - 1]; 283 for @{$rend}[$-[0] .. $+[0] - 1];
282
283 $line->r ($rend);
284 } 284 }
285 } 285 }
286
287 $line->r ($rend) if $rend;
286 288
287 () 289 ()
288} 290}
289 291
290sub valid_button { 292sub valid_button {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines