Merge pull request #13 from rdebath/patch-fixes
[congif.git] / term.h
blob097aeee713774df8752c82b0ab9e6d3917f17a7b
1 #define A_NORMAL 0x00
2 #define A_BOLD 0x01
3 #define A_DIM 0x02
4 #define A_ITALIC 0x04
5 #define A_UNDERLINE 0x08
6 #define A_BLINK 0x10
7 #define A_INVERSE 0x20
8 #define A_INVISIBLE 0x40
9 #define A_CROSSED 0x80
11 #define M_DISPCTRL 0x0001
12 #define M_INSERT 0x0002
13 #define M_NEWLINE 0x0004
14 #define M_CURSORKEY 0x0008
15 #define M_WIDETERM 0x0010
16 #define M_REVERSE 0x0020
17 #define M_ORIGIN 0x0040
18 #define M_AUTOWRAP 0x0080
19 #define M_AUTORPT 0x0100
20 #define M_MOUSEX10 0x0200
21 #define M_CURSORVIS 0x0400
22 #define M_MOUSEX11 0x0800
23 #define M_ISOLAT1 0x1000
25 #define EMPTY 0x0020
26 #define BCE 1
27 #if !BCE
28 #define BLANK (Cell) {EMPTY, def_attr, def_pair}
29 #else
30 #define BLANK (Cell) {EMPTY, term->attr, term->pair}
31 #endif
33 #define MAX_PARTIAL 0x100
34 #define MAX_PARAMS 0x10
36 typedef struct Cell {
37 uint16_t code;
38 uint8_t attr;
39 uint8_t pair;
40 } Cell;
42 typedef enum CharSet {CS_BMP, CS_ISO, CS_VTG, CS_437} CharSet;
43 typedef enum State {S_ANY, S_ESC, S_CSI, S_OSC, S_OSCESC, S_STR, S_STRESC, S_UNI} State;
45 typedef struct SaveCursor {
46 int row, col;
47 } SaveCursor;
49 typedef struct SaveMisc {
50 int row, col;
51 int origin_on;
52 uint8_t attr;
53 uint8_t pair;
54 CharSet cs_array[2];
55 int cs_index;
56 } SaveMisc;
58 typedef struct Term {
59 int rows, cols;
60 int row, col;
61 int top, bot;
62 uint16_t mode;
63 uint8_t attr;
64 uint8_t pair;
65 Cell **addr;
66 Cell *cells;
67 CharSet cs_array[2];
68 int cs_index;
69 SaveCursor save_cursor;
70 SaveMisc save_misc;
71 State state;
72 int parlen;
73 int unilen;
74 uint8_t partial[MAX_PARTIAL];
75 uint8_t plt[0x30];
76 uint8_t plt_local, plt_dirty;
77 } Term;
79 void set_verbosity(int level);
80 Term *new_term(int rows, int cols);
81 void parse(Term *term, uint8_t byte);
82 void set_default_palette(char * optarg);