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