4 ms·
I was a little disappointed by the explanation – I was expecting this to dive deep into how ANSI code came to be, and how they worked. Not just "hey they exist
by SeoxyS 14y ago
I was a little disappointed by the explanation – I was expecting this to dive deep into how ANSI code came to be, and how they worked. Not just "hey they exist and are neat."
You're probably better off reading the Wikipedia article:
https://en.wikipedia.org/wiki/ANSI_escape_code https://en.wikipedia.org/wiki/ANSI_escape_code
Some of the much more interesting codes are the ones that control cursor positioning and redrawing, and are used to create ASCII UIs by libraries like ncurses & readline, and programs like vim & tmux.
I've written a rudimentary chat interface using native ANSI code, which was quite a bit trickier than it looks, but a fun exercise. The tricky part was ensuring that an interactive line of input remained at the bottom of the screen, while the chat room history keeps scrolling above[1].
https://github.com/ChartBoost/zmq-examples/blob/master/chat/client.rb https://github.com/ChartBoost/zmq-examples/blob/master/chat/...
[1]: of course, if you're actually building something for production, don't be an idiot like me and use a real library like ncurses.
- duskwuff 14y agoAlso an interesting, useful reference: http://vt100.net/docs/vt100-ug/ http://vt100.net/docs/vt100-ug/ Note that this doesn't include all VT100 escape codes supported by modern terminals, but it is the basis for how they all work.
- thristian 14y agoThat site is historically interesting (and very useful if you want to write your own terminal emulator) but most actual terminals these days are actually xterm emulators, so it makes sense to look at the xterm docs: http://invisible-island.net/xterm/ctlseqs/ctlseqs.pdf http://invisible-island.net/xterm/ctlseqs/ctlseqs.pdf