… | |
… | |
4 | |
4 | |
5 | #:META:RESOURCE:%:string:activation hotkey keysym |
5 | #:META:RESOURCE:%:string:activation hotkey keysym |
6 | |
6 | |
7 | =head1 NAME |
7 | =head1 NAME |
8 | |
8 | |
9 | searchable-scrollback - incremental scrollback search (enabled by default) |
9 | searchable-scrollback - incremental scrollback search |
10 | |
10 | |
11 | =head1 DESCRIPTION |
11 | =head1 DESCRIPTION |
12 | |
12 | |
13 | Adds regex search functionality to the scrollback buffer, triggered by |
13 | Adds regex search functionality to the scrollback buffer, triggered by |
14 | the C<searchable-scrollback:start> action (bound to C<M-s> by |
14 | the C<searchable-scrollback:start> action (bound to C<M-s> by |
15 | default). While in search mode, normal terminal input/output is |
15 | default). While in search mode, normal terminal input/output is |
16 | suspended and a regex is displayed at the bottom of the screen. |
16 | suspended and a regex is displayed at the bottom of the screen. |
17 | |
17 | |
18 | Inputting characters appends them to the regex and continues incremental |
18 | Inputting characters appends them to the regex and continues incremental |
19 | search. C<BackSpace> removes a character from the regex, C<Up> and C<Down> |
19 | search. In addition, the following bindings are recognized: |
20 | search upwards/downwards in the scrollback buffer, C<End> jumps to the |
20 | |
21 | bottom. C<Escape> leaves search mode and returns to the point where search |
21 | =over |
22 | was started, while C<Enter> or C<Return> stay at the current position and |
22 | |
23 | additionally stores the first match in the current line into the primary |
23 | =item C<BackSpace> |
24 | selection if the C<Shift> modifier is active. |
24 | |
|
|
25 | Remove a character from the regex. |
|
|
26 | |
|
|
27 | =item C<Insert> |
|
|
28 | |
|
|
29 | Append the value of the PRIMARY selection to the regex. |
|
|
30 | |
|
|
31 | =item C<Up> |
|
|
32 | |
|
|
33 | Search for a match upwards. |
|
|
34 | |
|
|
35 | =item C<Down> |
|
|
36 | |
|
|
37 | Search for a match downwards. |
|
|
38 | |
|
|
39 | =item C<Prior> |
|
|
40 | |
|
|
41 | Scroll up. |
|
|
42 | |
|
|
43 | =item C<Next> |
|
|
44 | |
|
|
45 | Scroll down. |
|
|
46 | |
|
|
47 | =item C<End> |
|
|
48 | |
|
|
49 | Scroll to the bottom. |
|
|
50 | |
|
|
51 | =item C<Escape> |
|
|
52 | |
|
|
53 | Leave the mode and return to the point where search was started. |
|
|
54 | |
|
|
55 | =item C<Enter> or C<Return> |
|
|
56 | |
|
|
57 | Leave the mode maintaining the current position in the scrollback. |
|
|
58 | Additionally, if the C<Shift> modifier is active, store the first |
|
|
59 | match in the current line into the primary selection. |
|
|
60 | |
|
|
61 | =back |
25 | |
62 | |
26 | The regex defaults to "(?i)", resulting in a case-insensitive search. To |
63 | The regex defaults to "(?i)", resulting in a case-insensitive search. To |
27 | get a case-sensitive search you can delete this prefix using C<BackSpace> |
64 | get a case-sensitive search you can delete this prefix using C<BackSpace> |
28 | or simply use an uppercase character which removes the "(?i)" prefix. |
65 | or simply use an uppercase character which removes the "(?i)" prefix. |
29 | |
66 | |
… | |
… | |
37 | # only for backwards compatibility |
74 | # only for backwards compatibility |
38 | my $hotkey = $self->{argv}[0] |
75 | my $hotkey = $self->{argv}[0] |
39 | || $self->x_resource ("%") |
76 | || $self->x_resource ("%") |
40 | || "M-s"; |
77 | || "M-s"; |
41 | |
78 | |
42 | $self->bind_action ($hotkey, "searchable-scrollback:start") |
79 | $self->bind_action ($hotkey, "%:start") |
43 | or warn "unable to register '$hotkey' as scrollback search start hotkey\n"; |
80 | or warn "unable to register '$hotkey' as scrollback search start hotkey\n"; |
44 | |
81 | |
45 | () |
82 | () |
46 | } |
83 | } |
47 | |
84 | |
… | |
… | |
129 | do { |
166 | do { |
130 | push @{ $self->{found} }, [$line->coord_of ($-[0]), $line->coord_of ($+[0])]; |
167 | push @{ $self->{found} }, [$line->coord_of ($-[0]), $line->coord_of ($+[0])]; |
131 | } while $text =~ /$re/g; |
168 | } while $text =~ /$re/g; |
132 | |
169 | |
133 | $self->{row} = $row; |
170 | $self->{row} = $row; |
134 | $self->view_start (List::Util::min 0, $row - ($self->nrow >> 1)); |
171 | $self->view_start ($row - ($self->nrow >> 1)); |
135 | $self->want_refresh; |
172 | $self->want_refresh; |
136 | return; |
173 | return; |
137 | } |
174 | } |
138 | |
175 | |
139 | $row = $dir < 0 ? $line->beg - 1 : $line->end + 1; |
176 | $row = $dir < 0 ? $line->beg - 1 : $line->end + 1; |
… | |
… | |
182 | if $line->beg > $self->top_row; |
219 | if $line->beg > $self->top_row; |
183 | } elsif ($keysym == 0xff54) { # down |
220 | } elsif ($keysym == 0xff54) { # down |
184 | my $line = $self->line ($self->{row}); |
221 | my $line = $self->line ($self->{row}); |
185 | $self->search (+1, $line->end + 1) |
222 | $self->search (+1, $line->end + 1) |
186 | if $line->end < $self->nrow; |
223 | if $line->end < $self->nrow; |
|
|
224 | } elsif ($keysym == 0xff55) { # prior |
|
|
225 | my $row = $self->view_start - ($self->nrow - 1); |
|
|
226 | $self->view_start ($row); |
|
|
227 | } elsif ($keysym == 0xff56) { # next |
|
|
228 | my $row = $self->view_start + ($self->nrow - 1); |
|
|
229 | $self->view_start ($row); |
|
|
230 | } elsif ($keysym == 0xff63) { # insert |
|
|
231 | $self->selection_request (urxvt::CurrentTime, 1); |
187 | } elsif ($keysym == 0xff08) { # backspace |
232 | } elsif ($keysym == 0xff08) { # backspace |
188 | substr $self->{search}, -1, 1, ""; |
233 | substr $self->{search}, -1, 1, ""; |
189 | $self->search (+1, $self->{row}); |
234 | $self->search (+1, $self->{row}); |
190 | $self->idle; |
235 | $self->idle; |
191 | } elsif ($string !~ /[\x00-\x1f\x80-\xaf]/) { |
236 | } elsif ($string !~ /[\x00-\x1f\x80-\xaf]/) { |
… | |
… | |
197 | |
242 | |
198 | sub tt_write { |
243 | sub tt_write { |
199 | my ($self, $data) = @_; |
244 | my ($self, $data) = @_; |
200 | |
245 | |
201 | $self->{search} .= $self->locale_decode ($data); |
246 | $self->{search} .= $self->locale_decode ($data); |
|
|
247 | $self->{search} =~ s/\e\[20[01]~//g; |
202 | |
248 | |
203 | $self->{search} =~ s/^\(\?i\)// |
249 | $self->{search} =~ s/^\(\?i\)// |
204 | if $self->{search} =~ /^\(.*[[:upper:]]/; |
250 | if $self->{search} =~ /^\(.*[[:upper:]]/; |
205 | |
251 | |
206 | delete $self->{found}; |
252 | delete $self->{found}; |