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.3 by root, Mon Jan 9 23:03:13 2006 UTC vs.
Revision 1.7 by root, Mon Jan 9 23:30:01 2006 UTC

5sub on_init { 5sub on_init {
6 my ($self) = @_; 6 my ($self) = @_;
7 7
8 my $hotkey = $self->{argv}[0] || "M-s"; 8 my $hotkey = $self->{argv}[0] || "M-s";
9 9
10 $self->parse_keysym ($hotkey, "perl:searchable-scrollback:enter") 10 $self->parse_keysym ($hotkey, "perl:searchable-scrollback:start")
11 or warn "unable to register '$hotkey' as scrollback search enter hotkey\n"; 11 or warn "unable to register '$hotkey' as scrollback search start hotkey\n";
12 12
13 () 13 ()
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:enter") { 19 if ($cmd eq "searchable-scrollback:start") {
20 $self->enter; 20 $self->enter;
21 } 21 }
22 22
23 () 23 ()
24} 24}
38 $self->{pty_ev_events} = $self->pty_ev_events (urxvt::EVENT_NONE); 38 $self->{pty_ev_events} = $self->pty_ev_events (urxvt::EVENT_NONE);
39 $self->{view_start} = $self->view_start; 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 refresh_begin => \&refresh, 44 refresh_begin => \&refresh,
44 refresh_end => \&refresh, 45 refresh_end => \&refresh,
45 ); 46 );
46 47
47 $self->idle; 48 $self->idle;
50sub leave { 51sub leave {
51 my ($self) = @_; 52 my ($self) = @_;
52 53
53 delete $self->{overlay}; 54 delete $self->{overlay};
54 55
55 $self->disable ("key_press", "refresh_begin", "refresh_end"); 56 $self->disable ("key_press", "tt_write", "refresh_begin", "refresh_end");
56 57
57 $self->pty_ev_events ($self->{pty_ev_events}); 58 $self->pty_ev_events ($self->{pty_ev_events});
58 $self->want_refresh; 59 $self->want_refresh;
59} 60}
60 61
65 66
66 delete $self->{in_search}; 67 delete $self->{in_search};
67} 68}
68 69
69sub search { 70sub search {
70 my ($self) = @_; 71 my ($self, $offset) = @_;
71 72
72 my $row = -$self->view_start; 73 my $row = -$self->view_start + ($self->nrow >> 1) + $offset;
73 74
74 delete $self->{found}; 75 delete $self->{found};
75 76
77 my $search = $self->special_encode ($self->{search});
78
76 no re 'eval'; # just to be sure 79 no re 'eval'; # just to be sure
77 my $re = qr/$self->{search}/; 80 my $re = qr/$search/;
78 81
79 while ($row > -$self->nsaved) { 82 while ($row > -$self->nsaved) {
80 my $line = $self->line ($row) 83 my $line = $self->line ($row)
81 or last; 84 or last;
82 85
101sub refresh { 104sub refresh {
102 my ($self) = @_; 105 my ($self) = @_;
103 106
104 return unless $self->{found}; 107 return unless $self->{found};
105 108
106 $self->scr_xor_span (@$_) 109 $self->scr_xor_span (@$_, urxvt::SET_FGCOLOR (urxvt::RS_RVid, 15))
107 for @{ $self->{found} }; 110 for @{ $self->{found} };
108 111
109 () 112 ()
110} 113}
111 114
118 } elsif ($keysym == 0xff1b) { 121 } elsif ($keysym == 0xff1b) {
119 $self->view_start ($self->{in_search}); 122 $self->view_start ($self->{in_search});
120 $self->idle; 123 $self->idle;
121 } elsif ($keysym == 0xff08) { 124 } elsif ($keysym == 0xff08) {
122 substr $self->{search}, -1, 1, ""; 125 substr $self->{search}, -1, 1, "";
123
124 $self->search; 126 $self->search;
125 } elsif ($string ne "") { 127 } elsif ($string ne "") {
126 $self->{search} .= $string; 128 return;
127
128 $self->search;
129 } 129 }
130 } else { 130 } else {
131 if ($keysym == 0xff0d || $keysym == 0xff8d) { 131 if ($keysym == 0xff0d || $keysym == 0xff8d) {
132 # OK 132 # OK
133 $self->leave; 133 $self->leave;
142 $self->{in_search} = $self->view_start; 142 $self->{in_search} = $self->view_start;
143 $self->search; 143 $self->search;
144 } elsif ($string eq "G") { 144 } elsif ($string eq "G") {
145 $self->view_start (0); 145 $self->view_start (0);
146 } elsif ($string eq "n") { 146 } elsif ($string eq "n") {
147 $self->search; 147 $self->search (-1);
148 $self->idle;
148 } elsif ($string eq "p") { 149 } elsif ($string eq "p" or $string eq "N") {
149 # TODO 150 # TODO
150 } elsif ($string ne "") { 151 } elsif ($string ne "") {
151 $self->scr_bell; 152 $self->scr_bell;
152 } 153 }
153 } 154 }
154 155
155 1 156 1
156} 157}
157 158
159sub tt_write {
160 my ($self, $data) = @_;
158 161
162 $self->{search} .= $self->locale_decode ($data);
163 $self->search;
164
165 1
166}
167
168

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines