3/26/2026 at 4:57:54 AM
> The real fix requires agreement at the protocol level, across terminal emulators, shell applications, and TUI frameworks simultaneously.Yeah, and ideally you want the backward compatibility, so we don't have to recompile the world or patch things like e.g. cat.
But yeah, the root of the problem is that a) the TUI-like application that manually drives the terminal, with cursor movement/line folding/redrawing etc. needs to know, at every single moment, the precise location of the cursor and the coordinates of every single character it outputted (to e.g. properly handle backspacing, including over the line folds: \b explicitly doesn't move to the previous line by default and very wide and old convention), and b) getting that coordination info from the terminal in quick, reliable, and side-effect free manner is impossible, so you have to guess.
by Joker_vD
3/26/2026 at 7:10:42 AM
I think we really need a new protocol for apps to use when interacting with terminals, which is richer than sending escape sequences.It could just be the path to a Unix domain socket in an environment variable, where that socket speaks some kind of RPC protocol
by skissane
3/26/2026 at 8:18:27 AM
Like [0] that Windows has for its console? This API has just recently finally lost to UNIX's in-line signaling, because the in-band controls can be proxied through almost anything, including literal serial line with two RX-TX wires and a common ground; the downside, of course, is that you have to build "out-of-line" signalling on your own.If getting the current cursor position in the terminal were as easy (and as fast) as calling GetConsoleScreenBufferInfo, instead of sending "\e[6n" to the terminal and then reading input from it and looking for "\e[(\d+);(\d+)R" inside and then somehow unreading the input before that device report, yeah, that'd be nice and would allow solving a lot of problems with mere brute force. Sadly, it is not, and so most reimplementations of e.g. readline/linenoise functionality in shells and prompts (Erlang's shell went through 2 internal reimplementations just in my time using it, for example) are flying blind, hoping that their implementation of wcwidth(3) matches the terminal's one.
[0] https://learn.microsoft.com/en-us/windows/console/console-fu...
by Joker_vD