| 1 |
root |
1.1 |
#! perl |
| 2 |
|
|
|
| 3 |
|
|
sub on_button_press { |
| 4 |
|
|
my ($self, $event) = @_; |
| 5 |
|
|
|
| 6 |
root |
1.4 |
return |
| 7 |
|
|
if $self->current_screen || $self->hidden_cursor; |
| 8 |
|
|
|
| 9 |
root |
1.1 |
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 |
root |
1.4 |
if ($ofs >= 0 && $ofs < $line->l) { |
| 15 |
root |
1.1 |
my $diff = $ofs - $cur; |
| 16 |
root |
1.3 |
my $move; |
| 17 |
root |
1.1 |
|
| 18 |
root |
1.3 |
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/$urxvt::NOCHAR//g; |
| 27 |
|
|
|
| 28 |
|
|
$self->tt_write ($move x length $skipped); |
| 29 |
root |
1.1 |
} |
| 30 |
|
|
|
| 31 |
|
|
() |
| 32 |
|
|
} |