1 |
root |
1.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 |
root |
1.3 |
if ($ofs >= 0 && $ofs < $line->l && !$self->current_screen) { |
12 |
root |
1.1 |
my $diff = $ofs - $cur; |
13 |
root |
1.3 |
my $move; |
14 |
root |
1.1 |
|
15 |
root |
1.3 |
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 |
root |
1.1 |
} |
27 |
|
|
|
28 |
|
|
() |
29 |
|
|
} |