Mercurial > emacs
annotate src/systty.h @ 2382:030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
in LCD.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Sat, 27 Mar 1993 01:58:38 +0000 |
parents | 87934d212841 |
children | 9994dd2e75c9 |
rev | line source |
---|---|
1597 | 1 /* systty.h - System-dependent definitions for terminals. |
578 | 2 Copyright (C) 1992 Free Software Foundation, Inc. |
3 | |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 1, or (at your option) | |
9 any later version. | |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
2095
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
20 #ifdef HAVE_TERMIOS |
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
21 #define HAVE_TCATTR |
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
22 #endif |
578 | 23 |
24 /* Include the proper files. */ | |
25 #ifdef HAVE_TERMIO | |
26 #include <termio.h> | |
27 #include <fcntl.h> | |
28 #else | |
29 #ifdef HAVE_TERMIOS | |
30 #include <termio.h> | |
31 #include <termios.h> | |
1929
8ca19160362b
* systty.h [HAVE_TERMIOS]: Include fcntl.h.
Jim Blandy <jimb@redhat.com>
parents:
1597
diff
changeset
|
32 #include <fcntl.h> |
578 | 33 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */ |
34 #ifndef VMS | |
35 #include <sgtty.h> | |
1597 | 36 #else /* VMS */ |
37 #include <descrip.h> | |
38 static struct iosb | |
39 { | |
40 short status; | |
41 short offset; | |
42 short termlen; | |
43 short term; | |
44 } input_iosb; | |
45 | |
46 extern int waiting_for_ast; | |
47 extern int stop_input; | |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2095
diff
changeset
|
48 #if 0 /* VAX C doeasn't understand initializing declarations */ |
1597 | 49 extern int input_ef = 0; |
50 extern int timer_ef = 0; | |
51 extern int process_ef = 0; | |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2095
diff
changeset
|
52 #else |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2095
diff
changeset
|
53 extern int input_ef; |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2095
diff
changeset
|
54 extern int timer_ef; |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2095
diff
changeset
|
55 extern int process_ef; |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2095
diff
changeset
|
56 #endif |
1597 | 57 extern int input_eflist; |
58 extern int timer_eflist; | |
59 | |
60 static $DESCRIPTOR (input_dsc, "TT"); | |
61 static int terminator_mask[2] = { 0, 0 }; | |
62 | |
63 static struct sensemode { | |
64 short status; | |
65 unsigned char xmit_baud; | |
66 unsigned char rcv_baud; | |
67 unsigned char crfill; | |
68 unsigned char lffill; | |
69 unsigned char parity; | |
70 unsigned char unused; | |
71 char class; | |
72 char type; | |
73 short scr_wid; | |
74 unsigned long tt_char : 24, scr_len : 8; | |
75 unsigned long tt2_char; | |
76 } sensemode_iosb; | |
77 #endif /* VMS */ | |
578 | 78 #endif /* not HAVE_TERMIOS */ |
79 #endif /* not HAVE_TERMIO */ | |
80 | |
621 | 81 #ifdef AIX |
82 /* Get files for keyboard remapping */ | |
83 #define HFNKEYS 2 | |
84 #include <sys/hft.h> | |
85 #include <sys/devinfo.h> | |
86 #endif | |
87 | |
88 /* Get rid of LLITOUT in 4.1, since it is said to stimulate kernel bugs. */ | |
89 #ifdef BSD4_1 | |
90 #undef LLITOUT | |
91 #define LLITOUT 0 | |
92 #endif /* 4.1 */ | |
93 | |
94 #ifdef NEED_BSDTTY | |
95 #include <sys/bsdtty.h> | |
96 #endif | |
97 | |
98 #if defined (HPUX) && defined (HAVE_PTYS) | |
99 #include <sys/ptyio.h> | |
100 #endif | |
101 | |
102 #ifdef AIX | |
103 #include <sys/pty.h> | |
104 #include <unistd.h> | |
105 #endif /* AIX */ | |
106 | |
107 #ifdef SYSV_PTYS | |
108 #include <sys/tty.h> | |
648 | 109 #ifdef titan |
110 #include <sys/ttyhw.h> | |
111 #include <sys/stream.h> | |
112 #endif | |
621 | 113 #include <sys/pty.h> |
114 #endif | |
115 | |
116 /* saka@pfu.fujitsu.co.JP writes: | |
117 FASYNC defined in this file. But, FASYNC don't working. | |
118 so no problem, because unrequest_sigio only need. */ | |
119 #if defined (pfa) | |
120 #include <sys/file.h> | |
121 #endif | |
122 | |
578 | 123 |
124 /* Special cases - inhibiting the use of certain features. */ | |
125 | |
126 #ifdef APOLLO | |
127 #undef TIOCSTART | |
128 #endif | |
129 | |
648 | 130 #ifdef XENIX |
131 #undef TIOCGETC /* Avoid confusing some conditionals that test this. */ | |
132 #endif | |
133 | |
578 | 134 #ifdef BROKEN_TIOCGETC |
135 #undef TIOCGETC /* Avoid confusing some conditionals that test this. */ | |
136 #endif | |
137 | |
138 /* UNIPLUS systems may have FIONREAD. */ | |
139 #ifdef UNIPLUS | |
140 #include <sys.ioctl.h> | |
141 #endif | |
142 | |
143 /* Allow m- file to inhibit use of FIONREAD. */ | |
144 #ifdef BROKEN_FIONREAD | |
145 #undef FIONREAD | |
146 #undef ASYNC | |
147 #endif | |
148 | |
149 /* Interupt input is not used if there is no FIONREAD. */ | |
150 #ifndef FIONREAD | |
151 #undef SIGIO | |
152 #endif | |
153 | |
154 | |
1101 | 155 /* Try to establish the correct character to disable terminal functions |
156 in a system-independent manner. Note that USG (at least) define | |
157 _POSIX_VDISABLE as 0! */ | |
158 | |
159 #ifdef _POSIX_VDISABLE | |
160 #define CDISABLE _POSIX_VDISABLE | |
161 #else /* not _POSIX_VDISABLE */ | |
162 #ifdef CDEL | |
163 #define CDISABLE CDEL | |
164 #else /* not CDEL */ | |
165 #define CDISABLE 255 | |
166 #endif /* not CDEL */ | |
167 #endif /* not _POSIX_VDISABLE */ | |
168 | |
578 | 169 /* Get the number of characters queued for output. */ |
170 | |
171 /* EMACS_OUTQSIZE(FD, int *SIZE) stores the number of characters | |
172 queued for output to the terminal FD in *SIZE, if FD is a tty. | |
173 Returns -1 if there was an error (i.e. FD is not a tty), 0 | |
174 otherwise. */ | |
175 #ifdef TIOCOUTQ | |
176 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TIOCOUTQ, (size))) | |
177 #endif | |
178 | |
179 #ifdef HAVE_TERMIO | |
180 #ifdef TCOUTQ | |
181 #undef EMACS_OUTQSIZE | |
182 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TCOUTQ, (size))) | |
183 #endif | |
184 #endif | |
185 | |
186 | |
187 /* Manipulate a terminal's current process group. */ | |
188 | |
189 /* EMACS_HAVE_TTY_PGRP is true if we can get and set the tty's current | |
190 controlling process group. | |
191 | |
192 EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's | |
193 current process group. Return -1 if there is an error. | |
194 | |
195 EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's | |
196 current process group to *PGID. Return -1 if there is an error. */ | |
197 | |
648 | 198 #ifdef HPUX |
199 /* HPUX tty process group stuff doesn't work, says the anonymous voice | |
200 from the past. */ | |
201 #else | |
578 | 202 #ifdef TIOCGPGRP |
203 #define EMACS_HAVE_TTY_PGRP | |
204 #else | |
205 #ifdef HAVE_TERMIOS | |
206 #define EMACS_HAVE_TTY_PGRP | |
207 #endif | |
208 #endif | |
648 | 209 #endif |
578 | 210 |
211 #ifdef EMACS_HAVE_TTY_PGRP | |
212 | |
213 #ifdef HAVE_TERMIOS | |
214 | |
215 #define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp ((fd))) | |
216 #define EMACS_SET_TTY_PGRP(fd, pgid) (*(pgid) = tcsetpgrp ((fd))) | |
217 | |
218 #else | |
219 #ifdef TIOCSPGRP | |
220 | |
221 #define EMACS_GET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCGPGRP, (pgid))) | |
222 #define EMACS_SET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCSPGRP, (pgid))) | |
223 | |
224 #endif | |
225 #endif | |
226 | |
227 #else | |
228 | |
229 /* Just ignore this for now and hope for the best */ | |
230 #define EMACS_GET_TTY_PGRP(fd, pgid) 0 | |
999 | 231 #define EMACS_SET_TTY_PGRP(fd, pgif) 0 |
578 | 232 |
233 #endif | |
234 | |
235 | |
236 /* Manipulate a TTY's input/output processing parameters. */ | |
237 | |
238 /* struct emacs_tty is a structure used to hold the current tty | |
239 parameters. If the terminal has several structures describing its | |
240 state, for example a struct tchars, a struct sgttyb, a struct | |
241 tchars, a struct ltchars, and a struct pagechars, struct | |
242 emacs_tty should contain an element for each parameter struct | |
243 that Emacs may change. | |
244 | |
245 EMACS_GET_TTY (int FD, struct emacs_tty *P) stores the | |
246 parameters of the tty on FD in *P. | |
247 | |
248 EMACS_SET_TTY (int FD, struct emacs_tty *P, int waitp) | |
249 sets the parameters of the tty on FD according to the contents of | |
250 *P. If waitp is non-zero, we wait for all queued output to be | |
251 written before making the change; otherwise, we forget any queued | |
252 input and make the change immediately. | |
253 | |
254 EMACS_TTY_TABS_OK (struct emacs_tty *P) is false iff the kernel | |
255 expands tabs to spaces upon output; in that case, there is no | |
256 advantage to using tabs over spaces. */ | |
257 | |
258 | |
259 /* For each tty parameter structure that Emacs might want to save and restore, | |
260 - include an element for it in this structure, | |
261 - define a pair of numbered macros to get and set it and return | |
262 true iff the call succeeded, | |
263 - give alternative definitions for when the component is not implemented | |
264 which always succeed, and | |
265 - extend the definition of EMACS_{GET,SET}_TTY_CHARS to include the | |
266 new macros. */ | |
267 | |
268 struct emacs_tty { | |
269 | |
270 /* There is always one of the following elements, so there is no need | |
271 for dummy get and set definitions. */ | |
2095
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
272 #ifdef HAVE_TCATTR |
578 | 273 struct termios main; |
274 #else | |
275 #ifdef HAVE_TERMIO | |
276 struct termio main; | |
277 #else | |
278 #ifdef VMS | |
279 struct sensemode main; | |
280 #else | |
281 struct sgttyb main; | |
282 #endif | |
283 #endif | |
284 #endif | |
2095
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
285 #ifdef TIOCGLTC |
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
286 struct ltchars ltchars; |
578 | 287 #endif |
2095
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
288 #ifdef TIOCGETC |
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
289 struct tchars tchars; |
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
290 int lmode; |
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
291 #endif |
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
292 }; |
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
293 |
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
294 /* Define EMACS_GET_TTY and EMACS_SET_TTY, |
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
295 the macros for reading and setting parts of `struct emacs_tty'. */ |
578 | 296 |
297 #ifdef HAVE_TCATTR | |
298 | |
299 #define EMACS_GET_TTY_1(fd, p) (tcgetattr ((fd), &(p)->main) != -1) | |
300 #define EMACS_SET_TTY_1(fd, p, waitp) \ | |
301 (tcsetattr ((fd), (waitp) ? TCSAFLUSH : TCSADRAIN, &(p)->main) != -1) | |
302 | |
303 #else | |
621 | 304 #ifdef HAVE_TERMIO |
305 | |
306 #define EMACS_GET_TTY_1(fd, p) (ioctl ((fd), TCGETA, &(p)->main) != -1) | |
307 #define EMACS_SET_TTY_1(fd, p, waitp) \ | |
308 (ioctl ((fd), (waitp) ? TCSETAW : TCSETAF, &(p)->main) != -1) | |
309 | |
310 #else | |
578 | 311 #ifdef VMS |
312 | |
313 /* These definitions will really only work in sysdep.c, because of their | |
314 use of input_iosb. I don't know enough about VMS QIO to fix this. */ | |
1597 | 315 #define EMACS_GET_TTY_1(fd, p) \ |
316 (1 & SYS$QIOW (0, (fd), IO$_SENSEMODE, (p), 0, 0, \ | |
317 &(p)->main.class, 12, 0, 0, 0, 0)) | |
318 #define EMACS_SET_TTY_1(fd, p, waitp) \ | |
319 (1 & SYS$QIOW (0, (fd), IO$_SETMODE, &input_iosb, 0, 0, \ | |
320 &(p)->main.class, 12, 0, 0, 0, 0)) | |
578 | 321 |
322 #else | |
323 | |
324 #define EMACS_GET_TTY_1(fd, p) (ioctl ((fd), TIOCGETP, &(p)->main) != -1) | |
325 #define EMACS_SET_TTY_1(fd, p, waitp) \ | |
326 (ioctl ((fd), (waitp) ? TIOCSETP : TIOCSETN, &(p)->main) != -1) | |
327 | |
328 #endif | |
329 #endif | |
621 | 330 #endif |
578 | 331 |
332 #ifdef TIOCGLTC | |
333 #define EMACS_GET_TTY_2(fd, p) \ | |
334 (ioctl ((fd), TIOCGLTC, &(p)->ltchars) != -1) | |
335 #define EMACS_SET_TTY_2(fd, p, waitp) \ | |
336 (ioctl ((fd), TIOCSLTC, &(p)->ltchars) != -1) | |
337 #else | |
338 #define EMACS_GET_TTY_2(fd, p) 1 | |
339 #define EMACS_SET_TTY_2(fd, p, waitp) 1 | |
340 #endif /* TIOCGLTC */ | |
341 | |
342 #ifdef TIOCGETC | |
343 #define EMACS_GET_TTY_3(fd, p) \ | |
344 (ioctl ((fd), TIOCGETC, &(p)->tchars) != -1 \ | |
345 && ioctl ((fd), TIOCLGET, &(p)->lmode) != -1) | |
346 #define EMACS_SET_TTY_3(fd, p, waitp) \ | |
347 (ioctl ((fd), TIOCSETC, &(p)->tchars) != -1 \ | |
348 && ioctl ((fd), TIOCLSET, &(p)->lmode) != -1) | |
349 #else | |
350 #define EMACS_GET_TTY_3(fd, p) 1 | |
351 #define EMACS_SET_TTY_3(fd, p, waitp) 1 | |
352 #endif /* TIOCGLTC */ | |
353 | |
1039 | 354 /* Define these to be a concatenation of all the EMACS_{GET,SET}_TTY_n |
578 | 355 macros. */ |
356 #define EMACS_GET_TTY(fd, tc) \ | |
357 (EMACS_GET_TTY_1 (fd, tc) \ | |
358 && EMACS_GET_TTY_2 (fd, tc) \ | |
359 && EMACS_GET_TTY_3 (fd, tc)) | |
360 | |
361 #define EMACS_SET_TTY(fd, tc, waitp) \ | |
362 (EMACS_SET_TTY_1 (fd, tc, waitp) \ | |
363 && EMACS_SET_TTY_2 (fd, tc, waitp) \ | |
364 && EMACS_SET_TTY_3 (fd, tc, waitp)) | |
2095
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
365 |
139f87bcbaf1
Define HAVE_TCATTR based on HAVE_TERMIOS earlier.
Richard M. Stallman <rms@gnu.org>
parents:
1929
diff
changeset
|
366 /* Define EMACS_TTY_TABS_OK. */ |
578 | 367 |
368 #ifdef HAVE_TERMIOS | |
369 | |
370 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3) | |
371 | |
372 #else /* not def HAVE_TERMIOS */ | |
373 #ifdef HAVE_TERMIO | |
374 | |
375 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3) | |
376 | |
377 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */ | |
378 #ifdef VMS | |
379 | |
380 #define EMACS_TTY_TABS_OK(p) (((p)->main.tt_char & TT$M_MECHTAB) != 0) | |
381 | |
382 #else | |
383 | |
384 #define EMACS_TTY_TABS_OK(p) (((p)->main.sg_flags & XTABS) != XTABS) | |
385 | |
386 #endif /* not def VMS */ | |
387 #endif /* not def HAVE_TERMIO */ | |
388 #endif /* not def HAVE_TERMIOS */ |