LibTermFns is a library that provides a wrapper
around terminal-based properties for C++ programs. Included
routines include functions for colored text, clearing the
screen, moving cursor positions, querying and setting keyboard
LEDs, and key remapping. In addition to the wrapper functions
the library contains (POSIX) thread-based functions for console
widgets such as interactive progress bars, animated text,
hierarchical menus, and more. The source distribution contains
a number of example programs that demonstrate usage of the
library and reveal the beginnings of what can be coded with it.
The target system for
LibTermFns is a modern
version of Linux. However, any modern Unix system (within
reason) can operate with the core of text manipulation
The documentation for
LibTermFns and the example
programs in the source is the README
(also found in the library source). If something is missing, or
there is an error (or typo), send me an e-mail at
The platform with the most coverage of features is Linux (the author lives on Gentoo). The following Linux-specific man pages are useful to consult when attempting to pick apart the code:
Additionally, this site
contains a number of console-related information, in particular
the keys table used to generate the key defs in
LibTermFns. See the next section for more
console-related code and references.
Much of the
LibTermFns code was based on picking through
the source to various commandline utilities (see below for a
list of man pages for several of these programs). The following
list is a nice collection of code worth checking out:
TTY_sniff) that implements this differently. The base of these programs is that a tty is a character device that can be written to or read from in plain-text (try "
echo plain-text > /dev/tty") corresponding to STDIN and STDOUT on a non-virtual terminal (see
proc(5)) on a Linux box.
ioctlcalls (see "
man console_ioctl"); 2) Escape sequences (see "
man console_codes"); 3)
xterm-specific codes (see the official documentation); in addition to this check out "
test_code/TFNS-linux/console_codes_palette.info.txt" in the source distribution and spare some frustrations trying to figure out how the colors get used and defined;
The following two (Linux-specific) headers are used in the
library. The first has defs corresponding to a number of the
ioctl calls (see "
console_ioctl" on a Linux box). The second is (mostly) the
remainder of the
ioctl defs given in
console_ioctl, again on a Linux box:
#include <linux/kd.h>(path: "
#include <linux/vt.h>(path: "
stty(1), setterm(1), proc(5), w(1), pts(4), dumpkeys(1), kbd_mode(1), loadkeys(1), setleds(1), tty(4), mapscrn(8), tput(1), showkey(1), keymaps(5);