From 9c028bba7e526d4e0e152c33ba3c7b14d034c301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hinrik=20=C3=96rn=20Sigur=C3=B0sson?= <hinrik.sig@gmail.com> Date: Mon, 18 Apr 2011 17:01:12 +0000 Subject: [PATCH] Make transpose-chars work when cursor is at end of line Petr Pisar: Upstream commit de7200ea6ccf466f1a6d74cd86e3b53b590c2c43 ported to 1.289. --- lib/POE/Wheel/ReadLine.pm | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/lib/POE/Wheel/ReadLine.pm b/lib/POE/Wheel/ReadLine.pm index 4a3a89f..86e1770 100644 --- a/lib/POE/Wheel/ReadLine.pm +++ b/lib/POE/Wheel/ReadLine.pm @@ -1848,7 +1848,12 @@ sub rl_clear_screen { sub rl_transpose_chars { my ($self, $key) = @_; - if ($self->[SELF_CURSOR_INPUT] > 0 and $self->[SELF_CURSOR_INPUT] < length($self->[SELF_INPUT])) { + if (length($self->[SELF_INPUT]) > 1 && length($self->[SELF_INPUT]) == $self->[SELF_CURSOR_INPUT]) { + my $transposition = reverse substr($self->[SELF_INPUT], -2, 2); + substr($self->[SELF_INPUT], -2, 2) = $transposition; + _curs_left(_display_width($transposition)); + print $stdout _normalize($transposition); + } elsif (length($self->[SELF_INPUT]) > 1 && $self->[SELF_CURSOR_INPUT] > 0) { my $width_left = _display_width(substr($self->[SELF_INPUT], $self->[SELF_CURSOR_INPUT] - 1, 1)); my $transposition = reverse substr($self->[SELF_INPUT], $self->[SELF_CURSOR_INPUT] - 1, 2); -- 1.7.7.4