Further Reading¶
As a developer’s API, blessed is often bundled with frameworks and toolsets
that dive deeper into Terminal I/O programming than Terminal
offers.
Here are some recommended readings to help you along:
terminfo(5) manpage of your preferred posix-like operating system. The capabilities available as attributes of
Terminal
are directly mapped to those listed in the column Cap-name.termios(4) of your preferred posix-like operating system.
The TTY demystified by Linus Åkesson.
A Brief Introduction to Termios by Nelson Elhage.
Richard Steven’s Advance Unix Programming (“AUP”) provides two very good chapters, “Terminal I/O” and “Pseudo Terminals”.
GNU’s The Termcap Manual by Richard M. Stallman.
Chapter 4 of CUNY’s course material for Introduction to System Programming, by Stewart Weiss
Chapter 11 of the IEEE Open Group Base Specifications Issue 7, “General Terminal Interface”
The GNU C Library documentation, section Low-Level Terminal Interface
The source code of many popular terminal emulators. If there is ever any question of “the meaning of a terminal capability”, or whether or not your preferred terminal emulator actually handles them, read the source!
These are often written in the C language, and directly map the “Control Sequence Inducers” (CSI, literally
\x1b[
for most modern terminal types) emitted by most terminal capabilities to an action in a series ofcase
switch statements.- Many modern libraries are now based on libvte (or just ‘vte’): Gnome Terminal, sakura, Terminator, Lilyterm, ROXTerm, evilvte, Termit, Termite, Tilda, tinyterm, lxterminal.
- xterm, urxvt, SyncTerm, and EtherTerm.
- There are far too many to name, Chose one you like!
The source code of the tty(4), pty(4), and the given “console driver” for any posix-like operating system. If you search thoroughly enough, you will eventually discover a terminal sequence decoder, usually a
case
switch that translates\x1b[0m
into a “reset color” action towards the video driver. Thoughtty.c
is linked here (the only kernel file common among them), it is probably not the most interesting, but it can get you started:The TTY driver is a great introduction to Kernel and Systems programming, because familiar components may be discovered and experimented with. It is available on all operating systems (except windows), and because of its critical nature, examples of efficient file I/O, character buffers (often implemented as “ring buffers”) and even fine-grained kernel locking can be found.
Thomas E. Dickey has been maintaining xterm, as well as a primary maintainer of many related packages such as ncurses for quite a long while.
termcap & terminfo (O’Reilly Nutshell) by Linda Mui, Tim O’Reilly, and John Strang.
Note that System-V systems, also known as Unix98 (SunOS, HP-UX, AIX and others) use a Streams interface. On these systems, the ioctl(2) interface provides the
PUSH
andPOP
parameters to communicate with a Streams device driver, which differs significantly from Linux and BSD.Many of these systems provide compatible interfaces for Linux, but they may not always be as complete as the counterpart they emulate, most especially in regards to managing pseudo-terminals.