--- rxvt-unicode/src/perl/searchable-scrollback 2006/01/12 05:22:47 1.13 +++ rxvt-unicode/src/perl/searchable-scrollback 2006/01/12 11:16:36 1.19 @@ -80,25 +80,25 @@ my $search = $self->special_encode ($self->{search}); no re 'eval'; # just to be sure - my $re = qr/$search/; + if (my $re = eval { qr/$search/ }) { + while ($self->nrow > $row && $row > -$self->nsaved) { + my $line = $self->line ($row) + or last; + + my $text = $line->t; + if ($text =~ /$re/g) { + do { + push @{ $self->{found} }, [$line->coord_of ($-[0]), $line->coord_of ($+[0])]; + } while $text =~ /$re/g; + + $self->{row} = $row; + $self->view_start (List::Util::max 0, -$row + ($self->nrow >> 1)); + $self->want_refresh; + last; + } - while ($self->nrow > $row && $row > -$self->nsaved) { - my $line = $self->line ($row) - or last; - - my $text = $line->t; - if ($text =~ /$re/g) { - do { - push @{ $self->{found} }, [$line->coord_of ($-[0]), $line->coord_of ($+[0])]; - } while $text =~ /$re/g; - - $self->{row} = $row; - $self->view_start (-$row + ($self->nrow >> 1)); - $self->want_refresh; - last; + $row = $dir < 0 ? $line->beg - 1 : $line->end + 1; } - - $row = $dir < 0 ? $line->beg - 1 : $line->end + 1; } $self->scr_bell unless $self->{found}; @@ -107,7 +107,9 @@ sub refresh { my ($self) = @_; - my $xor = urxvt::RS_RVid | urxvt::RS_Uline; + return unless $self->{found}; + + my $xor = urxvt::RS_RVid | urxvt::RS_Blink; for (@{ $self->{found} }) { $self->scr_xor_span (@$_, $xor); $xor = urxvt::RS_RVid; @@ -121,7 +123,7 @@ delete $self->{manpage_overlay}; - if ($keysym == 0xff0d || $keysym == 0xff8d) { + if ($keysym == 0xff0d || $keysym == 0xff8d) { # enter if ($self->{found}) { my ($br, $bc, $er, $ec) = @{ $self->{found}[0] }; $self->selection_beg ($br, $bc); @@ -129,35 +131,23 @@ $self->selection_make ($event->{time}); } $self->leave; - } elsif ($keysym == 0xff1b) { + } elsif ($keysym == 0xff1b) { # escape $self->view_start ($self->{view_start}); $self->leave; - } elsif ($keysym == 0xff57) { + } elsif ($keysym == 0xff57) { # end $self->{row} = $self->nrow - 1; $self->view_start (0); - } elsif ($keysym == 0xff52) { + } elsif ($keysym == 0xff52) { # up $self->{row}-- if $self->{row} > -$self->nsaved; $self->search (-1); - } elsif ($keysym == 0xff54) { + } elsif ($keysym == 0xff54) { # down $self->{row}++ if $self->{row} < $self->nrow; $self->search (+1); - } elsif ($string eq "n") { - if ($self->{found} && @{ $self->{found} }) { - push @{ $self->{history} }, [$self->view_start, $self->{found}]; - $self->search (-1); - $self->idle; - } - } elsif ($string eq "p" or $string eq "N") { - if (my $prev = pop @{ $self->{history} }) { - $self->view_start ($prev->[0]); - $self->{found} = $prev->[1]; - $self->want_refresh; - } - } elsif ($keysym == 0xff08) { + } elsif ($keysym == 0xff08) { # backspace substr $self->{search}, -1, 1, ""; $self->search; $self->idle; - } elsif ($string =~ /^[^\x00-\x1f\x80-\xaf]+$/) { + } elsif ($string !~ /[\x00-\x1f\x80-\xaf]/) { return; # pass to tt_write }