From 77365583cd5fc134f8a07515ae022649c6be5423 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 12 Jan 2006 05:22:47 +0000 Subject: [PATCH] *** empty log message *** --- src/perl/searchable-scrollback | 112 ++++++++++++++++----------------- src/rxvtperl.xs | 10 +++ src/screen.C | 5 +- src/urxvt.pm | 18 ++++-- 4 files changed, 80 insertions(+), 65 deletions(-) diff --git a/src/perl/searchable-scrollback b/src/perl/searchable-scrollback index 88b99f39..4669f492 100644 --- a/src/perl/searchable-scrollback +++ b/src/perl/searchable-scrollback @@ -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 } diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs index 67594400..d5f901a3 100644 --- a/src/rxvtperl.xs +++ b/src/rxvtperl.xs @@ -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) diff --git a/src/screen.C b/src/screen.C index 7e178f60..04aa9fef 100644 --- a/src/screen.C +++ b/src/screen.C @@ -3023,7 +3023,10 @@ rxvt_term::selection_grab (Time tm) return true; } else - return false; + { + selection_clear (); + return false; + } #if 0 XTextProperty ct; diff --git a/src/urxvt.pm b/src/urxvt.pm index 2b852a63..da189655 100644 --- a/src/urxvt.pm +++ b/src/urxvt.pm @@ -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 and +C. 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 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). Useful in refresh hooks to provide effects similar -to the selection. +(default: C), which I 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, but xors a rectangle instead. Trailing whitespace will additionally be xored with the C<$rstyle2>, which defaults to C, which removes reverse video again and underlines -it instead. +it instead. Both styles I contain font styles. =item $term->scr_bell -- 2.34.1