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.7 by sf-tpope, Tue Aug 30 20:02:32 2011 UTC vs.
Revision 1.8 by root, Wed Jun 6 15:06:41 2012 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
6#:META:X_RESOURCE:%.launcher:string:default launcher command
7#:META:X_RESOURCE:%.button:string:the button, yeah
8#:META:X_RESOURCE:%.pattern.:string:extra pattern to match
9#:META:X_RESOURCE:%.launcher.:string:custom launcher for pattern
10#:META:X_RESOURCE:%.rend.:string:custom rednition for pattern
5 11
6my $url = 12my $url =
7 qr{ 13 qr{
8 (?:https?://|ftp://|news://|mailto:|file://|\bwww\.) 14 (?:https?://|ftp://|news://|mailto:|file://|\bwww\.)
9 [a-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27,~#]* 15 [a-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27,~#]*
146sub on_start { 152sub on_start {
147 my ($self) = @_; 153 my ($self) = @_;
148 154
149 ($self->{name} = __PACKAGE__) =~ s/.*:://; 155 ($self->{name} = __PACKAGE__) =~ s/.*:://;
150 $self->{name} =~ tr/_/-/; 156 $self->{name} =~ tr/_/-/;
151 $self->{launcher} = $self->my_resource("launcher") || 157 $self->{launcher} = $self->my_resource ("launcher") || $self->x_resource("url-launcher") || "sensible-browser";
152 $self->x_resource("urlLauncher") ||
153 "sensible-browser";
154 158
155 $self->{urls} = []; 159 $self->{urls} = [];
156 $self->{showing} = 0; 160 $self->{showing} = 0;
157 $self->{button} = 2; 161 $self->{button} = 2;
158 $self->{state} = 0; 162 $self->{state} = 0;
159 if($self->{argv}[0] || $self->my_resource("button")) { 163 if($self->{argv}[0] || $self->my_resource ("button")) {
160 my @mods = split('', $self->{argv}[0] || $self->my_resource("button")); 164 my @mods = split '', $self->{argv}[0] || $self->my_resource ("button");
161 for my $mod (@mods) { 165 for my $mod (@mods) {
162 if($mod =~ /^\d+$/) { 166 if($mod =~ /^\d+$/) {
163 $self->{button} = $mod; 167 $self->{button} = $mod;
164 } elsif($mod eq "C") { 168 } elsif($mod eq "C") {
165 $self->{state} |= urxvt::ControlMask; 169 $self->{state} |= urxvt::ControlMask;
173 } 177 }
174 } 178 }
175 179
176 my @defaults = ($url); 180 my @defaults = ($url);
177 my @matchers; 181 my @matchers;
178 for (my $idx = 0; defined (my $res = $self->my_resource("pattern.$idx") || $defaults[$idx]); $idx++) { 182 for (my $idx = 0; defined (my $res = $self->my_resource ("pattern.$idx") || $defaults[$idx]); $idx++) {
179 $res = $self->locale_decode ($res); 183 $res = $self->locale_decode ($res);
180 utf8::encode $res; 184 utf8::encode $res;
181 my $launcher = $self->my_resource("launcher.$idx"); 185 my $launcher = $self->my_resource ("launcher.$idx");
182 $launcher =~ s/\$&|\$\{&\}/\${0}/g if ($launcher); 186 $launcher =~ s/\$&|\$\{&\}/\${0}/g if $launcher;
183 my $rend = $self->parse_rend($self->my_resource("rend.$idx")); 187 my $rend = $self->parse_rend($self->my_resource ("rend.$idx"));
184 unshift @matchers, [qr($res)x,$launcher,$rend]; 188 unshift @matchers, [qr($res)x,$launcher,$rend];
185 } 189 }
186 $self->{matchers} = \@matchers; 190 $self->{matchers} = \@matchers;
187 191
188 () 192 ()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines