*** empty log message ***
authorroot <root>
Mon, 9 Jan 2006 23:00:07 +0000 (23:00 +0000)
committerroot <root>
Mon, 9 Jan 2006 23:00:07 +0000 (23:00 +0000)
src/perl/searchable-scrollback

index 8a56cac14d944817ed74da2e4f877f31064ac0f9..283c86caa0b219b7c507a0ed6625655a10dc9d9a 100644 (file)
@@ -39,12 +39,9 @@ sub enter {
    $self->{view_start} = $self->view_start;
 
    $self->enable (
-      refresh_begin => sub {
-         warn "beg(@_)\n";
-      },
-      refresh_end => sub {
-         warn "end(@_)\n";
-      },
+      key_press     => \&key_press,
+      refresh_begin => \&refresh,
+      refresh_end   => \&refresh,
    );
 
    $self->idle;
@@ -55,7 +52,7 @@ sub leave {
 
    delete $self->{overlay};
 
-   $self->disable ("refresh_begin", "refresh_end");
+   $self->disable ("key_press", "refresh_begin", "refresh_end");
 
    $self->pty_ev_events ($self->{pty_ev_events});
    $self->want_refresh;
@@ -86,7 +83,7 @@ sub search {
       my $text = $line->t;
       if ($text =~ /$re/g) {
          do {
-            push @{ $self->{found} }, [$line->coord_of ($-[0]), $line->coord_of ($+[1])];
+            push @{ $self->{found} }, [$line->coord_of ($-[0]), $line->coord_of ($+[0])];
          } while $text =~ /$re/g;
 
          $self->view_start (-$row + ($self->nrow >> 1));
@@ -101,24 +98,35 @@ sub search {
    $self->scr_bell unless $self->{found};
 }
 
-sub on_key_press {
-   my ($self, $event, $keysym, $string) =  @_;
+sub refresh {
+   my ($self) = @_;
+
+   return unless $self->{found};
+
+   $self->scr_xor_span (@$_)
+      for @{ $self->{found} };
+
+   ()
+}
 
-   $self->{overlay}
-      or return;
+sub key_press {
+   my ($self, $event, $keysym, $string) =  @_;
 
    if (exists $self->{in_search}) {
       if ($keysym == 0xff0d || $keysym == 0xff8d) {
-         delete $self->{in_search};
+         $self->idle;
       } elsif ($keysym == 0xff1b) {
-         $self->view_start (delete $self->{in_search});
+         $self->view_start ($self->{in_search});
+         $self->idle;
       } elsif ($keysym == 0xff08) {
          substr $self->{search}, -1, 1, "";
+
+         $self->search;
       } elsif ($string ne "") {
          $self->{search} .= $string;
-      }
 
-      $self->search;
+         $self->search;
+      }
    } else {
       if ($keysym == 0xff0d || $keysym == 0xff8d) {
          # OK
@@ -134,6 +142,7 @@ sub on_key_press {
          $self->{in_search} = $self->view_start;
          $self->search;
       } elsif ($string eq "n") {
+         $self->search;
       } elsif ($string eq "p") {
       } elsif ($string ne "") {
          $self->scr_bell;