1 |
#! perl |
2 |
|
3 |
sub on_button_press { |
4 |
my ($self, $event) = @_; |
5 |
|
6 |
return |
7 |
if $self->current_screen || $self->hidden_cursor; |
8 |
|
9 |
my ($row, $col) = $self->screen_cur; |
10 |
my $line = $self->line ($row); |
11 |
my $cur = $line->offset_of ($row, $col); |
12 |
my $ofs = $line->offset_of ($event->{row}, $event->{col}); |
13 |
|
14 |
if ($ofs >= 0 && $ofs < $line->l) { |
15 |
my $diff = $ofs - $cur; |
16 |
my $move; |
17 |
|
18 |
if ($diff < 0) { |
19 |
($ofs, $cur) = ($cur, $ofs); |
20 |
$move = "\x1b[D"; |
21 |
} else { |
22 |
$move = "\x1b[C"; |
23 |
} |
24 |
|
25 |
my $skipped = substr $line->t, $cur, $ofs - $cur; |
26 |
$skipped =~ s/\x{ffff}//g; |
27 |
|
28 |
$self->tt_write ($move x length $skipped); |
29 |
} |
30 |
|
31 |
() |
32 |
} |