1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | sub on_button_press { |
3 | sub on_button_press { |
4 | my ($self, $event) = @_; |
4 | my ($self, $event) = @_; |
|
|
5 | |
|
|
6 | return |
|
|
7 | if $self->current_screen || $self->hidden_cursor; |
5 | |
8 | |
6 | my ($row, $col) = $self->screen_cur; |
9 | my ($row, $col) = $self->screen_cur; |
7 | my $line = $self->line ($row); |
10 | my $line = $self->line ($row); |
8 | my $cur = $line->offset_of ($row, $col); |
11 | my $cur = $line->offset_of ($row, $col); |
9 | my $ofs = $line->offset_of ($event->{row}, $event->{col}); |
12 | my $ofs = $line->offset_of ($event->{row}, $event->{col}); |
10 | |
13 | |
11 | if ($ofs >= 0 && $ofs < $line->l) { |
14 | if ($ofs >= 0 && $ofs < $line->l) { |
12 | my $diff = $ofs - $cur; |
15 | my $diff = $ofs - $cur; |
|
|
16 | my $move; |
13 | |
17 | |
14 | $self->tt_write ($diff < 0 ? "\x1b[D" x -$diff |
18 | if ($diff < 0) { |
15 | : "\x1b[C" x $diff); |
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); |
16 | } |
29 | } |
17 | |
30 | |
18 | () |
31 | () |
19 | } |
32 | } |