5 ms·
There's no escaping it: an exploration of ANSI codes
- trumpdong 4mo agoI was expecting something more... informative?
- kps 4mo agoStart with ECMA-48 https://ecma-international.org/publications-and-standards/standards/ecma-48/ https://ecma-international.org/publications-and-standards/st... Then find DEC and XTerm extensions https://invisible-island.net/xterm/ctlseqs/ctlseqs.html https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
- JdeBP 4mo agoI recommend starting with ECMA-35. The actual structure of escape sequences is explained there. Otherwise it gets lost that it's the ESC [ that is the entire escape sequence, an alternative form of CSI, and that this actually is one part of an entire mechanism of escape sequences with intermediate and final bytes. It's a control sequence that CSI then introduces.
- kevin_thibedeau 4mo agoThe important part is that the escape prefix is just an alternate way to represent each of the 32 C1 control characters with a pair of 7-bit characters.
- noelwelsh 4mo agoThis would be far better without the slop and just the widget with a little bit of explanatory text.
- mspreij 4mo agohttps://en.wikipedia.org/wiki/ANSI_escape_code https://en.wikipedia.org/wiki/ANSI_escape_code goes a bit more in-depth.
- daneel_w 4mo agoI am not sure if it's part of the ANSI standard, but the AmigaDOS shell supported a set of ANSI codes that provided single line stepping - not a whole text line/row, but a single raster line - allowing for pretty advanced graphics rendering by overlaying rows of text shifted by just one or two pixels vertically. It was a tad fancier than the very common ASCII art, being used in the same venues and always a "treat" to come across, though not as common due to the size and additional time needed to render.
- Lerc 4mo agoI have never quite found a full and comprehensive catalogue of escape sequences. I think the last time I needed a list, I found a developer of a terminal app(might have been kitty?) had a page with what they had found. This isn't no much a specification as a collection of variously supported codes. Some have been deliberately killed off (like setting the window title to the string returned from a commandline string). An escape code so powerful that it gives text files shell access.
- shakna 4mo agoOr, a collection of specifications. C0 in ISO 6429 C1 in ECMA-48 Though, the big one is C1. OS commands and CSI (graphics, cursors, etc.) are both defined in it. And hyperlinks have sorta default to ESC]8 but its not in any of the standards. Ta to Gnome and VTE for making it semi-supported everywhere. The Linux manpage for ANSI escapes is pretty comprehensive as a catalogue. [1] If you're looking for what you can actually use, and what has been deprecated, man should be the first stop. [1] https://man7.org/linux/man-pages/man4/console_codes.4.html https://man7.org/linux/man-pages/man4/console_codes.4.html
- skissane 4mo ago> The Linux manpage for ANSI escapes is pretty comprehensive as a catalogue. [1] If you're looking for what you can actually use, and what has been deprecated, man should be the first stop. The Linux console_codes(4) man page is only what escape sequences are supported by the Linux VT console, which you probably aren't using. You are more likely using a GUI terminal emulator under Wayland or X, in which case you need to look at the docs for that terminal emulator. Most terminal emulators have more comprehensive support than the VT console does, so if the VT console supports it, a recent terminal emulator probably will too. The exception is "Linux Console Private CSI Sequences", which I doubt terminal emulators would support, although some of them could be supported.
- shakna 4mo ago> Most terminal emulators have more comprehensive support than the VT console does, so if the VT console supports it, a recent terminal emulator probably will too. The exception is "Linux Console Private CSI Sequences", which I doubt terminal emulators would support, although some of them could be supported. Huh? Most of them have less. And none of them will have documented the OS-specific escapes, because that's kinda the role of console_codes. xterm-specific things, which supports more than most other emulators, and a lot more than VT, is documented in... console_codes. Sure, they have their own documentation, too. But console_codes is absolutely not only what is supported by the Linux VT console.
- kevin_thibedeau 4mo ago> Even fancier terminal UIs, like Vim and htop, extend the ANSI codes for cursor positioning and screen manipulation These aren't an extension. They're either part of ECMA-48 like the color codes or legacy from VT52/VT100 that has become de facto standard.
- kstrauser 4mo agoI don’t think that’s right. Ghostty has its own TERM=xterm-ghostty value, which surely it wouldn’t need if it supported nothing more than ECMA-48/VT100.
- Chu4eeno 4mo agoThat's usually only necessary for more questionable things that was niche for a reason, like file transfer, images, audio, and rediscovering the root cause of old security issues like this all over again: https://web.archive.org/web/20030302210517/http://www.digitaldefense.net/labs/papers/Termulation.txt https://web.archive.org/web/20030302210517/http://www.digita...
- kevin_thibedeau 4mo agoCursor movement isn't an extension. Xterm extensions don't deal with in terminal rendering.
- skissane 4mo agoAs an aside, I'd always been told that the actual ANSI X3.64 standard wasn't available unless you paid $$$ for it, and that's why people referred to ECMA-48 instead. Recently, I discovered that it has been available for free all this time from the US government, who republished it as FIPS Pub 86: https://nvlpubs.nist.gov/nistpubs/Legacy/FIPS/fipspub86.pdf https://nvlpubs.nist.gov/nistpubs/Legacy/FIPS/fipspub86.pdf