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.4 by root, Sat Jan 21 08:07:39 2006 UTC vs.
Revision 1.10 by root, Mon Feb 20 20:48:11 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) = @_;
5 21
6 return
7 if $self->current_screen || $self->hidden_cursor; 22 $self->current_screen || $self->hidden_cursor || !$self->{enabled}
23 and return;
24
25 my $mask = $self->ModLevel3Mask | $self->ModMetaMask
26 | urxvt::ShiftMask | urxvt::ControlMask;
27
28 ($event->{state} & $mask) == urxvt::ShiftMask
29 or return;
30
31 $termios->getattr ($self->pty_fd)
32 or return;
33
34 $termios->getlflag & &POSIX::ICANON
35 and return;
8 36
9 my ($row, $col) = $self->screen_cur; 37 my ($row, $col) = $self->screen_cur;
10 my $line = $self->line ($row); 38 my $line = $self->line ($row);
11 my $cur = $line->offset_of ($row, $col); 39 my $cur = $line->offset_of ($row, $col);
12 my $ofs = $line->offset_of ($event->{row}, $event->{col}); 40 my $ofs = $line->offset_of ($event->{row}, $event->{col});
13 41
14 if ($ofs >= 0 && $ofs < $line->l) { 42 $ofs >= 0 && $ofs < $line->l
15 my $diff = $ofs - $cur; 43 or return;
16 my $move;
17 44
18 if ($diff < 0) { 45 my $diff = $ofs - $cur;
19 ($ofs, $cur) = ($cur, $ofs); 46 my $move;
20 $move = "\x1b[D";
21 } else {
22 $move = "\x1b[C";
23 }
24 47
25 my $skipped = substr $line->t, $cur, $ofs - $cur; 48 if ($diff < 0) {
26 $skipped =~ s/$urxvt::NOCHAR//g; 49 ($ofs, $cur) = ($cur, $ofs);
27 50 $move = "\x1b[D";
28 $self->tt_write ($move x length $skipped); 51 } else {
52 $move = "\x1b[C";
29 } 53 }
30 54
31 () 55 my $skipped = substr $line->t, $cur, $ofs - $cur;
56 $skipped =~ s/\x{ffff}//g;
57
58 $self->tt_write ($move x length $skipped);
59
60 1
32} 61}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines