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 && !$self->current_screen) { |
14 | if ($ofs >= 0 && $ofs < $line->l) { |
12 | my $diff = $ofs - $cur; |
15 | my $diff = $ofs - $cur; |
13 | my $move; |
16 | my $move; |
14 | |
17 | |
15 | if ($diff < 0) { |
18 | if ($diff < 0) { |
16 | ($ofs, $cur) = ($cur, $ofs); |
19 | ($ofs, $cur) = ($cur, $ofs); |
… | |
… | |
18 | } else { |
21 | } else { |
19 | $move = "\x1b[C"; |
22 | $move = "\x1b[C"; |
20 | } |
23 | } |
21 | |
24 | |
22 | my $skipped = substr $line->t, $cur, $ofs - $cur; |
25 | my $skipped = substr $line->t, $cur, $ofs - $cur; |
23 | $skipped =~ s/$urxvt::NOCHAR//g; |
26 | $skipped =~ s/\x{ffff}//g; |
24 | |
27 | |
25 | $self->tt_write ($move x length $skipped); |
28 | $self->tt_write ($move x length $skipped); |
26 | } |
29 | } |
27 | |
30 | |
28 | () |
31 | () |