ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/searchable-scrollback
(Generate patch)

Comparing rxvt-unicode/src/perl/searchable-scrollback (file contents):
Revision 1.25 by sf-exg, Thu Apr 1 18:36:23 2010 UTC vs.
Revision 1.36 by sf-exg, Sat May 31 08:33:47 2014 UTC

1#! perl 1#! perl
2 2
3# this extension implements scrollback buffer search 3# this extension implements scrollback buffer search
4 4
5#:META:RESOURCE:%:string:activation hotkey keysym
6#:META:BINDING:M-s:start
7
8=head1 NAME
9
10searchable-scrollback - incremental scrollback search (enabled by default)
11
12=head1 DESCRIPTION
13
14Adds regex search functionality to the scrollback buffer, triggered by
15the C<searchable-scrollback:start> action (bound to C<M-s> by
16default). While in search mode, normal terminal input/output is
17suspended and a regex is displayed at the bottom of the screen.
18
19Inputting characters appends them to the regex and continues incremental
20search. C<BackSpace> removes a character from the regex, C<Up> and C<Down>
21search upwards/downwards in the scrollback buffer, C<End> jumps to the
22bottom. C<Escape> leaves search mode and returns to the point where search
23was started, while C<Enter> or C<Return> stay at the current position and
24additionally stores the first match in the current line into the primary
25selection if the C<Shift> modifier is active.
26
27The regex defaults to "(?i)", resulting in a case-insensitive search. To
28get a case-sensitive search you can delete this prefix using C<BackSpace>
29or simply use an uppercase character which removes the "(?i)" prefix.
30
31See L<perlre> for more info about perl regular expression syntax.
32
33=cut
34
5sub on_init { 35sub on_init {
6 my ($self) = @_; 36 my ($self) = @_;
7 37
38 # only for backwards compatibility
8 my $hotkey = $self->{argv}[0] 39 my $hotkey = $self->{argv}[0]
9 || $self->x_resource ("searchable-scrollback") 40 || $self->x_resource ("%")
10 || "M-s"; 41 || return;
11 42
12 $self->parse_keysym ($hotkey, "perl:searchable-scrollback:start") 43 $self->bind_action ($hotkey, "searchable-scrollback:start") # ugh
13 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";
14 45
15 () 46 ()
16} 47}
17 48
18sub on_user_command { 49sub on_action {
19 my ($self, $cmd) = @_; 50 my ($self, $action) = @_;
20 51
21 $cmd eq "searchable-scrollback:start" 52 $action eq "start"
22 and $self->enter; 53 and $self->enter;
23 54
24 () 55 ()
25} 56}
26 57
60 $self->disable ("key_press", "tt_write", "refresh_begin", "refresh_end"); 91 $self->disable ("key_press", "tt_write", "refresh_begin", "refresh_end");
61 $self->pty_ev_events ($self->{pty_ev_events}); 92 $self->pty_ev_events ($self->{pty_ev_events});
62 93
63 delete $self->{manpage_overlay}; 94 delete $self->{manpage_overlay};
64 delete $self->{overlay}; 95 delete $self->{overlay};
65 delete $self->{history};
66 delete $self->{search}; 96 delete $self->{search};
67} 97}
68 98
69sub idle { 99sub idle {
70 my ($self) = @_; 100 my ($self) = @_;
160 190
161 $self->{search} .= $self->locale_decode ($data); 191 $self->{search} .= $self->locale_decode ($data);
162 192
163 $self->{search} =~ s/^\(\?i\)// 193 $self->{search} =~ s/^\(\?i\)//
164 if $self->{search} =~ /^\(.*[[:upper:]]/; 194 if $self->{search} =~ /^\(.*[[:upper:]]/;
165 195
166 $self->search (-1); 196 $self->search (-1);
167 $self->idle; 197 $self->idle;
168 198
169 1 199 1
170} 200}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines