ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/searchable-scrollback
(Generate patch)

Comparing rxvt-unicode/src/perl/searchable-scrollback (file contents):
Revision 1.1 by root, Mon Jan 9 22:41:41 2006 UTC vs.
Revision 1.2 by root, Mon Jan 9 23:00:07 2006 UTC

37 37
38 $self->{pty_ev_events} = $self->pty_ev_events (urxvt::EVENT_NONE); 38 $self->{pty_ev_events} = $self->pty_ev_events (urxvt::EVENT_NONE);
39 $self->{view_start} = $self->view_start; 39 $self->{view_start} = $self->view_start;
40 40
41 $self->enable ( 41 $self->enable (
42 key_press => \&key_press,
42 refresh_begin => sub { 43 refresh_begin => \&refresh,
43 warn "beg(@_)\n"; 44 refresh_end => \&refresh,
44 },
45 refresh_end => sub {
46 warn "end(@_)\n";
47 },
48 ); 45 );
49 46
50 $self->idle; 47 $self->idle;
51} 48}
52 49
53sub leave { 50sub leave {
54 my ($self) = @_; 51 my ($self) = @_;
55 52
56 delete $self->{overlay}; 53 delete $self->{overlay};
57 54
58 $self->disable ("refresh_begin", "refresh_end"); 55 $self->disable ("key_press", "refresh_begin", "refresh_end");
59 56
60 $self->pty_ev_events ($self->{pty_ev_events}); 57 $self->pty_ev_events ($self->{pty_ev_events});
61 $self->want_refresh; 58 $self->want_refresh;
62} 59}
63 60
84 or last; 81 or last;
85 82
86 my $text = $line->t; 83 my $text = $line->t;
87 if ($text =~ /$re/g) { 84 if ($text =~ /$re/g) {
88 do { 85 do {
89 push @{ $self->{found} }, [$line->coord_of ($-[0]), $line->coord_of ($+[1])]; 86 push @{ $self->{found} }, [$line->coord_of ($-[0]), $line->coord_of ($+[0])];
90 } while $text =~ /$re/g; 87 } while $text =~ /$re/g;
91 88
92 $self->view_start (-$row + ($self->nrow >> 1)); 89 $self->view_start (-$row + ($self->nrow >> 1));
93 last; 90 last;
94 } 91 }
99 $self->msg ("enter/type/backspace: /$self->{search}_" 96 $self->msg ("enter/type/backspace: /$self->{search}_"
100 . ($self->{found} ? " (not found)" : "")); 97 . ($self->{found} ? " (not found)" : ""));
101 $self->scr_bell unless $self->{found}; 98 $self->scr_bell unless $self->{found};
102} 99}
103 100
101sub refresh {
102 my ($self) = @_;
103
104 return unless $self->{found};
105
106 $self->scr_xor_span (@$_)
107 for @{ $self->{found} };
108
109 ()
110}
111
104sub on_key_press { 112sub key_press {
105 my ($self, $event, $keysym, $string) = @_; 113 my ($self, $event, $keysym, $string) = @_;
106
107 $self->{overlay}
108 or return;
109 114
110 if (exists $self->{in_search}) { 115 if (exists $self->{in_search}) {
111 if ($keysym == 0xff0d || $keysym == 0xff8d) { 116 if ($keysym == 0xff0d || $keysym == 0xff8d) {
112 delete $self->{in_search}; 117 $self->idle;
113 } elsif ($keysym == 0xff1b) { 118 } elsif ($keysym == 0xff1b) {
114 $self->view_start (delete $self->{in_search}); 119 $self->view_start ($self->{in_search});
120 $self->idle;
115 } elsif ($keysym == 0xff08) { 121 } elsif ($keysym == 0xff08) {
116 substr $self->{search}, -1, 1, ""; 122 substr $self->{search}, -1, 1, "";
123
124 $self->search;
117 } elsif ($string ne "") { 125 } elsif ($string ne "") {
118 $self->{search} .= $string; 126 $self->{search} .= $string;
127
128 $self->search;
119 } 129 }
120
121 $self->search;
122 } else { 130 } else {
123 if ($keysym == 0xff0d || $keysym == 0xff8d) { 131 if ($keysym == 0xff0d || $keysym == 0xff8d) {
124 # OK 132 # OK
125 $self->leave; 133 $self->leave;
126 } elsif ($keysym == 0xff1b) { 134 } elsif ($keysym == 0xff1b) {
132 $self->view_start ($self->view_start - 1); 140 $self->view_start ($self->view_start - 1);
133 } elsif ($string eq "/") { 141 } elsif ($string eq "/") {
134 $self->{in_search} = $self->view_start; 142 $self->{in_search} = $self->view_start;
135 $self->search; 143 $self->search;
136 } elsif ($string eq "n") { 144 } elsif ($string eq "n") {
145 $self->search;
137 } elsif ($string eq "p") { 146 } elsif ($string eq "p") {
138 } elsif ($string ne "") { 147 } elsif ($string ne "") {
139 $self->scr_bell; 148 $self->scr_bell;
140 } 149 }
141 } 150 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines