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.25 by sf-exg, Fri Jun 13 21:49:19 2014 UTC vs.
Revision 1.26 by sf-exg, Fri Jun 13 21:57:16 2014 UTC

57 \([\w\-\@;\/?:&=%\$.+!*\x27,~#]*\)| # Allow a pair of matched parentheses 57 \([\w\-\@;\/?:&=%\$.+!*\x27,~#]*\)| # Allow a pair of matched parentheses
58 [\w\-\@;\/?:&=%\$+*~] # exclude some trailing characters (heuristic) 58 [\w\-\@;\/?:&=%\$+*~] # exclude some trailing characters (heuristic)
59 )+ 59 )+
60 }x; 60 }x;
61 61
62sub on_key_press { 62sub matchlist_key_press {
63 my ($self, $event, $keysym, $octets) = @_; 63 my ($self, $event, $keysym, $octets) = @_;
64 64
65 return unless $self->{overlay};
66
67 delete $self->{overlay}; 65 delete $self->{overlay};
66 $self->disable ("key_press");
68 67
69 my $i = ($keysym == 96 ? 0 : $keysym - 48); 68 my $i = ($keysym == 96 ? 0 : $keysym - 48);
70 if ($i >= 0 && $i < @{ $self->{matches} }) { 69 if ($i >= 0 && $i < @{ $self->{matches} }) {
71 my @exec = @{ $self->{matches}[$i] }; 70 my @exec = @{ $self->{matches}[$i] };
72 shift @exec;
73 $self->exec_async (@exec); 71 $self->exec_async (@exec[5 .. $#exec]);
74 } 72 }
75 73
76 1 74 1
77} 75}
78 76
107} 105}
108 106
109sub matchlist { 107sub matchlist {
110 my ($self) = @_; 108 my ($self) = @_;
111 109
112 @{ $self->{matches} } = (); 110 $self->{matches} = [];
113 my $row = $self->nrow - 1; 111 my $row = $self->nrow - 1;
114 while ($row >= 0 && @{ $self->{matches} } < 10) { 112 while ($row >= 0 && @{ $self->{matches} } < 10) {
115 my $line = $self->line ($row); 113 my $line = $self->line ($row);
116 my @matches = $self->find_matches ($row); 114 my @matches = $self->find_matches ($row);
117 115
118 for (sort { $b->[0] <=> $a->[0] } @matches) { 116 for (sort { $b->[0] <=> $a->[0] or $b->[1] <=> $a->[1] } @matches) {
119 shift @$_;
120 push @{ $self->{matches} }, $_; 117 push @{ $self->{matches} }, $_;
121 last if @{ $self->{matches} } == 10; 118 last if @{ $self->{matches} } == 10;
122 } 119 }
123 120
124 $row = $line->beg - 1; 121 $row = $line->beg - 1;
128 125
129 my $width = 0; 126 my $width = 0;
130 127
131 my $i = 0; 128 my $i = 0;
132 for my $match (@{ $self->{matches} }) { 129 for my $match (@{ $self->{matches} }) {
133 my $text = $match->[0]; 130 my $text = $match->[4];
134 my $w = $self->strwidth ("$i-$text"); 131 my $w = $self->strwidth ("$i-$text");
135 132
136 $width = $w if $w > $width; 133 $width = $w if $w > $width;
137 $i++; 134 $i++;
138 } 135 }
140 $width = $self->ncol - 2 if $width > $self->ncol - 2; 137 $width = $self->ncol - 2 if $width > $self->ncol - 2;
141 138
142 $self->{overlay} = $self->overlay (0, 0, $width, scalar (@{ $self->{matches} }), urxvt::OVERLAY_RSTYLE, 2); 139 $self->{overlay} = $self->overlay (0, 0, $width, scalar (@{ $self->{matches} }), urxvt::OVERLAY_RSTYLE, 2);
143 my $i = 0; 140 my $i = 0;
144 for my $match (@{ $self->{matches} }) { 141 for my $match (@{ $self->{matches} }) {
145 my $text = $match->[0]; 142 my $text = $match->[4];
146 143
147 $self->{overlay}->set (0, $i, "$i-$text"); 144 $self->{overlay}->set (0, $i, "$i-$text");
148 $i++; 145 $i++;
149 } 146 }
150 147
148 $self->enable (key_press => \&matchlist_key_press);
151} 149}
152 150
153sub most_recent { 151sub most_recent {
154 my ($self) = shift; 152 my ($self) = shift;
155 my $row = $self->nrow; 153 my $row = $self->nrow;
186sub on_start { 184sub on_start {
187 my ($self) = @_; 185 my ($self) = @_;
188 186
189 $self->{launcher} = $self->my_resource ("launcher") || $self->x_resource("url-launcher") || "sensible-browser"; 187 $self->{launcher} = $self->my_resource ("launcher") || $self->x_resource("url-launcher") || "sensible-browser";
190 188
191 $self->{matches} = [];
192 $self->{button} = 2; 189 $self->{button} = 2;
193 $self->{state} = 0; 190 $self->{state} = 0;
194 if($self->{argv}[0] || $self->my_resource ("button")) { 191 if($self->{argv}[0] || $self->my_resource ("button")) {
195 my @mods = split '', $self->{argv}[0] || $self->my_resource ("button"); 192 my @mods = split '', $self->{argv}[0] || $self->my_resource ("button");
196 for my $mod (@mods) { 193 for my $mod (@mods) {
281 @exec = map { s/\$(\d+)|\$\{(\d+)\}/ 278 @exec = map { s/\$(\d+)|\$\{(\d+)\}/
282 substr $text, $begin[$1 || $2], $end[$1 || $2] - $begin[$1 || $2] 279 substr $text, $begin[$1 || $2], $end[$1 || $2] - $begin[$1 || $2]
283 /egx; $_ } split /\s+/, $launcher; 280 /egx; $_ } split /\s+/, $launcher;
284 } 281 }
285 282
286 push @matches, [ $begin[0], $match, @exec ]; 283 push @matches, [ $line->coord_of ($begin[0]), $line->coord_of ($end[0]), $match, @exec ];
287 } 284 }
288 } 285 }
289 } 286 }
290 287
291 @matches; 288 @matches;
295 my ($self, $row, $col) = @_; 292 my ($self, $row, $col) = @_;
296 293
297 my @matches = $self->find_matches ($row, $col); 294 my @matches = $self->find_matches ($row, $col);
298 if (@matches) { 295 if (@matches) {
299 my @match = @{ $matches[0] }; 296 my @match = @{ $matches[0] };
300 return @match[2 .. $#match]; 297 return @match[5 .. $#match];
301 } 298 }
302 299
303 () 300 ()
304} 301}
305 302

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines