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.3 by root, Fri Jan 20 22:49:34 2006 UTC vs.
Revision 1.9 by root, Mon Feb 20 20:46:54 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 $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;
5 36
6 my ($row, $col) = $self->screen_cur; 37 my ($row, $col) = $self->screen_cur;
7 my $line = $self->line ($row); 38 my $line = $self->line ($row);
8 my $cur = $line->offset_of ($row, $col); 39 my $cur = $line->offset_of ($row, $col);
9 my $ofs = $line->offset_of ($event->{row}, $event->{col}); 40 my $ofs = $line->offset_of ($event->{row}, $event->{col});
10 41
11 if ($ofs >= 0 && $ofs < $line->l && !$self->current_screen) { 42 if ($ofs >= 0 && $ofs < $line->l) {
12 my $diff = $ofs - $cur; 43 my $diff = $ofs - $cur;
13 my $move; 44 my $move;
14 45
15 if ($diff < 0) { 46 if ($diff < 0) {
16 ($ofs, $cur) = ($cur, $ofs); 47 ($ofs, $cur) = ($cur, $ofs);
18 } else { 49 } else {
19 $move = "\x1b[C"; 50 $move = "\x1b[C";
20 } 51 }
21 52
22 my $skipped = substr $line->t, $cur, $ofs - $cur; 53 my $skipped = substr $line->t, $cur, $ofs - $cur;
23 $skipped =~ s/$urxvt::NOCHAR//g; 54 $skipped =~ s/\x{ffff}//g;
24 55
25 $self->tt_write ($move x length $skipped); 56 $self->tt_write ($move x length $skipped);
57
58 return 1;
26 } 59 }
27 60
28 () 61 ()
29} 62}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines