comparison src/console-tty.h @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 0293115a14e9
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
1 /* Define TTY specific console, device, and frame object for XEmacs.
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
3 Copyright (C) 1996 Ben Wing.
4
5 This file is part of XEmacs.
6
7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
10 later version.
11
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 /* Synched up with: Not in FSF. */
23
24 /* Written by Chuck Thompson and Ben Wing. */
25
26 /* NOTE: Currently each TTY console can have only one device.
27 Therefore, all stuff for both input and output is lumped into
28 the console structure. If it ever becomes meaningful to
29 have more than one device on a TTY console, the output stuff
30 will have to get separated out. */
31
32 #ifndef _XEMACS_CONSOLE_TTY_H_
33 #define _XEMACS_CONSOLE_TTY_H_
34
35 #include "console.h"
36 #include "syssignal.h" /* Always include before systty.h */
37 #include "systty.h"
38
39 DECLARE_CONSOLE_TYPE (tty);
40
41 struct tty_console
42 {
43 int infd, outfd;
44 Lisp_Object instream, outstream;
45 Lisp_Object terminal_type;
46 char *term_entry_buffer;
47
48 /* Physical location of cursor on this console. */
49 int cursor_x;
50 int cursor_y;
51
52 /* The real location of the cursor. The above physical location may
53 be ahead of where we really are. */
54 int real_cursor_x;
55 int real_cursor_y;
56
57 int height;
58 int width;
59
60 /* flags indicating presence, absence or value of various features */
61 struct
62 {
63 unsigned int must_write_spaces :1;/* terminal inserts nulls, not
64 spaces to fill whitespace
65 on screen */
66 unsigned int insert_mode_motion :1;/* cursor movement commands
67 work while in insert mode */
68 unsigned int standout_motion :1; /* cursor movement is graceful
69 in standout or underline mode */
70 unsigned int memory_above_frame :1;/* display retained above screen */
71 unsigned int memory_below_frame :1;/* display retained below screen */
72 unsigned int meta_key :2; /* 0 == mask off top bit;
73 1 == top bit is meta;
74 2 == top bit is useful as
75 character info */
76 unsigned int flow_control :1; /* Nonzero means use ^S/^Q as
77 cretinous flow control. */
78 int standout_width; /* # of spaces printed when
79 change to standout mode */
80 int underline_width; /* # of spaces printed when
81 change to underline mode */
82 } flags;
83
84 /* cursor motion entries - each entry is commented with the terminfo
85 and the termcap entry */
86 struct
87 {
88 /* local cursor movement */
89 CONST char *up; /* cuu1, up */
90 CONST char *down; /* cud1, do */
91 CONST char *left; /* cub1, le */
92 CONST char *right; /* cuf1, nd */
93 CONST char *home; /* home, ho */
94 CONST char *low_left; /* ll, ll */
95 CONST char *car_return; /* cr, cr */
96
97 /* parameterized local cursor movement */
98 CONST char *multi_up; /* cuu, UP */
99 CONST char *multi_down; /* cud, DO */
100 CONST char *multi_left; /* cub, LE */
101 CONST char *multi_right; /* cuf, RI */
102
103 /* absolute cursor motion */
104 CONST char *abs; /* cup, cm */
105 CONST char *hor_abs; /* hpa, ch */
106 CONST char *ver_abs; /* vpa, cv */
107
108 /* scrolling */
109 CONST char *scroll_forw; /* ind, sf */
110 CONST char *scroll_back; /* ri, sr */
111 CONST char *multi_scroll_forw; /* indn, SF */
112 CONST char *multi_scroll_back; /* rin, SR */
113 CONST char *set_scroll_region; /* csr, cs */
114 } cm;
115
116 /* screen editing entries - each entry is commented with the
117 terminfo and the termcap entry */
118 struct
119 {
120 /* adding to the screen */
121 CONST char *ins_line; /* il1, al */
122 CONST char *multi_ins_line; /* il, AL */
123 CONST char *repeat; /* rep, rp */
124 CONST char *begin_ins_mode; /* smir, im */
125 CONST char *end_ins_mode; /* rmir, ei */
126 CONST char *ins_char; /* ich1, ic */
127 CONST char *multi_ins_char; /* ich, IC */
128 CONST char *insert_pad; /* ip, ip */
129
130 /* deleting from the screen */
131 CONST char *clr_frame; /* clear, cl */
132 CONST char *clr_from_cursor; /* ed, cd */
133 CONST char *clr_to_eol; /* el, ce */
134 CONST char *del_line; /* dl1, dl */
135 CONST char *multi_del_line; /* dl, DL */
136 CONST char *del_char; /* dch1, dc */
137 CONST char *multi_del_char; /* dch, DC */
138 CONST char *begin_del_mode; /* smdc, dm */
139 CONST char *end_del_mode; /* rmdc, ed */
140 CONST char *erase_at_cursor; /* ech, ec */
141 } se;
142
143 /* screen display entries - each entry is commented with the
144 terminfo and termcap entry */
145 struct
146 {
147 CONST char *begin_standout; /* smso, so */
148 CONST char *end_standout; /* rmso, se */
149 CONST char *begin_underline; /* smul, us */
150 CONST char *end_underline; /* rmul, ue */
151 CONST char *begin_alternate; /* smacs, as */
152 CONST char *end_alternate; /* rmacs, ae */
153
154 CONST char *turn_on_reverse; /* rev, mr */
155 CONST char *turn_on_blinking; /* blink, mb */
156 CONST char *turn_on_bold; /* bold, md */
157 CONST char *turn_on_dim; /* dim, mh */
158 CONST char *turn_off_attributes; /* sgr0, me */
159
160 CONST char *visual_bell; /* flash, vb */
161 CONST char *audio_bell; /* bel, bl */
162
163 CONST char *cursor_visible; /* cvvis, vs */
164 CONST char *cursor_normal; /* cnorm, ve */
165 CONST char *init_motion; /* smcup, ti */
166 CONST char *end_motion; /* rmcup, te */
167 CONST char *keypad_on; /* smkx, ks */
168 CONST char *keypad_off; /* rmkx, ke */
169 } sd;
170
171 /* costs of various operations */
172 struct
173 {
174 int cm_up;
175 int cm_down;
176 int cm_left;
177 int cm_right;
178 int cm_home;
179 int cm_low_left;
180 int cm_car_return;
181 int cm_abs;
182 int cm_hor_abs;
183 int cm_ver_abs;
184 } cost;
185
186 /* The initial tty mode bits */
187 struct emacs_tty old_tty;
188
189 /* Is this TTY our controlling terminal? */
190 int controlling_terminal :1;
191 int is_stdio :1;
192 };
193
194 #define CONSOLE_TTY_DATA(c) CONSOLE_TYPE_DATA (c, tty)
195 #define CONSOLE_TTY_CURSOR_X(c) (CONSOLE_TTY_DATA (c)->cursor_x)
196 #define CONSOLE_TTY_CURSOR_Y(c) (CONSOLE_TTY_DATA (c)->cursor_y)
197 #define CONSOLE_TTY_REAL_CURSOR_X(c) (CONSOLE_TTY_DATA (c)->real_cursor_x)
198 #define CONSOLE_TTY_REAL_CURSOR_Y(c) (CONSOLE_TTY_DATA (c)->real_cursor_y)
199
200 #define TTY_CM(c) (CONSOLE_TTY_DATA (c)->cm)
201 #define TTY_SE(c) (CONSOLE_TTY_DATA (c)->se)
202 #define TTY_SD(c) (CONSOLE_TTY_DATA (c)->sd)
203 #define TTY_FLAGS(c) (CONSOLE_TTY_DATA (c)->flags)
204 #define TTY_COST(c) (CONSOLE_TTY_DATA (c)->cost)
205
206 #define TTY_INC_CURSOR_X(c, n) \
207 do \
208 { \
209 int __tempn__ = (n); \
210 assert (CONSOLE_TTY_CURSOR_X (c) == CONSOLE_TTY_REAL_CURSOR_X (c)); \
211 CONSOLE_TTY_CURSOR_X (c) += __tempn__; \
212 CONSOLE_TTY_REAL_CURSOR_X (c) += __tempn__; \
213 } while (0)
214
215 #define TTY_INC_CURSOR_Y(c, n) \
216 do \
217 { \
218 int __tempn__ = (n); \
219 CONSOLE_TTY_CURSOR_Y (c) += __tempn__; \
220 CONSOLE_TTY_REAL_CURSOR_Y (c) += __tempn__; \
221 } while (0)
222
223 struct tty_device
224 {
225 #ifdef HAVE_TERMIOS
226 speed_t ospeed; /* Output speed (from sg_ospeed) */
227 #else
228 short ospeed; /* Output speed (from sg_ospeed) */
229 #endif
230 };
231
232 #define DEVICE_TTY_DATA(d) DEVICE_TYPE_DATA (d, tty)
233
234 /* termcap requires this to be global */
235 #ifndef HAVE_TERMIOS
236 extern short ospeed; /* Output speed (from sg_ospeed) */
237 #endif
238
239 extern FILE *termscript;
240
241
242 /****************** Prototypes from cm.c *******************/
243
244 /* #### Verify that all of these are still needed. */
245
246 extern void cm_cost_init (struct console *c);
247 extern void cmputc (int c);
248 extern void cmgoto (struct frame *f, int row, int col);
249 extern struct console *cmputc_console;
250 void send_string_to_tty_console (struct console *c, unsigned char *str,
251 int len);
252
253
254 /*************** Prototypes from event-tty.c ****************/
255
256 extern void init_event_tty_late (void);
257
258
259
260 /*************** Prototypes from redisplay-tty.c ****************/
261
262 enum term_init_status
263 {
264 TTY_UNABLE_OPEN_DATABASE,
265 TTY_TYPE_UNDEFINED,
266 TTY_TYPE_INSUFFICIENT,
267 TTY_SIZE_UNSPECIFIED,
268 TTY_INIT_SUCCESS
269 };
270
271 extern int init_tty_for_redisplay (struct device *d, char *terminal_type);
272 /* #### These should probably be methods. */
273 void set_tty_modes (struct console *c);
274 void reset_tty_modes (struct console *c);
275
276 /* Used in sysdep.c to properly clear and position the cursor when exiting. */
277 extern void tty_redisplay_shutdown (struct console *c);
278
279 /* called from console-stream.c */
280 Lisp_Object tty_semi_canonicalize_console_connection (Lisp_Object connection,
281 Error_behavior errb);
282 Lisp_Object tty_canonicalize_console_connection (Lisp_Object connection,
283 Error_behavior errb);
284 Lisp_Object tty_semi_canonicalize_device_connection (Lisp_Object connection,
285 Error_behavior errb);
286 Lisp_Object tty_canonicalize_device_connection (Lisp_Object connection,
287 Error_behavior errb);
288
289 #endif /* _XEMACS_CONSOLE_TTY_H_ */