GNOME Bugzilla – Bug 744819
Incorrect cursor position after backspace at end of line with autowrap disabled -- breaks ncurses display
Last modified: 2015-03-03 14:34:00 UTC
(I'm using GNOME Terminal 3.6.2. I wasn't able to select that version.) ncurses disables wraparound mode (DECAWM) when outputting a character in the right margin (last column) of the terminal. If the next character after that is a backspace, the cursor should move back to the second-to-last column, but gnome-terminal (or libvte) gets confused and keeps it in the last column. Further backspace characters do move the cursor, but at that point the cursor position is already off by one compared to what ncurses assumes, and so things break. Here's a simple testcase (make ^H a real backspace and substitute some existing terminal for /dev/pts/25): (tput clear; tput rmam; echo -n "abcdefghijklmnopqrst^H ") > /dev/pts/25 ("tput rmam" turns off autowrap mode (outputs "^[[?7l" for xterm).) The output for gnome-terminal when the terminal width is 5 is "abcd " (i.e., the cursor was not moved back before outputting the space.) The output for for xterm when the terminal width is 5 is "abc e" ("e" might be an error too, but at least the cursor position is correct.) /Ulfalizer
You're using an ancient version of gnome-terminal/vte. There have been lots of fixes to the emulation; in particular, this bug has been fixed (you get "abc t" and the cursor over "t"). xterm is definitely buggy, the output depends on timing. The command above gives "abc e", while piping through slowcat (part of vte tarball) results in "abc t". I'll follow up with its maintainer.
s/ancient/old :) It was fixed for the vte-0.38 series.
At least it's merely old in Ubuntu 14.04 then. :)
You could try to get latest vte (git or tarball), compile, and run locally (without installing) as ./src/vte-2.91. Please let us know if you experience any other emulation issues there. Unfortunately it's not easy to install the fix on 14.04. You can either try to backport the fix to vte-0.36.x and install that system-wide, or go with vte-0.38 but then you need to upgrade gnome-terminal to 3.14, probably requiring to update the whole Gtk+ stack, let alone some hacking with the bash profile scripts. Or just wait for 2 months and upgrade to 15.04 which will ship these. *** This bug has been marked as a duplicate of bug 731155 ***
It's not critical. Only produces minor cosmetic annoyances for long commands in a readline + ncurses UI I'm developing. Glad it's been fixed! Thanks, Ulf
*** This bug has been marked as a duplicate of bug 731155 ***
FYI: xterm-315 fixes its bug too, the output is "abc t"