… | |
… | |
44 | 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"; |
45 | |
45 | |
46 | () |
46 | () |
47 | } |
47 | } |
48 | |
48 | |
|
|
49 | sub on_user_command { |
|
|
50 | my ($self, $cmd) = @_; |
|
|
51 | |
|
|
52 | $cmd eq "searchable-scrollback:start" |
|
|
53 | and $self->enter; |
|
|
54 | |
|
|
55 | () |
|
|
56 | } |
|
|
57 | |
49 | sub on_action { |
58 | sub on_action { |
50 | my ($self, $action) = @_; |
59 | my ($self, $action) = @_; |
51 | |
60 | |
52 | $action eq "start" |
61 | $action eq "start" |
53 | and $self->enter; |
62 | and $self->enter; |
… | |
… | |
92 | $self->pty_ev_events ($self->{pty_ev_events}); |
101 | $self->pty_ev_events ($self->{pty_ev_events}); |
93 | |
102 | |
94 | delete $self->{manpage_overlay}; |
103 | delete $self->{manpage_overlay}; |
95 | delete $self->{overlay}; |
104 | delete $self->{overlay}; |
96 | delete $self->{search}; |
105 | delete $self->{search}; |
|
|
106 | delete $self->{found}; |
97 | } |
107 | } |
98 | |
108 | |
99 | sub idle { |
109 | sub idle { |
100 | my ($self) = @_; |
110 | my ($self) = @_; |
101 | |
111 | |
102 | $self->msg ("(escape cancels) /$self->{search}█"); |
112 | $self->msg ("(escape cancels) /$self->{search}█"); |
103 | } |
113 | } |
104 | |
114 | |
105 | sub search { |
115 | sub search { |
106 | my ($self, $dir, $row) = @_; |
116 | my ($self, $dir, $row) = @_; |
107 | |
|
|
108 | delete $self->{found}; |
|
|
109 | |
117 | |
110 | my $search = $self->special_encode ($self->{search}); |
118 | my $search = $self->special_encode ($self->{search}); |
111 | |
119 | |
112 | no re 'eval'; # just to be sure |
120 | no re 'eval'; # just to be sure |
113 | if (my $re = eval { qr/$search/ }) { |
121 | if (my $re = eval { qr/$search/ }) { |
… | |
… | |
115 | my $line = $self->line ($row) |
123 | my $line = $self->line ($row) |
116 | or last; |
124 | or last; |
117 | |
125 | |
118 | my $text = $line->t; |
126 | my $text = $line->t; |
119 | if ($text =~ /$re/g) { |
127 | if ($text =~ /$re/g) { |
|
|
128 | delete $self->{found}; |
|
|
129 | |
120 | do { |
130 | do { |
121 | push @{ $self->{found} }, [$line->coord_of ($-[0]), $line->coord_of ($+[0])]; |
131 | push @{ $self->{found} }, [$line->coord_of ($-[0]), $line->coord_of ($+[0])]; |
122 | } while $text =~ /$re/g; |
132 | } while $text =~ /$re/g; |
123 | |
133 | |
124 | $self->{row} = $row; |
134 | $self->{row} = $row; |
125 | $self->view_start (List::Util::min 0, $row - ($self->nrow >> 1)); |
135 | $self->view_start (List::Util::min 0, $row - ($self->nrow >> 1)); |
126 | $self->want_refresh; |
136 | $self->want_refresh; |
127 | last; |
137 | return; |
128 | } |
138 | } |
129 | |
139 | |
130 | $row = $dir < 0 ? $line->beg - 1 : $line->end + 1; |
140 | $row = $dir < 0 ? $line->beg - 1 : $line->end + 1; |
131 | } |
141 | } |
132 | } |
142 | } |
133 | |
143 | |
134 | $self->scr_bell unless $self->{found}; |
144 | $self->scr_bell; |
135 | } |
145 | } |
136 | |
146 | |
137 | sub refresh { |
147 | sub refresh { |
138 | my ($self) = @_; |
148 | my ($self) = @_; |
139 | |
149 | |
… | |
… | |
192 | $self->{search} .= $self->locale_decode ($data); |
202 | $self->{search} .= $self->locale_decode ($data); |
193 | |
203 | |
194 | $self->{search} =~ s/^\(\?i\)// |
204 | $self->{search} =~ s/^\(\?i\)// |
195 | if $self->{search} =~ /^\(.*[[:upper:]]/; |
205 | if $self->{search} =~ /^\(.*[[:upper:]]/; |
196 | |
206 | |
|
|
207 | delete $self->{found}; |
197 | $self->search (-1, $self->{row}); |
208 | $self->search (-1, $self->{row}); |
198 | $self->idle; |
209 | $self->idle; |
199 | |
210 | |
200 | 1 |
211 | 1 |
201 | } |
212 | } |