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.7 by root, Mon Jan 9 23:30:01 2006 UTC vs.
Revision 1.8 by root, Tue Jan 10 04:23:39 2006 UTC

14} 14}
15 15
16sub on_keyboard_command { 16sub on_keyboard_command {
17 my ($self, $cmd) = @_; 17 my ($self, $cmd) = @_;
18 18
19 if ($cmd eq "searchable-scrollback:start") { 19 $cmd eq "searchable-scrollback:start"
20 $self->enter; 20 and $self->enter;
21 }
22 21
23 () 22 ()
24} 23}
25 24
26sub msg { 25sub msg {
33sub enter { 32sub enter {
34 my ($self) = @_; 33 my ($self) = @_;
35 34
36 return if $self->{overlay}; 35 return if $self->{overlay};
37 36
37 $self->{history} = [];
38 $self->{view_start} = $self->view_start;
38 $self->{pty_ev_events} = $self->pty_ev_events (urxvt::EVENT_NONE); 39 $self->{pty_ev_events} = $self->pty_ev_events (urxvt::EVENT_NONE);
39 $self->{view_start} = $self->view_start;
40 40
41 $self->enable ( 41 $self->enable (
42 key_press => \&key_press, 42 key_press => \&key_press,
43 tt_write => \&tt_write, 43 tt_write => \&tt_write,
44 refresh_begin => \&refresh, 44 refresh_begin => \&refresh,
45 refresh_end => \&refresh, 45 refresh_end => \&refresh,
46 ); 46 );
47 47
48 $self->{manpage_overlay} = $self->overlay (0, -2, $self->ncol, 1, urxvt::OVERLAY_RSTYLE, 0);
49 $self->{manpage_overlay}->set (0, 0, "scrollback search, see man ${urxvt::RXVTNAME}perl");
50
48 $self->idle; 51 $self->idle;
49} 52}
50 53
51sub leave { 54sub leave {
52 my ($self) = @_; 55 my ($self) = @_;
53 56
57 $self->disable ("key_press", "tt_write", "refresh_begin", "refresh_end");
58 $self->pty_ev_events ($self->{pty_ev_events});
59
60 delete $self->{manpage_overlay};
54 delete $self->{overlay}; 61 delete $self->{overlay};
55 62 delete $self->{history};
56 $self->disable ("key_press", "tt_write", "refresh_begin", "refresh_end");
57
58 $self->pty_ev_events ($self->{pty_ev_events});
59 $self->want_refresh;
60} 63}
61 64
62sub idle { 65sub idle {
63 my ($self) = @_; 66 my ($self) = @_;
64 67
65 $self->msg ("scrollback search, escape=exit, enter=accept, /=start search, n=next, p=previous, G=bottom"); 68 $self->msg ("escape=exit, enter=accept, /=start search, n=next, p=previous, G=bottom");
66 69
67 delete $self->{in_search}; 70 delete $self->{in_search};
68} 71}
69 72
70sub search { 73sub search {
125 substr $self->{search}, -1, 1, ""; 128 substr $self->{search}, -1, 1, "";
126 $self->search; 129 $self->search;
127 } elsif ($string ne "") { 130 } elsif ($string ne "") {
128 return; 131 return;
129 } 132 }
133
130 } else { 134 } else {
131 if ($keysym == 0xff0d || $keysym == 0xff8d) { 135 if ($keysym == 0xff0d || $keysym == 0xff8d) {
132 # OK 136 # OK
133 $self->leave; 137 $self->leave;
134 } elsif ($keysym == 0xff1b) { 138 } elsif ($keysym == 0xff1b) {
137 } elsif ($keysym == 0xff52) { 141 } elsif ($keysym == 0xff52) {
138 $self->view_start ($self->view_start + 1); 142 $self->view_start ($self->view_start + 1);
139 } elsif ($keysym == 0xff54) { 143 } elsif ($keysym == 0xff54) {
140 $self->view_start ($self->view_start - 1); 144 $self->view_start ($self->view_start - 1);
141 } elsif ($string eq "/") { 145 } elsif ($string eq "/") {
146 delete $self->{manpage_overlay};
142 $self->{in_search} = $self->view_start; 147 $self->{in_search} = $self->view_start;
143 $self->search; 148 $self->search;
144 } elsif ($string eq "G") { 149 } elsif ($string eq "G") {
150 $self->{history} = [];
145 $self->view_start (0); 151 $self->view_start (0);
146 } elsif ($string eq "n") { 152 } elsif ($string eq "n") {
153 if ($self->{found} && @{ $self->{found} }) {
154 push @{ $self->{history} }, [$self->view_start, $self->{found}];
147 $self->search (-1); 155 $self->search (-1);
148 $self->idle; 156 $self->idle;
157 }
149 } elsif ($string eq "p" or $string eq "N") { 158 } elsif ($string eq "p" or $string eq "N") {
150 # TODO 159 if (my $prev = pop @{ $self->{history} }) {
160 $self->view_start ($prev->[0]);
161 $self->{found} = $prev->[1];
162 $self->want_refresh;
163 }
151 } elsif ($string ne "") { 164 } elsif ($string ne "") {
152 $self->scr_bell; 165 $self->scr_bell;
153 } 166 }
154 } 167 }
155 168

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines