Fix backspacing in cooked mode
This is a meta-bug of several technical issues.
Switch to cooked mode (e.g. execute cat
), type some text, press Backspace here and there.
Expected sane behavior from a user's point of view:
-
Whenever you hit Enter, the text printed by
cat
should exactly match the input text as seen on the screen. -
If you type exactly one line of text (the last letter is in the last column), pressing Backspace should remove the last letter.
-
If you type a multiline text, pressing Backspace should move back to the previous line in the obvious way.
-
If you Backspace over a double-wide character, this entire character should be erased and the cursor should retreat by 2 cells.
-
If there was an unused cell at the right edge before wrapping because a double-wide character didn't fit in the last column, pressing Backspace should skip that unused cell when walking backwards.
What needs to be done:
-
Currently the 80th letter remains there and the 79th letter is erased. This is reported in #60 (closed), and is the result of the fix to 731155 which we cannot just revert and see ncurses apps break. The investigation in konsole 399615 reveals that
screen
,tmux
andurxvt
manage to fix both at the same time, by (perhaps accidentally) behaving differently based on the autowrap mode. If the last character is received when autowrap is enabled, the "pending wrap" flag is set (or with VTE's internals: the cursor would move to the invisible 81st column). But if the last character is received when autowrap is disabled, the "pending wrap" flag is probably not set (with VTE's internals: the cursor would remain in the 80th column). We would also need to implement this "dual" behavior. -
We'd need reverse wraparound (764206), at least across soft linebreaks.
screen
andurxvt
allow reverse wraparound everywhere,tmux
allows it across soft linebreaks only. I favor tmux's approach. -
Not a VTE but a kernel issue. It was me adding support for backspacing over a CJK to Linux, back in 2007, but did it incorrectly: as far as I remember, the VT layer retreats the cursor by 2 cells upon receiving a backspace, hence it's only fixed on the console. Instead, the TTY(?) layer, where cooked mode is handled, should emit the
\b \b
sequence twice. I should fix it in Linux. (On a side note, the kernel's wcwidth table should also be updated.) BSD and friends will be up for others to fix. -
None of
screen
,tmux
andurxvt
does this, so probably we'd be the first one, hence it's a bit more risky, but why not.