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.31 by sf-exg, Sun Jun 22 07:51:21 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
187 $self->enable (key_press => \&matchlist_key_press); 188 $self->enable (key_press => \&matchlist_key_press);
188} 189}
189 190
190sub most_recent { 191sub most_recent {
191 my ($self) = shift; 192 my ($self) = shift;
192 my $row = $self->nrow; 193 my $row = $self->nrow - 1;
193 my @exec; 194 my @exec;
194 while($row-- > $self->top_row) { 195 while ($row >= $self->top_row) {
196 my $line = $self->line ($row);
195 @exec = $self->command_for($row); 197 @exec = $self->command_for($row);
196 last if(@exec); 198 last if(@exec);
199
200 $row = $line->beg - 1;
197 } 201 }
198 if(@exec) { 202 if(@exec) {
199 return $self->exec_async (@exec); 203 return $self->exec_async (@exec);
200 } 204 }
201 () 205 ()
263 my ($self, $row) = @_; 267 my ($self, $row) = @_;
264 268
265 # fetch the line that has changed 269 # fetch the line that has changed
266 my $line = $self->line ($row); 270 my $line = $self->line ($row);
267 my $text = $line->t; 271 my $text = $line->t;
272 my $rend;
268 273
269 # find all urls (if any) 274 # find all urls (if any)
270 for my $matcher (@{$self->{matchers}}) { 275 for my $matcher (@{$self->{matchers}}) {
271 while ($text =~ /$matcher->[0]/g) { 276 while ($text =~ /$matcher->[0]/g) {
272 #print "$&\n"; 277 #print "$&\n";
273 my $rend = $line->r; 278 $rend ||= $line->r;
274 279
275 # mark all characters as underlined. we _must_ not toggle underline, 280 # mark all characters as underlined. we _must_ not toggle underline,
276 # as we might get called on an already-marked url. 281 # as we might get called on an already-marked url.
277 &{$matcher->[2]} 282 &{$matcher->[2]}
278 for @{$rend}[$-[0] .. $+[0] - 1]; 283 for @{$rend}[$-[0] .. $+[0] - 1];
279
280 $line->r ($rend);
281 } 284 }
282 } 285 }
286
287 $line->r ($rend) if $rend;
283 288
284 () 289 ()
285} 290}
286 291
287sub valid_button { 292sub valid_button {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines