-#include <stdlib.h>
-
-/* Color codes: 0 = black, 1 = red, 2 = green, 3 = yellow, 4 = blue,
- * 5 = magenta, 6 = cyan, 7 = white.
- *
- * An 'attribute' as used in this library means an 8-bit value that conveys
- * a foreground color code, a background color code, and the bold
- * and blink bits. Each cell in the virtual terminal screen is associated
- * with an attribute that specifies its appearance. The bits of an attribute,
- * from most significant to least significant, are
- *
- * bit: 7 6 5 4 3 2 1 0
- * content: S F F F H B B B
- * | `-,-' | `-,-'
- * | | | |
- * | | | `----- 3-bit background color code (0 - 7)
- * | | `--------- blink bit (if on, text is blinking)
- * | `------------- 3-bit foreground color code (0 - 7)
- * `----------------- bold bit
- *
- * It is however recommended that you use the provided macros rather
- * than dealing with this format directly.
- *
- * Sometimes we will call the 'SFFF' nibble above the 'extended
- * foreground color code', and the 'HBBB' nibble the 'extended background
- * color code'. So the extended color codes are just the regular
- * color codes except that they have an additional bit (the most significant
- * bit) indicating bold/blink.
- */
-
-/* retrieve attribute fields */
-#define ROTE_ATTR_BG(attr) ((attr) & 0x07)
-#define ROTE_ATTR_FG(attr) (((attr) & 0x70) >> 4)
-
-/* retrieve 'extended' color codes (see above for info) */
-#define ROTE_ATTR_XBG(attr) ((attr) & 0x0F)
-#define ROTE_ATTR_XFG(attr) (((attr) & 0xF0) >> 4)
-
-/* set attribute fields. This requires attr to be an lvalue, and it will
- * be evaluated more than once. Use with care. */
-#define ROTE_ATTR_MOD_BG(attr, newbg) attr &= 0xF8, attr |= (newbg)
-#define ROTE_ATTR_MOD_FG(attr, newfg) attr &= 0x8F, attr |= ((newfg) << 4)
-#define ROTE_ATTR_MOD_XBG(attr, newxbg) attr &= 0xF0, attr |= (newxbg)
-#define ROTE_ATTR_MOD_XFG(attr, newxfg) attr &= 0x0F, attr |= ((newxfg) << 4)
-#define ROTE_ATTR_MOD_BOLD(attr, boldbit) \
- attr &= 0x7F, attr |= (boldbit)?0x80:0x00
-#define ROTE_ATTR_MOD_BLINK(attr, blinkbit) \
- attr &= 0xF7, attr |= (blinkbit)?0x08:0x00
-
-/* these return non-zero for 'yes', zero for 'no'. Don't rely on them being
- * any more specific than that (e.g. being exactly 1 for 'yes' or whatever). */
-#define ROTE_ATTR_BOLD(attr) ((attr) & 0x80)
-#define ROTE_ATTR_BLINK(attr) ((attr) & 0x08)
-
-/* Represents each of the text cells in the terminal screen */
-typedef struct RoteCell_ {
- unsigned char ch; /* >= 32, that is, control characters are not
- * allowed to be on the virtual screen */
-
- unsigned char attr; /* a color attribute, as described previously */
-} RoteCell;
-
-/* Declaration of opaque rote_Term_Private structure */
-typedef struct RoteTermPrivate_ RoteTermPrivate;
-
-/* Represents a virtual terminal. You may directly access the fields
- * of this structure, but please pay close attention to the fields
- * marked read-only or with special usage notes. */
-typedef struct RoteTerm_ {
- int rows, cols; /* terminal dimensions, READ-ONLY. You
- * can't resize the terminal by changing
- * this (a segfault is about all you will
- * accomplish). */
-
- RoteCell **cells; /* matrix of cells. This
- * matrix is indexed as cell[row][column]
- * where 0 <= row < rows and
- * 0 <= col < cols
- *
- * You may freely modify the contents of
- * the cells.
- */
-
- int crow, ccol; /* cursor coordinates. READ-ONLY. */
-
- unsigned char curattr; /* current attribute, that is the attribute
- * that will be used for newly inserted
- * characters */
-
- pid_t childpid; /* pid of the child process running in the
- * terminal; 0 for none. This is READ-ONLY. */
-
- RoteTermPrivate *pd; /* private state data */