ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/readline
Revision: 1.7
Committed: Mon Feb 6 06:14:08 2006 UTC (18 years, 3 months ago) by root
Branch: MAIN
CVS Tags: rel-7_6
Changes since 1.6: +13 -1 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #! perl
2
3 use POSIX ();
4
5 my $termios = new POSIX::Termios;
6
7 sub 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 }
18
19 sub on_button_press {
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;
30
31 my ($row, $col) = $self->screen_cur;
32 my $line = $self->line ($row);
33 my $cur = $line->offset_of ($row, $col);
34 my $ofs = $line->offset_of ($event->{row}, $event->{col});
35
36 if ($ofs >= 0 && $ofs < $line->l) {
37 my $diff = $ofs - $cur;
38 my $move;
39
40 if ($diff < 0) {
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);
51 }
52
53 ()
54 }