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
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...
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
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.
I'm not sure about overline, but strikethrough should also work.
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
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
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.
#!/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 ''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.
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.
This is for dropbear ssh have not tested it on openssh, yet.
ANSI Escape Artist – webapp for generating terminal escape codes