1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | # this extension implements scrollback buffer search |
3 | # this extension implements scrollback buffer search |
4 | |
4 | |
5 | #:META:X_RESOURCE:%:string:activation hotkey keysym |
5 | #:META:RESOURCE:%:string:activation hotkey keysym |
|
|
6 | #:META:BINDING:M-s:start |
|
|
7 | |
|
|
8 | =head1 NAME |
|
|
9 | |
|
|
10 | searchable-scrollback<hotkey> - incremental scrollback search (enabled by default) |
|
|
11 | |
|
|
12 | =head1 DESCRIPTION |
|
|
13 | |
|
|
14 | Adds regex search functionality to the scrollback buffer, triggered |
|
|
15 | by a hotkey (default: C<M-s>). While in search mode, normal terminal |
|
|
16 | input/output is suspended and a regex is displayed at the bottom of the |
|
|
17 | screen. |
|
|
18 | |
|
|
19 | Inputting characters appends them to the regex and continues incremental |
|
|
20 | search. C<BackSpace> removes a character from the regex, C<Up> and C<Down> |
|
|
21 | search upwards/downwards in the scrollback buffer, C<End> jumps to the |
|
|
22 | bottom. C<Escape> leaves search mode and returns to the point where search |
|
|
23 | was started, while C<Enter> or C<Return> stay at the current position and |
|
|
24 | additionally stores the first match in the current line into the primary |
|
|
25 | selection if the C<Shift> modifier is active. |
|
|
26 | |
|
|
27 | The regex defaults to "(?i)", resulting in a case-insensitive search. To |
|
|
28 | get a case-sensitive search you can delete this prefix using C<BackSpace> |
|
|
29 | or simply use an uppercase character which removes the "(?i)" prefix. |
|
|
30 | |
|
|
31 | See L<perlre> for more info about perl regular expression syntax. |
|
|
32 | |
|
|
33 | =cut |
6 | |
34 | |
7 | sub on_init { |
35 | sub on_init { |
8 | my ($self) = @_; |
36 | my ($self) = @_; |
9 | |
37 | |
|
|
38 | # only for backwards compatibility |
10 | my $hotkey = $self->{argv}[0] |
39 | my $hotkey = $self->{argv}[0] |
11 | || $self->x_resource ("searchable-scrollback") |
40 | || $self->x_resource ("%") |
12 | || "M-s"; |
41 | || return; |
13 | |
42 | |
14 | $self->parse_keysym ($hotkey, "perl:searchable-scrollback:start") |
43 | $self->bind_action ($hotkey, "searchable-scrollback:start") # ugh |
15 | or warn "unable to register '$hotkey' as scrollback search start hotkey\n"; |
44 | or warn "unable to register '$hotkey' as scrollback search start hotkey\n"; |
16 | |
45 | |
17 | () |
46 | () |
18 | } |
47 | } |
19 | |
48 | |
20 | sub on_user_command { |
49 | sub on_action { |
21 | my ($self, $cmd) = @_; |
50 | my ($self, $action) = @_; |
22 | |
51 | |
23 | $cmd eq "searchable-scrollback:start" |
52 | $action eq "start" |
24 | and $self->enter; |
53 | and $self->enter; |
25 | |
54 | |
26 | () |
55 | () |
27 | } |
56 | } |
28 | |
57 | |