--- rxvt-unicode/src/perl/searchable-scrollback 2014/10/14 09:00:52 1.41 +++ rxvt-unicode/src/perl/searchable-scrollback 2020/03/13 11:18:29 1.45 @@ -3,7 +3,6 @@ # this extension implements scrollback buffer search #:META:RESOURCE:%:string:activation hotkey keysym -#:META:BINDING:M-s:start =head1 NAME @@ -17,12 +16,49 @@ suspended and a regex is displayed at the bottom of the screen. Inputting characters appends them to the regex and continues incremental -search. C removes a character from the regex, C and C -search upwards/downwards in the scrollback buffer, C jumps to the -bottom. C leaves search mode and returns to the point where search -was started, while C or C stay at the current position and -additionally stores the first match in the current line into the primary -selection if the C modifier is active. +search. In addition, the following bindings are recognized: + +=over 4 + +=item C + +Remove a character from the regex. + +=item C + +Append the value of the PRIMARY selection to the regex. + +=item C + +Search for a match upwards. + +=item C + +Search for a match downwards. + +=item C + +Scroll up. + +=item C + +Scroll down. + +=item C + +Scroll to the bottom. + +=item C + +Leave the mode and return to the point where search was started. + +=item C or C + +Leave the mode maintaining the current position in the scrollback. +Additionally, if the C modifier is active, store the first +match in the current line into the primary selection. + +=back The regex defaults to "(?i)", resulting in a case-insensitive search. To get a case-sensitive search you can delete this prefix using C @@ -38,9 +74,9 @@ # only for backwards compatibility my $hotkey = $self->{argv}[0] || $self->x_resource ("%") - || return; + || "M-s"; - $self->bind_action ($hotkey, "searchable-scrollback:start") # ugh + $self->bind_action ($hotkey, "%:start") or warn "unable to register '$hotkey' as scrollback search start hotkey\n"; () @@ -185,6 +221,14 @@ my $line = $self->line ($self->{row}); $self->search (+1, $line->end + 1) if $line->end < $self->nrow; + } elsif ($keysym == 0xff55) { # prior + my $row = $self->view_start - ($self->nrow - 1); + $self->view_start (List::Util::min 0, $row); + } elsif ($keysym == 0xff56) { # next + my $row = $self->view_start + ($self->nrow - 1); + $self->view_start (List::Util::min 0, $row); + } elsif ($keysym == 0xff63) { # insert + $self->selection_request (urxvt::CurrentTime, 1); } elsif ($keysym == 0xff08) { # backspace substr $self->{search}, -1, 1, ""; $self->search (+1, $self->{row}); @@ -200,6 +244,7 @@ my ($self, $data) = @_; $self->{search} .= $self->locale_decode ($data); + $self->{search} =~ s/\e\[20[01]~//g; $self->{search} =~ s/^\(\?i\)// if $self->{search} =~ /^\(.*[[:upper:]]/;