*** empty log message ***
authorroot <root>
Thu, 12 Jan 2006 05:22:47 +0000 (05:22 +0000)
committerroot <root>
Thu, 12 Jan 2006 05:22:47 +0000 (05:22 +0000)
src/perl/searchable-scrollback
src/rxvtperl.xs
src/screen.C
src/urxvt.pm

index 88b99f39c0bffd932e1ba9a6ce400be451066f77..4669f49267ff356a351bf8de0dc646b6c6d8a832 100644 (file)
@@ -36,9 +36,9 @@ sub enter {
 
    return if $self->{overlay};
 
-   $self->{history} = [];
    $self->{view_start} = $self->view_start;
    $self->{pty_ev_events} = $self->pty_ev_events (urxvt::EVENT_NONE);
+   $self->{row} = $self->nrow - 1;
 
    $self->enable (
       key_press     => \&key_press,
@@ -62,29 +62,27 @@ sub leave {
    delete $self->{manpage_overlay};
    delete $self->{overlay};
    delete $self->{history};
+   delete $self->{search};
 }
 
 sub idle {
    my ($self) = @_;
 
-   $self->msg ("escape=exit, enter=accept, /=start search, n=next, p=previous, G=bottom");
-
-   delete $self->{in_search};
+   $self->msg ("(escape cancels) /$self->{search}█");
 }
 
 sub search {
-   my ($self, $offset) = @_;
-
-   my $row = -$self->view_start + ($self->nrow >> 1) + $offset;
+   my ($self, $dir) = @_;
 
    delete $self->{found};
+   my $row = $self->{row};
 
    my $search = $self->special_encode ($self->{search});
 
    no re 'eval'; # just to be sure
    my $re = qr/$search/;
 
-   while ($row > -$self->nsaved) {
+   while ($self->nrow > $row && $row > -$self->nsaved) {
       my $line = $self->line ($row)
          or last;
 
@@ -94,25 +92,26 @@ sub search {
             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 = $line->beg - 1;
+      $row = $dir < 0 ? $line->beg - 1 : $line->end + 1;
    }
 
-   $self->msg ("enter/type/backspace: /$self->{search}_"
-               . ($self->{found} ? "" : " (not found)"));
    $self->scr_bell unless $self->{found};
 }
 
 sub refresh {
    my ($self) = @_;
 
-   return unless $self->{found};
-
-   $self->scr_xor_span (@$_, urxvt::SET_FGCOLOR (urxvt::RS_RVid, 15))
-      for @{ $self->{found} };
+   my $xor = urxvt::RS_RVid | urxvt::RS_Uline;
+   for (@{ $self->{found} }) {
+      $self->scr_xor_span (@$_, $xor);
+      $xor = urxvt::RS_RVid;
+   }
 
    ()
 }
@@ -120,52 +119,46 @@ sub refresh {
 sub key_press {
    my ($self, $event, $keysym, $string) =  @_;
 
-   if (exists $self->{in_search}) {
-      if ($keysym == 0xff0d || $keysym == 0xff8d) {
-         $self->idle;
-      } elsif ($keysym == 0xff1b) {
-         $self->view_start ($self->{in_search});
+   delete $self->{manpage_overlay};
+
+   if ($keysym == 0xff0d || $keysym == 0xff8d) {
+      if ($self->{found}) {
+         my ($br, $bc, $er, $ec) = @{ $self->{found}[0] };
+         $self->selection_beg ($br, $bc);
+         $self->selection_end ($er, $ec);
+         $self->selection_make ($event->{time});
+      }
+      $self->leave;
+   } elsif ($keysym == 0xff1b) {
+      $self->view_start ($self->{view_start});
+      $self->leave;
+   } elsif ($keysym == 0xff57) {
+      $self->{row} = $self->nrow - 1;
+      $self->view_start (0);
+   } elsif ($keysym == 0xff52) {
+      $self->{row}-- if $self->{row} > -$self->nsaved;
+      $self->search (-1);
+   } elsif ($keysym == 0xff54) {
+      $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 ($keysym == 0xff08) {
-         substr $self->{search}, -1, 1, "";
-         $self->search;
-      } elsif ($string ne "") {
-         return;
       }
-
-   } else {
-      if ($keysym == 0xff0d || $keysym == 0xff8d) {
-         # TODO: set selection
-         $self->leave;
-      } elsif ($keysym == 0xff1b) {
-         $self->view_start ($self->{view_start});
-         $self->leave;
-      } elsif ($keysym == 0xff52) {
-         $self->view_start ($self->view_start + 1);
-      } elsif ($keysym == 0xff54) {
-         $self->view_start ($self->view_start - 1);
-      } elsif ($string eq "/") {
-         delete $self->{manpage_overlay};
-         $self->{in_search} = $self->view_start;
-         $self->search;
-      } elsif ($string eq "G") {
-         $self->{history} = [];
-         $self->view_start (0);
-      } 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 ($string ne "") {
-         $self->scr_bell;
+   } 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) {
+      substr $self->{search}, -1, 1, "";
+      $self->search;
+      $self->idle;
+   } elsif ($string =~ /^[^\x00-\x1f\x80-\xaf]+$/) {
+      return; # pass to tt_write
    }
 
    1
@@ -175,7 +168,8 @@ sub tt_write {
    my ($self, $data) = @_;
 
    $self->{search} .= $self->locale_decode ($data);
-   $self->search;
+   $self->search (-1);
+   $self->idle;
 
    1
 }
index 675944007eedbf6c19fec5a7931a2a80e1ee57be..d5f901a360f1604e6f3307321d82e6c48cab31fc 100644 (file)
@@ -1383,6 +1383,16 @@ rxvt_term::cur_charset ()
        OUTPUT:
         RETVAL
 
+#void
+#rxvt_term::selection_clear ()
+
+void
+rxvt_term::selection_make (U32 eventtime, bool rect = false)
+       CODE:
+        THIS->selection.op = SELECTION_CONT;
+        THIS->selection.rect = rect;
+        THIS->selection_make (eventtime);
+
 int
 rxvt_term::selection_grab (U32 eventtime)
 
index 7e178f6008680c025f3eecc3d496a4aa27b171b9..04aa9fefeb2d153f0cd2415c523fec3cae10480f 100644 (file)
@@ -3023,7 +3023,10 @@ rxvt_term::selection_grab (Time tm)
       return true;
     }
   else
-    return false;
+    {
+      selection_clear ();
+      return false;
+    }
 
 #if 0
   XTextProperty ct;
index 2b852a63bab33bdc6e2cc7258a48093e9e8e6eea..da1896558d43a11aa43656a6c72d3c94b3c38457 100644 (file)
@@ -917,10 +917,18 @@ set it (which is usually bad as applications don't expect that).
 Return the current values of the selection mark, begin or end positions,
 and optionally set them to new values.
 
+=item $term->selection_make ($eventtime[, $rectangular])
+
+Tries to make a selection as set by C<selection_beg> and
+C<selection_end>. If C<$rectangular> is true (default: false), a
+rectangular selection will be made. This is the prefered function to make
+a selection.
+
 =item $success = $term->selection_grab ($eventtime)
 
-Try to request the primary selection from the server (for example, as set
-by the next method).
+Try to request the primary selection text from the server (for example, as
+set by the next method). No visual feedback will be given. This function
+is mostly useful from within C<on_sel_grab> hooks.
 
 =item $oldtext = $term->selection ([$newtext])
 
@@ -1023,15 +1031,15 @@ Convert the given locale-encoded octets into a perl string.
 =item $term->scr_xor_span ($beg_row, $beg_col, $end_row, $end_col[, $rstyle])
 
 XORs the rendition values in the given span with the provided value
-(default: C<RS_RVid>). Useful in refresh hooks to provide effects similar
-to the selection.
+(default: C<RS_RVid>), which I<MUST NOT> contain font styles. Useful in
+refresh hooks to provide effects similar to the selection.
 
 =item $term->scr_xor_rect ($beg_row, $beg_col, $end_row, $end_col[, $rstyle1[, $rstyle2]])
 
 Similar to C<scr_xor_span>, but xors a rectangle instead. Trailing
 whitespace will additionally be xored with the C<$rstyle2>, which defaults
 to C<RS_RVid | RS_Uline>, which removes reverse video again and underlines
-it instead.
+it instead. Both styles I<MUST NOT> contain font styles.
 
 =item $term->scr_bell