--- rxvt-unicode/src/perl/searchable-scrollback 2014/06/09 19:40:42 1.39 +++ rxvt-unicode/src/perl/searchable-scrollback 2017/10/24 20:12:08 1.44 @@ -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,14 +74,23 @@ # 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"; () } +sub on_user_command { + my ($self, $cmd) = @_; + + $cmd eq "searchable-scrollback:start" + and $self->enter; + + () +} + sub on_action { my ($self, $action) = @_; @@ -94,6 +139,7 @@ delete $self->{manpage_overlay}; delete $self->{overlay}; delete $self->{search}; + delete $self->{found}; } sub idle { @@ -175,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});