ANSI Escape Codes
gist.github.com
gist.github.com
I'm not sure about overline, but strikethrough should also work.
(Which makes me wonder: is there a way to tell Linux to not use its own console framebuffer driver for displaying TTYs, but rather to instead spawn some userland libsdl binary and connect it to the raw framebuffer? If so, we could presumably just drop in a fully-featured terminal emulator to act as the Linux console.)
I'm not sure how it works with systemd, but back in init land you could just replace the getty lines in /etc/inittab with whatever you wanted to use on that VT, or replace the default login command. What you wonder should be possible.
Source: Quite a long time ago I believed that the Linux framebuffer was the future of development, and spent a lot of time making animated bootup sequences, custom login screens, writing libraries (in collaboration with others) to make development easier without having to go into a "framework" like DirectFB, and using elinks (or was it links2?) for browsing and fbi for image and PDF viewing.
Hey, most of the Linux-based "retro portables" are running a pure "libsdl with Linux framebuffer backend" userland. So it was at least the future of something.
I believe it was links. It had numerous backends from what I recall, to include fb, X, and maybe even svgalib. I don't recall elinks supporting any of that. But I could be wrong.
With the frame buffer, it should be much easier.
That's almost how frecon (and kmscon/systemd-consoled before it) works.
https://chromium.googlesource.com/chromiumos/platform/frecon...
Is this used or packaged in any major Linux distribution besides ChromiumOS? I'd like to try out living inside this for a while (probably in a fullscreened VM) but CrOS is a bit too restrictive/unfamiliar as a userland for me to want to attempt it there. I guess Crouton exists, but I'd be afraid that Crouton would add an additional layer of impedance-mismatch to the VT that isn't there when just using it raw (like the kind you get when using tmux-in-ssh-in-tmux.)
It’s great for terminal status lines.
As pointed out, this refers to the Linux framebuffer console.
It would dial the plant via modem, and I remember being given a list of "escape codes" that determined how the stream of bytes should be rendered on the screen. My program parsed (some of) these codes and displayed the text accordingly, I specifically remember implementing the "move cursor" and "reverse mode" codes...
Not until years after did I realise I had basically built a shitty terminal emulator using Visual Basic text fields.
If you want to have reliable and accurate information on how to control your terminal, consult the documentation on your terminal emulator or the ncurses database. The ncurses database is vast but does not include most of the exotic features of specific terminals.
[tl;dr] dont rely on secondary sources like this, please consult primary documentation instead
The keyboard remapping function is also specific to ANSI.SYS[2].
[1] http://www.ctyme.com/intr/rb-0069.htm
[2] https://en.wikipedia.org/wiki/ANSI.SYS#Keyboard_remapping
There is a Terminals WG over at the XDG[6], but I don’t know if they have produced anything useful yet.
[1]: https://www.ecma-international.org/publications-and-standard... [2]: https://vt100.net/ [3]: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html [4]: https://vt100.net/emu/dec_ansi_parser [5]: https://terminalguide.namepad.de/ [6]: https://gitlab.freedesktop.org/terminal-wg
(ETA: another commenter also recommends https://bjh21.me.uk/all-escapes/all-escapes.xhtml)
FWIW, in a low-level cross-terminal API, I made up some concepts that seemed helpful (and there are also a few comments scattered in there, such as hints about why key mapping is less consistent than one would've guessed): https://www.neilvandyke.org/racket/charterm/#%28part._.Termi...
One of my earliest programming projects was creating my own diary app which used ANSI codes to let you format the text. It also kept track of your cursor movements and encoded them so that you could do neat things like write text anywhere on the screen or overwrite existing text.
[0] Here's a basic example I wrote in Ruby: https://github.com/mike-bourgeous/mb-util/blob/5616cc4ce6218...
str.gsub(/\e\[[^A-Za-z~]*[A-Za-z~]/, '')While the overall focus of the book is on programming with Notcurses[2], the author shares a wealth of related info and history throughout its pages.
There's also Ben Harris's concordance of escape sequences https://bjh21.me.uk/all-escapes/all-escapes.xhtml (Ben is a member of the PuTTY team)
A few months ago I put together a kind of interactive cheatsheet for working with them quickly: http://ansi-escape-artist.surge.sh/
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
EDIT: This is actually linked at the bottom of the article.
It’s a port of sindresorhus’s ansi-escapes library. I find it way more convenient than looking up codes.
https://github.com/shawwn/ansi-escapes-python
It has some basic iTerm2 support too, so you can print out annotations in the console. Think of it like sticky notes.
See also ansi-styles, the lib that Chalk is based on. (Colors! You like colors? Are you a curmudgeony salt like me that refuses to use Rich for some reason? Use that.)
As with ansi-escapes, you can just pip install ansi-styles.
It looks like we may be able to forego setup.cfg soon too. https://stackoverflow.com/a/64151860
#!/bin/dash
fg () ( printf '\033[38;2;%d;%d;%dm' "${1:-0}" "${2:-0}" "${3:-0}"; )
bg () ( printf '\033[48;2;%d;%d;%dm' "${1:-0}" "${2:-0}" "${3:-0}"; )
fg256 () ( printf '\033[38;5;%dm' "${1:-0}"; )
bg256 () ( printf '\033[48;5;%dm' "${1:-0}"; )
N='\033[' x=30
for a in Bl R G Y B M C W # Black Red Green Yellow Blue Magenta Cyan White
do eval $a='$N'"'"$(( x))"m'" \
b$a='$N'"'"$((60+x))"m'" \
${a}bg='$N'"'"$((10+x))"m'" \
b${a}bg='$N'"'"$((70+x))"m'" # bX=bright Xbg=background bXbg=brgt bgnd
x=$((1+x))
done
N=$N'0m'
printf "${B}${Gbg}This is blue on a green background.$N\n"
fg 255
bg 255 255 255
printf "This is red on a white background.$N\n"
x=0
while [ $x -lt 256 ]
do y=$((255-x))
fg256 $x
bg256 $y
printf "%.3d $N" $x
[ $(((1+x)%16)) -eq 0 ] && echo ''
x=$((1+x))
done
echo ''This is for dropbear ssh have not tested it on openssh, yet.
It also works with just the bare terminal line discipline in many flavours of unix: look at the 'lnext' control character in the output from 'stty' on Linux, macOS, or BSD (but not POSIX).
(however the equivalent in emacs itself is ctrl-Q, probably for bad reasons)
Good reasons:
1) Q is mnemonic for Quote.
2) emacs began life on non-Unix platforms (ITS, TOPS-20, Multics), and was only ported to Unix later. Ctrl-Q is inherited from the original ITS emacs.
ANSI Escape Artist – webapp for generating terminal escape codes
Search for both "vertical tab" and "VFU" (Vertical Format Unit). The "VFU" would accept commands to set the vertical tab stops to match whatever form you had. Say there was an address box that was 6 lines the top, a multi-line field 10 lines from the top, and an SSN field 15 lines from the top, and so on. You could program those tab stops and have a tractor feed of those forms loaded. Which would be easier programmatically than, for example, doing the math on how the length of text in some multi-line field in between those two would change the amount of line feeds you would need to send to land in the SSN field.
So, something like:
<vt> Enter the Address Stuff
<vt> Enter some amount of multiline text without having to calculate how many lines it filled
<vt> Now you're in the SSN field