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.26 by sf-exg, Fri Jun 13 21:57:16 2014 UTC vs.
Revision 1.30 by sf-exg, Sat Jun 21 14:11:18 2014 UTC

5 5
6#:META:RESOURCE:%.launcher:string:default launcher command 6#:META:RESOURCE:%.launcher:string:default launcher command
7#:META:RESOURCE:%.button:string:the button, yeah 7#:META:RESOURCE:%.button:string:the button, yeah
8#:META:RESOURCE:%.pattern.:string:extra pattern to match 8#:META:RESOURCE:%.pattern.:string:extra pattern to match
9#:META:RESOURCE:%.launcher.:string:custom launcher for pattern 9#:META:RESOURCE:%.launcher.:string:custom launcher for pattern
10#:META:RESOURCE:%.rend.:string:custom rednition for pattern 10#:META:RESOURCE:%.rend.:string:custom rendition for pattern
11 11
12=head1 NAME 12=head1 NAME
13 13
14matcher - match strings in terminal output and change their rendition 14matcher - match strings in terminal output and change their rendition
15 15
224 my ($self, $row) = @_; 224 my ($self, $row) = @_;
225 225
226 # fetch the line that has changed 226 # fetch the line that has changed
227 my $line = $self->line ($row); 227 my $line = $self->line ($row);
228 my $text = $line->t; 228 my $text = $line->t;
229 my $i = 0;
230 229
231 # find all urls (if any) 230 # find all urls (if any)
232 for my $matcher (@{$self->{matchers}}) { 231 for my $matcher (@{$self->{matchers}}) {
233 while ($text =~ /$matcher->[0]/g) { 232 while ($text =~ /$matcher->[0]/g) {
234 #print "$&\n"; 233 #print "$&\n";
235 my $rend = $line->r; 234 my $rend = $line->r;
236 235
237 # mark all characters as underlined. we _must_ not toggle underline, 236 # mark all characters as underlined. we _must_ not toggle underline,
238 # as we might get called on an already-marked url. 237 # as we might get called on an already-marked url.
239 &{$matcher->[2]} 238 &{$matcher->[2]}
240 for @{$rend}[ $-[0] .. $+[0] - 1]; 239 for @{$rend}[$-[0] .. $+[0] - 1];
241 240
242 $line->r ($rend); 241 $line->r ($rend);
243 } 242 }
244 } 243 }
245 244
256 255
257sub find_matches { 256sub find_matches {
258 my ($self, $row, $col) = @_; 257 my ($self, $row, $col) = @_;
259 my $line = $self->line ($row); 258 my $line = $self->line ($row);
260 my $text = $line->t; 259 my $text = $line->t;
261 my $off = $line->offset_of ($row, $col) if $col; 260 my $off = $line->offset_of ($row, $col) if defined $col;
262 261
263 my @matches; 262 my @matches;
264 for my $matcher (@{$self->{matchers}}) { 263 for my $matcher (@{$self->{matchers}}) {
265 my $launcher = $matcher->[1] || $self->{launcher}; 264 my $launcher = $matcher->[1] || $self->{launcher};
266 while ($text =~ /$matcher->[0]/g) { 265 while ($text =~ /$matcher->[0]/g) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines