… | |
… | |
10 | \([a-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27,~#]*\)| # Allow a pair of matched parentheses |
10 | \([a-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27,~#]*\)| # Allow a pair of matched parentheses |
11 | [a-zA-Z0-9\-\@;\/?:&=%\$_+*~] # exclude some trailing characters (heuristic) |
11 | [a-zA-Z0-9\-\@;\/?:&=%\$_+*~] # exclude some trailing characters (heuristic) |
12 | )+ |
12 | )+ |
13 | }x; |
13 | }x; |
14 | |
14 | |
15 | #sub on_user_command { |
15 | sub on_user_command { |
16 | # my ($self, $cmd) = @_; |
16 | my ($self, $cmd) = @_; |
17 | # if($cmd =~ s/^matcher\b//) { |
17 | if($cmd =~ s/^matcher\b//) { |
18 | # $self->most_recent; |
18 | $self->most_recent; |
19 | # } |
19 | } |
|
|
20 | () |
|
|
21 | } |
|
|
22 | |
|
|
23 | sub most_recent { |
|
|
24 | my ($self) = shift; |
20 | # my $row = $self->nrow; |
25 | my $row = $self->nrow; |
21 | # my @exec; |
26 | my @exec; |
22 | # while($row-- > $self->top_row) { |
27 | while($row-- > $self->top_row) { |
23 | # #my $line = $self->line ($row); |
28 | #my $line = $self->line ($row); |
24 | # #my $text = $line->t; |
29 | #my $text = $line->t; |
25 | # @exec = $self->command_for($row); |
30 | @exec = $self->command_for($row); |
26 | # last if(@exec); |
31 | last if(@exec); |
27 | # } |
32 | } |
28 | # if(@exec) { |
33 | if(@exec) { |
29 | # return $self->exec_async (@exec); |
34 | return $self->exec_async (@exec); |
30 | # } |
35 | } |
31 | # () |
36 | () |
32 | #} |
37 | } |
33 | # |
|
|
34 | #sub most_recent { |
|
|
35 | # my ($self) = shift; |
|
|
36 | # () |
|
|
37 | #} |
|
|
38 | |
38 | |
39 | sub my_resource { |
39 | sub my_resource { |
40 | my $self = shift; |
40 | my $self = shift; |
41 | $self->x_resource ("$self->{name}.$_[0]"); |
41 | $self->x_resource ("$self->{name}.$_[0]"); |
42 | } |
42 | } |
… | |
… | |
162 | () |
162 | () |
163 | } |
163 | } |
164 | |
164 | |
165 | sub on_button_press { |
165 | sub on_button_press { |
166 | my ($self, $event) = @_; |
166 | my ($self, $event) = @_; |
167 | if($self->valid_button($event)) { |
167 | if($self->valid_button($event) |
|
|
168 | && (my @exec = $self->command_for($event->{row},$event->{col}))) { |
168 | $self->{row} = $event->{row}; |
169 | $self->{row} = $event->{row}; |
169 | $self->{col} = $event->{col}; |
170 | $self->{col} = $event->{col}; |
|
|
171 | $self->{cmd} = \@exec; |
|
|
172 | return 1; |
170 | } else { |
173 | } else { |
171 | delete $self->{row}; |
174 | delete $self->{row}; |
172 | delete $self->{col}; |
175 | delete $self->{col}; |
|
|
176 | delete $self->{cmd}; |
173 | } |
177 | } |
174 | |
178 | |
175 | () |
179 | () |
176 | } |
180 | } |
177 | |
181 | |
178 | sub on_button_release { |
182 | sub on_button_release { |
179 | my ($self, $event) = @_; |
183 | my ($self, $event) = @_; |
180 | |
184 | |
181 | my $row = delete $self->{row}; |
185 | my $row = delete $self->{row}; |
182 | my $col = delete $self->{col}; |
186 | my $col = delete $self->{col}; |
|
|
187 | my $cmd = delete $self->{cmd}; |
183 | |
188 | |
|
|
189 | return if !defined $row; |
|
|
190 | |
184 | if(defined($row) && $row == $event->{row} && abs($col-$event->{col}) < 2) { |
191 | if($row == $event->{row} && abs($col-$event->{col}) < 2 |
|
|
192 | && join("\x00", @$cmd) eq join("\x00", $self->command_for($row,$col))) { |
185 | if($self->valid_button($event)) { |
193 | if($self->valid_button($event)) { |
186 | |
194 | |
187 | my @exec = $self->command_for($row,$col); |
195 | $self->exec_async (@$cmd); |
188 | if(@exec) { |
196 | |
189 | return $self->exec_async (@exec); |
|
|
190 | } |
197 | } |
191 | |
|
|
192 | } |
|
|
193 | } |
198 | } |
194 | |
199 | |
195 | () |
200 | 1; |
196 | } |
201 | } |
197 | |
202 | |
198 | # vim:set sw=3 sts=3 et: |
203 | # vim:set sw=3 sts=3 et: |