… | |
… | |
586 | warn "no draw defined for $self\n"; |
586 | warn "no draw defined for $self\n"; |
587 | } |
587 | } |
588 | |
588 | |
589 | sub DESTROY { |
589 | sub DESTROY { |
590 | my ($self) = @_; |
590 | my ($self) = @_; |
|
|
591 | |
|
|
592 | return if CFClient::in_destruct; |
591 | |
593 | |
592 | delete $WIDGET{$self+0}; |
594 | delete $WIDGET{$self+0}; |
593 | |
595 | |
594 | eval { $self->destroy }; |
596 | eval { $self->destroy }; |
595 | warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/; |
597 | warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/; |
… | |
… | |
1826 | |
1828 | |
1827 | my $idx = $self->{layout}->xy_to_index ($x, $y); |
1829 | my $idx = $self->{layout}->xy_to_index ($x, $y); |
1828 | |
1830 | |
1829 | # byte-index to char-index |
1831 | # byte-index to char-index |
1830 | my $text = $self->{text}; |
1832 | my $text = $self->{text}; |
1831 | utf8::encode $text; |
1833 | utf8::encode $text; $text = substr $text, 0, $idx; utf8::decode $text; |
1832 | $self->{cursor} = length substr $text, 0, $idx; |
1834 | $self->{cursor} = length $text; |
1833 | |
1835 | |
1834 | $self->_set_text ($self->{text}); |
1836 | $self->_set_text ($self->{text}); |
1835 | $self->update; |
1837 | $self->update; |
1836 | |
1838 | |
1837 | 1 |
1839 | 1 |