Raw keyboard handling in Unix terminals
sw.kovidgoyal.net
sw.kovidgoyal.net
Will we ever just admit that the vt100 tty is just no longer suitable as a basic OS abstraction, and needs to be torn out and replaced? Or in 50 years will simple interactive programs still not be able to detect keyup without importing a bunch of bloat from x11/wayland?
>Command line interfaces are superior even today because the step from interaction to automation is as minimal as possible.
Agreed completely. In fact, the OS should force GUI programs to all speak a coherent language so that you can automate them and pipe data between them. And if the machine is going to serve the user, the user should be in control of the GUI, they should be able to move buttons and UI elements around into the configuration they prefer. This would only be possible if GUI programs had minimal control over actual UI layout, which would make webdevs angry. But given the state of web UI, I think that's an acceptable sacrifice.
Much of the above was possible in lisp machines. But sadly I don't think it would be possible to create such an OS today (unless the "OS" is running in a linux VM and using linux for the actual hardware interface) due to the sheer diversity of hardware. And the closed source nvidia driver would ensure that you never got cool graphics.
That is to say, a large part of what makes the automation capabilities of most terminal applications so strong is specifically that the idea of character streams over raw binary streams being the default.
Can I dream of a lisp machine that lets me do what you are suggesting? I mean, sorta. Early HTML based apps came pretty close on this, but folks regularly refuse to limit themselves to a base set of constructs. Is why it would be easy to user style HN, but basically impossible to do the same to gmail. (gmail, amusingly, created their own theme capabilities...)
No way, it's way more popular and useful than ever.
We just need to ditch vt100 and settle on some sort of xterm variation as the new standard.
I wish something like this was also created for the mouse, so that you could use your mouse everywhere (including the console without any graphical environment running), remotely over ssh, etc. I see no reason why a similar protocol could not transmit mouse events over ssh and allow you to interact, using your mouse, with a remote character-based application.
I would love for such proposals to gain traction and be accepted everywhere.
It's a terminal based mouse server. ncurses supports it so it's theoretically possible to do all the same things in a TUI that you would in a GUI with a mouse.
I hope there's a plan to standardize this with the relevant organizations! I worry that's the only way to see widespread adoption.
I would hazard to say that some basic subset of VT100 commands is "universally" supported, even on Windows if one uses Windows Terminal.
Various obscure high-end features from 1980s, like programmable font bitmaps, or sixel support, much less so.
Also, modern terminals support Unicode, including emoji (as double-width symbols), which was unimaginable in 1980s or 1990s.
This is also true of the Windows Console as of Windows 10. Any VT100 (also VT220, VT4xx, VT5xx, xterm ...) support we add to Terminal eventually flows out to the console host integrated into Windows. :)
What about non-standard features, like drawing, sixels, sound, mouse, touches, clipboard, fonts, true color, transparent background, color emoji, double size text, etc.?
What happens if the application crashes without emitting this? The user is dropped in to the shell and the terminal and shell might misbehave together?
But not to trust what I just read I've installed kitty and tested it and you can type in the "reset" just fine. I hit a bit of a problem with "Entering" it, as apparently if you have numlock enabled (which I do on login) pressing "Enter" sends escape code: "^[[13;129u", but if you disable numlock it is typed in as per documentation: "0x0d - for the Enter key", which in any ascii table is Carriage Return.
And yes, issuing reset restored normal terminal operation.
Every now and they I'll want to do ^K in Vim and inadvertently hit ⌘K instead, which is fun. (`:redraw!` sorts things back out. Though weirdly it occurs to me that now that the terminal seems to somehow remain in alternate mode…)
(Yeah, yeah, I can read the whole thing and see for myself, but I'm hoping someone has a quick answer.)
Applications:
https://vimhelp.org/map.txt.html#modifyOtherKeys
https://github.com/emacs-mirror/emacs/blob/d68f2b8681f8eeb6b...
https://github.com/akinomyoga/ble.sh
https://github.com/mawww/kakoune/commit/47c0d2038807757207cd...
https://github.com/tmux/tmux/wiki/Modifier-Keys#extended-key...
https://github.com/magiblot/tvision/commit/a50569f549465c9ed...
Terminals:
xterm (obviously)
https://github.com/gnachman/iTerm2/commit/ac1aa575011028ed86...
https://github.com/kovidgoyal/kitty/commit/d360d077d1f7723b1...
https://github.com/tomszilagyi/zutty
https://github.com/mintty/mintty/blob/master/wiki/CtrlSeqs.m...