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

Comparing rxvt-unicode/src/perl/readline (file contents):
Revision 1.2 by root, Fri Jan 20 22:07:08 2006 UTC vs.
Revision 1.7 by root, Mon Feb 6 06:14:08 2006 UTC

1#! perl 1#! perl
2
3use POSIX ();
4
5my $termios = new POSIX::Termios;
6
7sub on_init {
8 my ($self) = @_;
9
10 $self->{enabled} = 1;
11
12 push @{ $self->{term}{option_popup_hook} }, sub {
13 ("readline" => $self->{enabled}, sub { $self->{enabled} = shift })
14 };
15
16 ()
17}
2 18
3sub on_button_press { 19sub on_button_press {
4 my ($self, $event) = @_; 20 my ($self, $event) = @_;
21
22 return
23 if $self->current_screen || $self->hidden_cursor || !$self->{enabled};
24
25 $termios->getattr ($self->pty_fd)
26 or return;
27
28 return
29 if $termios->getlflag & &POSIX::ICANON;
5 30
6 my ($row, $col) = $self->screen_cur; 31 my ($row, $col) = $self->screen_cur;
7 my $line = $self->line ($row); 32 my $line = $self->line ($row);
8 my $cur = $line->offset_of ($row, $col); 33 my $cur = $line->offset_of ($row, $col);
9 my $ofs = $line->offset_of ($event->{row}, $event->{col}); 34 my $ofs = $line->offset_of ($event->{row}, $event->{col});
10 35
11 if ($ofs >= 0 && $ofs < $line->l) { 36 if ($ofs >= 0 && $ofs < $line->l) {
12 my $diff = $ofs - $cur; 37 my $diff = $ofs - $cur;
38 my $move;
13 39
14 $self->tt_write ($diff < 0 ? "\x1b[D" x -$diff 40 if ($diff < 0) {
15 : "\x1b[C" x $diff); 41 ($ofs, $cur) = ($cur, $ofs);
42 $move = "\x1b[D";
43 } else {
44 $move = "\x1b[C";
45 }
46
47 my $skipped = substr $line->t, $cur, $ofs - $cur;
48 $skipped =~ s/\x{ffff}//g;
49
50 $self->tt_write ($move x length $skipped);
16 } 51 }
17 52
18 () 53 ()
19} 54}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines