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.18 by root, Thu Jan 12 11:15:06 2006 UTC vs.
Revision 1.23 by ayin, Wed Aug 1 17:55:37 2007 UTC

13 or warn "unable to register '$hotkey' as scrollback search start hotkey\n"; 13 or warn "unable to register '$hotkey' as scrollback search start hotkey\n";
14 14
15 () 15 ()
16} 16}
17 17
18sub on_keyboard_command { 18sub on_user_command {
19 my ($self, $cmd) = @_; 19 my ($self, $cmd) = @_;
20 20
21 $cmd eq "searchable-scrollback:start" 21 $cmd eq "searchable-scrollback:start"
22 and $self->enter; 22 and $self->enter;
23 23
37 return if $self->{overlay}; 37 return if $self->{overlay};
38 38
39 $self->{view_start} = $self->view_start; 39 $self->{view_start} = $self->view_start;
40 $self->{pty_ev_events} = $self->pty_ev_events (urxvt::EVENT_NONE); 40 $self->{pty_ev_events} = $self->pty_ev_events (urxvt::EVENT_NONE);
41 $self->{row} = $self->nrow - 1; 41 $self->{row} = $self->nrow - 1;
42 $self->{search} = "(?i)";
42 43
43 $self->enable ( 44 $self->enable (
44 key_press => \&key_press, 45 key_press => \&key_press,
45 tt_write => \&tt_write, 46 tt_write => \&tt_write,
46 refresh_begin => \&refresh, 47 refresh_begin => \&refresh,
79 80
80 my $search = $self->special_encode ($self->{search}); 81 my $search = $self->special_encode ($self->{search});
81 82
82 no re 'eval'; # just to be sure 83 no re 'eval'; # just to be sure
83 if (my $re = eval { qr/$search/ }) { 84 if (my $re = eval { qr/$search/ }) {
84 while ($self->nrow > $row && $row > -$self->nsaved) { 85 while ($self->nrow > $row && $row > $self->top_row) {
85 my $line = $self->line ($row) 86 my $line = $self->line ($row)
86 or last; 87 or last;
87 88
88 my $text = $line->t; 89 my $text = $line->t;
89 if ($text =~ /$re/g) { 90 if ($text =~ /$re/g) {
90 do { 91 do {
91 push @{ $self->{found} }, [$line->coord_of ($-[0]), $line->coord_of ($+[0])]; 92 push @{ $self->{found} }, [$line->coord_of ($-[0]), $line->coord_of ($+[0])];
92 } while $text =~ /$re/g; 93 } while $text =~ /$re/g;
93 94
94 $self->{row} = $row; 95 $self->{row} = $row;
95 $self->view_start (List::Util::max 0, -$row + ($self->nrow >> 1)); 96 $self->view_start (List::Util::min 0, $row - ($self->nrow >> 1));
96 $self->want_refresh; 97 $self->want_refresh;
97 last; 98 last;
98 } 99 }
99 100
100 $row = $dir < 0 ? $line->beg - 1 : $line->end + 1; 101 $row = $dir < 0 ? $line->beg - 1 : $line->end + 1;
122 my ($self, $event, $keysym, $string) = @_; 123 my ($self, $event, $keysym, $string) = @_;
123 124
124 delete $self->{manpage_overlay}; 125 delete $self->{manpage_overlay};
125 126
126 if ($keysym == 0xff0d || $keysym == 0xff8d) { # enter 127 if ($keysym == 0xff0d || $keysym == 0xff8d) { # enter
127 if ($self->{found}) { 128 if ($self->{found} && $event->{state} & urxvt::ShiftMask) {
128 my ($br, $bc, $er, $ec) = @{ $self->{found}[0] }; 129 my ($br, $bc, $er, $ec) = @{ $self->{found}[0] };
129 $self->selection_beg ($br, $bc); 130 $self->selection_beg ($br, $bc);
130 $self->selection_end ($er, $ec); 131 $self->selection_end ($er, $ec);
131 $self->selection_make ($event->{time}); 132 $self->selection_make ($event->{time});
132 } 133 }
136 $self->leave; 137 $self->leave;
137 } elsif ($keysym == 0xff57) { # end 138 } elsif ($keysym == 0xff57) { # end
138 $self->{row} = $self->nrow - 1; 139 $self->{row} = $self->nrow - 1;
139 $self->view_start (0); 140 $self->view_start (0);
140 } elsif ($keysym == 0xff52) { # up 141 } elsif ($keysym == 0xff52) { # up
141 $self->{row}-- if $self->{row} > -$self->nsaved; 142 $self->{row}-- if $self->{row} > $self->top_row;
142 $self->search (-1); 143 $self->search (-1);
143 } elsif ($keysym == 0xff54) { # down 144 } elsif ($keysym == 0xff54) { # down
144 $self->{row}++ if $self->{row} < $self->nrow; 145 $self->{row}++ if $self->{row} < $self->nrow;
145 $self->search (+1); 146 $self->search (+1);
146 } elsif ($keysym == 0xff08) { # backspace 147 } elsif ($keysym == 0xff08) { # backspace
147 substr $self->{search}, -1, 1, ""; 148 substr $self->{search}, -1, 1, "";
148 $self->search; 149 $self->search;
149 $self->idle; 150 $self->idle;
150 } elsif ($string =~ /^[^\x00-\x1f\x80-\xaf]+$/) { 151 } elsif ($string !~ /[\x00-\x1f\x80-\xaf]/) {
151 return; # pass to tt_write 152 return; # pass to tt_write
152 } 153 }
153 154
154 1 155 1
155} 156}
156 157
157sub tt_write { 158sub tt_write {
158 my ($self, $data) = @_; 159 my ($self, $data) = @_;
159 160
160 $self->{search} .= $self->locale_decode ($data); 161 $self->{search} .= $self->locale_decode ($data);
162
163 $self->{search} =~ s/^\(\?i\)//
164 if $self->{search} =~ /^\(.*[[:upper:]]/;
165
161 $self->search (-1); 166 $self->search (-1);
162 $self->idle; 167 $self->idle;
163 168
164 1 169 1
165} 170}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines