\b
doesn't go all the way back on wrapped lines
#15348
Replies: 5 comments 1 reply
-
This is expected behavior for a standard VT terminal. Quoting from the DEC STD 070 Reference Manual for the Back Space control (page 5-63):
|
Beta Was this translation helpful? Give feedback.
-
It's just really terribly inconvenient to never know if you can use It's too bad the DEC standard made that call, but standards aren't always set in stone and can evolve over time to better serve user needs. I mean, back then they had things like ENQ, ACK, BEL, etc that are all but ignored these days. I took a look real quick and there's lot of stuff that have been left behind from the standard. Here's a direct quote stating double width lines are a required feature: Page 1-18
I've never even heard of that before. And it's not just on that one page, double width lines are mentioned 26 times. But I'd be willing to bet no one meets that requirement anymore. I doubt they ever imagined terminals that were vastly different sizes or that could change size on the fly. I'm not saying the DEC STD 070 standard isn't still influential, but terminal emulator developers do make practical decisions about what aspects to implement based on the needs and constraints of modern computing. |
Beta Was this translation helpful? Give feedback.
-
I've just done some testing, and yes PuTTY does this, and so does iTerm2, but the only other terminal I could find that matches that behavior is Rxvt (but not all versions). Gnome Terminal does NOT wrap back onto the previous line. Nor does XTerm. Nor did any of the other 30 or so terminals I tested. I can't imagine we'd choose to side with PuTTY, iTerm2, and Rxvt over everyone else, in addition to ignoring the standard.
You'd lose that bet. Windows Terminal and Conhost both support it, as does XTerm, MLTerm, Konsole, and like 15 or so other terminals that I'm aware of. I know not everyone cares about standards, but I certainly do, and I would like to improve our standards compliance - not make it worse. |
Beta Was this translation helpful? Give feedback.
-
I realize I'm not likely to change your mind, but I'm still interested in the conversation. The terminals that the DEC STD 070 standards were written for had a fixed width in characters. So you could write your code assuming you had, say, 80 characters. You send a string of text you decided on ahead of time and then safely backspace over it and overwrite it. For example, you could print "Loading..." and then send 10 BS before replacing it with "Successfully loaded." However, a modern terminal could be just 4 columns wide! Without backspace unwrapping, the previous example is no longer safe. There's no string short enough to safely use backspaces with. You have to check your position every single time you want to backspace and have special code that will take you to the end of the line above your current row instead. I think it's important to keep these interfaces usable and efficient. I ended up writing my own version of printf/WriteConsole that iterates over each character and handles backspaces differently. So, I guess technically the problem is solved for me, but I don't think the standard would have even introduced a special BS character if they thought it was going to be unreliable.
Is it really only those 3? I often run in a
I guess I would lose that bet! I doubt any real terminal supports it but it looks like some virtual terminals do. Even PuTTY supports this: echo -e "\033#3This is the top half of a double-height line.\n\033#4This is the bottom half of a double-height line."` I saw screenshots of it in Windows Terminal but I couldn't get it to work myself. How can I test it there? I tried: Write-Host ([char]27 + "#3This is the top half of a double-height line.`n" + [char]27 + "#4This is the bottom half of a double-height line.") But perhaps that was a bad example. There's also extensive discussion about printers in DEC STD 070 that I assume no one follows anymore. The word "printer" comes up 852 times. As technology advances and changes, it's only natural that certain parts of these standards become outdated. (Again, a terminal with 4 columns.) I realize there must be some trade off for moving forward but it does seem others have figured out how to do this effectively without breaking backward compatibility with existing command-line tools, scripts, etc. |
Beta Was this translation helpful? Give feedback.
-
(I'm going to move this to a discussion - it doesn't seem like there's anything for us to do on our end here, but this has been a really interesting discussion so by all accounts, do go on) |
Beta Was this translation helpful? Give feedback.
-
Windows Terminal version
1.16.10261.0
Windows build number
Version 10.0.19045.2965
Other Software
No response
Steps to reproduce
It's easily reproducible in C. This seems to happen with any writing to the console,
WriteConsole
,printf
,putchar
, etc. Just write more letters than you have columns, and try to backspace back. You'll get stuck at the front of a row.Expected Behavior
I just want
\b
to take me back to the previous line if I didn't end the previous line with a\n
. The console knows the line is wrapped. I can increase the size of the window and the cursor will pop back up to the previous line.Actual Behavior
The cursor just gets stuck in the first column and refuses to delete what it just wrote.
I don't even care if it stops working when you end your line with a new line, but not letting you unwrap a line you know is wrapped? This is really hard to code around. You can't just write to the terminal, you have to query your position every time you want to backspace or line wrapping will break your program.
Beta Was this translation helpful? Give feedback.
All reactions