twn | Simple terminal multiplexer |
| download: https://git.y1.nz/archives/twn.tar.gz | |
| README | Files | Log | Refs |
codes.h
1 /* list of all codes I need to worry about, with descriptions */
2 /* (that is, if they do window-specific things? or...) */
3 /* this is psuedocode, but will later be converted to c. */
4
5 /* BECAUSE I'M LAZY: these are based on the alpine linux console_codes man page. */
6 /* Those are just the codes my system supports. Feel free to edit these */
7 /* to support your system as well. If you send me a patch, and a description */
8 /* of your system (so I can test/integrate your changes correctly), I will */
9 /* see if it is possible to add support for it. */
10
11 #define ESC (char) 0x1B
12 #define CSI (char) 0x9B
13
14 /**********************/
15 /* CONTROL CHARACTERS */
16 /**********************/
17
18 /* backspace one column (but not past beginning of line) */
19 #define BS (char) 0x08
20
21 /* goes to next tab stop, or to EOL */
22 #define HT (char) 0x09
23
24 /* linefeeds (plus carriage return if LF/NL is set) */
25 #define LF (char) 0x0A
26 #define VT (char) 0x0B
27 #define FF (char) 0x0C
28
29 /* carriage return */
30 #define CR (char) 0x0D
31
32 /**********************************/
33 /* ESCAPE (but Not CSI) SEQUENCES */
34 /**********************************/
35
36 /* "reset" (what attributes, exactly?) */
37 #define RIS 'c'
38
39 /* linefeed */
40 #define IND 'D'
41
42 /* newline */
43 #define NEL 'E'
44
45 /* set tab stop at current column */
46 #define HTS 'H'
47
48 /* reverse linefeed */
49 #define RI 'M'
50
51 /* DEC private identification (return "ESC[?6c") */
52 #define DECID 'Z'
53 // TODO or should this be passed to parent? hm...
54
55 /************************/
56 /* ESC[ or CSI SEQUENCES */
57 /************************/
58 /* the numerical arguments are referred to by $1, $2, $3, etc. */
59 /* ALSO (I think?) all row/col numbers are 1-INDEXED!!! */
60
61 /* insert $1 blank characters */
62 #define ICH '@'
63
64 /* Move cursor up $1 steps */
65 #define CUU 'A'
66
67 /* Move cursor down $1 steps */
68 #define CUD 'B'
69
70 /* Move cursor right $1 steps */
71 #define CUF 'C'
72
73 /* Move cursor left $1 steps */
74 #define CUB 'D'
75
76 /* Move cursor down $1 of rows, and to column 1 */
77 #define CNL 'E'
78
79 /* Move cursor up $1 rows and to column 1 */
80 #define CPL 'F'
81
82 /* Move cursor to column $1 in current row */
83 #define CHA 'G'
84
85 /* Move cursor to row $1 and column $2 */
86 #define CUP 'H'
87
88 /* Erase display, based on $1: */
89 /* 1 > (1, 1) to cursor */
90 /* 2 > whole display */
91 /* 3 > whole display and scrollback buffer */
92 /* else > cursor to (max, max) */
93 #define ED 'J'
94
95 /* Erase line, based on $1: */
96 /* 1 > from column 1 to cursor */
97 /* 2 > whole line */
98 /* else > from cursor to end of line */
99 #define EL 'K'
100
101 /* Insert $1 blank lines */
102 #define IL 'L'
103
104 /* Delete $1 lines */
105 #define DL 'M'
106
107 /* Delete $1 chars on current line */
108 #define DCH 'P'
109
110 /* Erase $1 chars on current line */
111 #define ECH 'X'
112
113 /* Move cursor right $1 columns */
114 #define HPR 'a'
115
116 /* Move cursor to row $1, current column */
117 #define VPA 'd'
118
119 /* Move cursor down $1 rows */
120 #define VPR 'e'
121
122 /* Move cursor to row $1, column $2 */
123 #define HVP 'f'
124
125 /* Clear tab stop(s) based on $1: */
126 /* empty > only at current position */
127 /* 3 > clear all tab stops */
128 #define TBC 'g'
129
130 /* Save cursor location */
131 #define SCOSC 's'
132
133 /* Restore cursor location */
134 #define SCORC 'u'
135
136 /* Move cursor to column $1 in current row */
137 #define HPA '`'
138
139 /***************************************************/
140 /* ESC [ $1 ; $2 ; ... m: select graphic rendition */
141 /***************************************************/
142 /* we need to manage these too, so subterms have independent coloring. */
143 /* the values defined here correspond to $1. */
144
145 #define ATTR_RESET 0
146 #define ATTR_SET_BOLD 1
147 #define ATTR_SET_HALF_BRIGHT 2
148 #define ATTR_SET_ITALIC 3
149 #define ATTR_SET_UNDERSCORE 4
150 #define ATTR_SET_BLINK 5
151 #define ATTR_SET_REVERSE 6
152
153 #define ATTR_SET_UNDERLINE 21
154 #define ATTR_SET_NORMAL_INTENSITY 22
155 #define ATTR_SET_NO_ITALIC 23
156 #define ATTR_SET_NO_UNDERLINE 24
157 #define ATTR_SET_NO_BLINK 25
158 #define ATTR_SET_NO_REVERSE 27
159
160 #define ATTR_SET_FG_BLACK 30
161 #define ATTR_SET_FG_RED 31
162 #define ATTR_SET_FG_GREEN 32
163 #define ATTR_SET_FG_BROWN 33
164 #define ATTR_SET_FG_BLUE 34
165 #define ATTR_SET_FG_MAGENTA 35
166 #define ATTR_SET_FG_CYAN 36
167 #define ATTR_SET_FG_WHITE 37
168 #define ATTR_SET_FG_CUSTOM 38 /* takes additional parameter */
169 #define ATTR_SET_DEFAULT_FG 39 /* takes additional parameter */
170
171 #define ATTR_SET_BG_BLACK 40
172 #define ATTR_SET_BG_RED 41
173 #define ATTR_SET_BG_GREEN 42
174 #define ATTR_SET_BG_BROWN 43
175 #define ATTR_SET_BG_BLUE 44
176 #define ATTR_SET_BG_MAGENTA 45
177 #define ATTR_SET_BG_CYAN 46
178 #define ATTR_SET_BG_WHITE 47
179 #define ATTR_SET_BG_CUSTOM 48 /* takes additional parameter */
180 #define ATTR_SET_DEFAULT_BG 49 /* takes additional parameter */
181
182 #define ATTR_SET_FG_BLACK_BRIGHT 100
183 #define ATTR_SET_FG_RED_BRIGHT 101
184 #define ATTR_SET_FG_GREEN_BRIGHT 102
185 #define ATTR_SET_FG_BROWN_BRIGHT 103
186 #define ATTR_SET_FG_BLUE_BRIGHT 104
187 #define ATTR_SET_FG_MAGENTA_BRIGHT 105
188 #define ATTR_SET_FG_CYAN_BRIGHT 106
189 #define ATTR_SET_FG_WHITE_BRIGHT 107
190
191 #define ATTR_SET_BG_BLACK_BRIGHT 100
192 #define ATTR_SET_BG_RED_BRIGHT 101
193 #define ATTR_SET_BG_GREEN_BRIGHT 102
194 #define ATTR_SET_BG_BROWN_BRIGHT 103
195 #define ATTR_SET_BG_BLUE_BRIGHT 104
196 #define ATTR_SET_BG_MAGENTA_BRIGHT 105
197 #define ATTR_SET_BG_CYAN_BRIGHT 106
198 #define ATTR_SET_BG_WHITE_BRIGHT 107
199
200 /****************************************/
201 /* ESC [ $1 ; $2 ; ... h: MODE SWITCHES */ (some of which are positional)
202 /****************************************/
203 /* the values here correspond to $1. */
204
205 #define DECCRM 3 /* display control chars. do we need to handle this? */
206 #define DECIM 4 /* set insert mode. again, not sure what this does... */
207 #define LFNL 20 /* set LF/NL - echo CR after all LF, VT, and FF */
208
209 /*****************************************/
210 /* ESC [ $1 ; $2 ; ... n: STATUS REPORTS */
211 /*****************************************/
212
213 #define CPR 6 /* report cursor position. Anwers with 'ESC [ y ; x R' */
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.