3 * AUTHOR: John L. Miller, johnmil@cs.cmu.edu / johnmil@jprc.com
6 * Copyright (c) 1996 John L. Miller
8 * Full permission is granted to use, modify and distribute
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.
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.
21 /* This identifier should be spit back to the computer when a terminal
24 #define ANSWERBACK_MESSAGE "vt100"
26 /* Various terminal-related modes Entries are as follows:
27 * Identification esc. ID If set, if clear
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
40 #define NUM_TERM_ATTR_MODES 9 /* We only track eight '?' escape sequences */
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
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)
69 /* This constant is VERY important - the size of the buffer for
70 * unprocessed vt-100 prints!
72 #define MAXVTBUFLEN 4096
74 /* Constants used in place of actual row and column numbers
75 * for the cursor movement and text erasing and deleting functions.
79 #define ALL_TABS -1999
82 #define RIGHT_EDGE 12000
84 #define BOTTOM_EDGE 12000
86 /* Text attribute definitions; color, font, bold. */
87 #define NUM_SC_ATTRIBUTES 11
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 */
102 /* forward variable declarations */
104 extern int termAttrMode
[NUM_TERM_ATTR_MODES
];
105 extern int alltermAttrModes
;
108 /* prototypes from vt100.c */
110 /* functions meant for use outside of the emulator */
113 int vtprintf(char *format
, ...);
114 int vtInitVT100(void);
115 int vtProcessedTextOut(char *cbuf
, int count
);
118 /* Prototype for functions which MUST BE SUPPLIED BY THE BACK END!!! */
120 /* Back-end specific initialization is performed in this function.
121 * this is gauranteed to be called before any other requests are made
125 /* beInitVT100Terminal() -
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.
131 int beInitVT100Terminal();
134 /* beAbsoluteCursor -
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.
142 * ROW must be able to accept CUR_ROW, TOP_EDGE, BOTTOM_EDGE,
145 * COLUMN must be able to accept CUR_COL, LEFT_EDGE, RIGHT_EDGE,
146 * or a column number.
148 int beAbsoluteCursor(int row
, int col
);
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.
157 * If the cursor can't move the requested amount, results are
160 int beOffsetCursor(int row
, int column
);
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.
169 int beRestoreCursor(void);
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.
180 int beSaveCursor(void);
183 /* beGetTextAttributes -
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.
190 int beGetTextAttributes(int *fore
, int *back
);
193 /* beSetTextAttributes -
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.
199 * Note that many font-specific constants (bold/underline/reverse, G0/G1/ASCII)
200 * are stored ONLY in the foreground specification.
202 int beSetTextAttributes(int fore
, int back
);
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.
214 int beRawTextOut(char *text
, int len
);
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
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.
230 int beEraseText(int rowFrom
, int colFrom
, int rowTo
, int colTo
);
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.
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.
247 int beDeleteText(int rowFrom
, int colFrom
, int rowTo
, int colTo
);
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.
256 int beInsertRow(int row
);
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.
265 int beTransmitText(char *text
, int len
);
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.
275 int beAdvanceToTab(void);
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.
287 int beClearTab(int col
);
290 /* beSetScrollingRows -
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.
297 int beSetScrollingRows(int fromRow
, int toRow
);
302 * Ring the system bell once.
304 int beRingBell(void);
309 * Return the value of conTermMode, which is the terminal settings which
310 * can be queried/set by <esc>[?#h/l.
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.
320 int beSetTermMode(int newMode
);