… | |
… | |
1828 | |
1828 | |
1829 | my $idx = $self->{layout}->xy_to_index ($x, $y); |
1829 | my $idx = $self->{layout}->xy_to_index ($x, $y); |
1830 | |
1830 | |
1831 | # byte-index to char-index |
1831 | # byte-index to char-index |
1832 | my $text = $self->{text}; |
1832 | my $text = $self->{text}; |
1833 | utf8::encode $text; |
1833 | utf8::encode $text; $text = substr $text, 0, $idx; utf8::decode $text; |
1834 | $self->{cursor} = length substr $text, 0, $idx; |
1834 | $self->{cursor} = length $text; |
1835 | |
1835 | |
1836 | $self->_set_text ($self->{text}); |
1836 | $self->_set_text ($self->{text}); |
1837 | $self->update; |
1837 | $self->update; |
1838 | |
1838 | |
1839 | 1 |
1839 | 1 |