added tests for StretchBlt, PatBlt and BitBlt by Damon Chandler
[reactos.git] / posix / apps / posixw32 / vt100.h
1 /* vt100.h
2 *
3 * AUTHOR: John L. Miller, johnmil@cs.cmu.edu / johnmil@jprc.com
4 * DATE: 8/4/96
5 *
6 * Copyright (c) 1996 John L. Miller
7 *
8 * Full permission is granted to use, modify and distribute
9 * this code, provided:
10 * 1) This comment field is included in its entirity
11 * 2) No money is charged for any work including or based on
12 * portions of this code.
13 *
14 * If you're a nice person and find this useful, I'd appreciate a
15 * note letting me know about it. e-mail is usually what spurs me
16 * on to improve and support software I've written.
17 *
18 */
19
20
21 /* This identifier should be spit back to the computer when a terminal
22 * id is requested.
23 */
24 #define ANSWERBACK_MESSAGE "vt100"
25
26 /* Various terminal-related modes Entries are as follows:
27 * Identification esc. ID If set, if clear
28 */
29
30 /* Keyboard action 2 Locked Unlocked */
31 #define CAPS_MODE 0x00000001
32 /* Insertion 4 Insert Overwrite */
33 #define INSERT_MODE 0x00000002
34 /* Send - Receive 12 Full Echo */
35 #define FULLDUPLEX_MODE 0x00000004
36 /* Line feed/New line 20 New line Line feed */
37 #define NEWLINE_MODE 0x00000008
38
39
40 #define NUM_TERM_ATTR_MODES 9 /* We only track eight '?' escape sequences */
41
42 /* Cursor key ?1 Application Cursor */
43 #define CURSORAPPL_MODE 0x00000010
44 /* ANSI/VT52 ?2 ANSI VT52 */
45 #define ANSI_MODE 0x00000020
46 /* Column ?3 132 80 */
47 #define COL132_MODE 0x00000040
48 /* Scrolling ?4 Smooth Jump */
49 #define SMOOTHSCROLL_MODE 0x00000080
50 /* Screen ?5 Reverse Normal */
51 #define REVSCREEN_MODE 0x00000100
52 /* Origin ?6 Relative Absolute */
53 #define ORIGINREL_MODE 0x00000200
54 /* Wraparound ?7 Wrap Truncate */
55 #define WRAP_MODE 0x00000400
56 /* Auto key repeat ?8 Repeating No repeat */
57 #define REPEAT_MODE 0x00000800
58
59
60 /* Print form feed ?18 Yes No */
61 #define PRINTFF_MODE 0x00001000
62 /* Print extent ?19 Full screen Scrolling region */
63 #define PRINTFULLSCR_MODE 0x00002000
64 /* Keypad application 'Esc =' numeric 'Esc >' */
65 #define KEYPADNUMERIC_MODE 0x00004000
66 /* default mode that we start the emulator with */
67 #define DEFAULT_MODE (NEWLINE_MODE|ANSI_MODE|REPEAT_MODE)
68
69 /* This constant is VERY important - the size of the buffer for
70 * unprocessed vt-100 prints!
71 */
72 #define MAXVTBUFLEN 4096
73
74 /* Constants used in place of actual row and column numbers
75 * for the cursor movement and text erasing and deleting functions.
76 */
77 #define CUR_ROW -999
78 #define CUR_COL -999
79 #define ALL_TABS -1999
80
81 #define LEFT_EDGE 0
82 #define RIGHT_EDGE 12000
83 #define TOP_EDGE 0
84 #define BOTTOM_EDGE 12000
85
86 /* Text attribute definitions; color, font, bold. */
87 #define NUM_SC_ATTRIBUTES 11
88
89 #define SC_RED 0x0001
90 #define SC_GREEN 0x0002
91 #define SC_BLUE 0x0004
92 #define SC_BOLD 0x0010
93 #define SC_UL 0x0020 /* Underlined */
94 #define SC_BL 0x0040 /* Blinking */
95 #define SC_RV 0x0080 /* Reverse video */
96 #define SC_ASCII 0x0100 /* Normal ASCII (USASCII) */
97 #define SC_G0 0x0200 /* graphics set G0 */
98 #define SC_G1 0x0400 /* Graphics set G1 */
99 #define SC_GRAPHICS 0x0800 /* Good question */
100
101
102 /* forward variable declarations */
103
104 extern int termAttrMode[NUM_TERM_ATTR_MODES];
105 extern int alltermAttrModes;
106
107
108 /* prototypes from vt100.c */
109
110 /* functions meant for use outside of the emulator */
111
112 int vtputs(char *f);
113 int vtprintf(char *format, ...);
114 int vtInitVT100(void);
115 int vtProcessedTextOut(char *cbuf, int count);
116
117
118 /* Prototype for functions which MUST BE SUPPLIED BY THE BACK END!!! */
119
120 /* Back-end specific initialization is performed in this function.
121 * this is gauranteed to be called before any other requests are made
122 * of the back end.
123 */
124
125 /* beInitVT100Terminal() -
126 *
127 * This function is called by the VT100 emulator as soon as the
128 * front-end terminal is initialized. It's responsible for setting
129 * initial state of the terminal, and initing our many wacky variables.
130 */
131 int beInitVT100Terminal();
132
133
134 /* beAbsoluteCursor -
135 *
136 * Given an input row and column, move the cursor to the
137 * absolute screen coordinates requested. Note that if the
138 * display window has scrollbars, the column is adjusted
139 * to take that into account, but the row is not. This allows
140 * for large scrollback in terminal windows.
141 *
142 * ROW must be able to accept CUR_ROW, TOP_EDGE, BOTTOM_EDGE,
143 * or a row number.
144 *
145 * COLUMN must be able to accept CUR_COL, LEFT_EDGE, RIGHT_EDGE,
146 * or a column number.
147 */
148 int beAbsoluteCursor(int row, int col);
149
150
151 /* beOffsetCursor -
152 *
153 * Given an input row and column offset, move the cursor by that
154 * many positions. For instance, row=0 and column=-1 would move
155 * the cursor left a single column.
156 *
157 * If the cursor can't move the requested amount, results are
158 * unpredictable.
159 */
160 int beOffsetCursor(int row, int column);
161
162
163 /* beRestoreCursor -
164 *
165 * Saved cursor position should be stored in a static
166 * variable in the back end. This function restores the
167 * cursor to the position stored in that variable.
168 */
169 int beRestoreCursor(void);
170
171
172 /* beSaveCursor -
173 *
174 * The back-end should maintain a static variable with the
175 * last STORED cursor position in it. This function replaces
176 * the contents of that variable with the current cursor position.
177 * The cursor may be restored to this position by using the
178 * beRestoreCursor function.
179 */
180 int beSaveCursor(void);
181
182
183 /* beGetTextAttributes -
184 *
185 * given a pointer to 'fore'ground and 'back'ground ints,
186 * fill them with a device-independant description of the
187 * current foreground and background colors, as well as any
188 * font information in the foreground variable.
189 */
190 int beGetTextAttributes(int *fore, int *back);
191
192
193 /* beSetTextAttributes -
194 *
195 * Given a foreground and a background device independant (SC) color and font
196 * specification, apply these to the display, and save the state in the
197 * static screen variables.
198 *
199 * Note that many font-specific constants (bold/underline/reverse, G0/G1/ASCII)
200 * are stored ONLY in the foreground specification.
201 */
202 int beSetTextAttributes(int fore, int back);
203
204
205 /* beRawTextOut-
206 *
207 * The name of this function is misleading. Given a pointer to
208 * ascii text and a count of bytes to print, print them to the
209 * display device. If wrapping is enabled, wrap text. If there is a
210 * scrolling region set and the cursor is in it,
211 * scroll only within that region. 'beRawTextOut' means that it's guaranteed
212 * not to have control sequences within the text.
213 */
214 int beRawTextOut(char *text, int len);
215
216
217 /* beEraseText -
218 *
219 * Given a 'from' and a 'to' position in display coordinates,
220 * this function will fill in all characters between the two
221 * (inclusive) with spaces. Note that the coordinates do NOT
222 * specify a rectangle. erasing from (1,1) to (2,2) erases
223 * all of the first row, and the first two characters of the
224 * second.
225 *
226 * Note that this routine must be able to handle TOP_EDGE,
227 * BOTTOM_EDGE, LEFT_EDGE, RIGHT_EDGE, CUR_ROW, and CUR_COL
228 * in the appropriate parameters.
229 */
230 int beEraseText(int rowFrom, int colFrom, int rowTo, int colTo);
231
232
233 /* beDeleteText -
234 *
235 * Given a screen cursor 'from' and 'to' position, this function
236 * will delete all text between the two. Text will be scrolled
237 * up as appropriate to fill the deleted space. Note that, as in
238 * beEraseText, the two coordinates don't specify a rectangle, but
239 * rather a starting position and ending position. In other words,
240 * deleting from (1,1) to (2,2) should move the text from (2,3) to the
241 * end of the second row to (1,1), move line 3 up to line 2, and so on.
242 *
243 * This function must be able to process TOP_EDGE, BOTTOM_EDGE, LEFT_EDGE,
244 * RIGHT_EDGE, CUR_ROW, and CUR_COL specifications in the appropriate
245 * variables as well as regular row and column specifications.
246 */
247 int beDeleteText(int rowFrom, int colFrom, int rowTo, int colTo);
248
249
250 /* beInsertRow -
251 *
252 * Given a row number or CUR_ROW, TOP_EDGE or BOTTOM_EDGE as an input,
253 * this function will scroll all text from the current row down down by one,
254 * and create a blank row under the cursor.
255 */
256 int beInsertRow(int row);
257
258
259 /* beTransmitText -
260 *
261 * Given a pointer to text and byte count, this routine should transmit data
262 * to whatever host made the request it's responding to. Typically this routin
263 * should transmit data as though the user had typed it in.
264 */
265 int beTransmitText(char *text, int len);
266
267
268 /* beAdvanceToTab -
269 *
270 * This routine will destructively advance the cursor to the
271 * next set tab, or to the end of the line if there are no
272 * more tabs to the right of the cursor.
273 */
274
275 int beAdvanceToTab(void);
276
277
278 /* beClearTab -
279 *
280 * This function accepts a constant, and will try to clear tabs
281 * appropriately. Its argument is either
282 * ALL_TABS, meaning all tabs should be removed
283 * CUR_COL, meaning the tab in the current column should be wiped, or
284 * a column value, meaning if there's a tab there it should be wiped.
285 *
286 */
287 int beClearTab(int col);
288
289
290 /* beSetScrollingRows -
291 *
292 * Given a pair of row numbers, this routine will set the scrolling
293 * rows to those values. Note that this routine will accept
294 * TOP_ROW and BOTTOM_ROW as values, meaning that scrolling should
295 * be enabled for the entire display, regardless of resizing.
296 */
297 int beSetScrollingRows(int fromRow, int toRow);
298
299
300 /* beRingBell -
301 *
302 * Ring the system bell once.
303 */
304 int beRingBell(void);
305
306
307 /* beGetTermMode -
308 *
309 * Return the value of conTermMode, which is the terminal settings which
310 * can be queried/set by <esc>[?#h/l.
311 */
312 int beGetTermMode();
313
314
315 /* beSetTermMode -
316 *
317 * Set the terminal as requested, assuming we can. Right now we only handle a
318 * couple of the possible flags, but we store many of the others.
319 */
320 int beSetTermMode(int newMode);