Mercurial > emacs
comparison src/systty.h @ 578:a4591b4d5435
Initial revision
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sat, 14 Mar 1992 20:40:04 +0000 |
parents | |
children | eca8812e61cd |
comparison
equal
deleted
inserted
replaced
577:53f29271d1b0 | 578:a4591b4d5435 |
---|---|
1 /* systerm.h - System-dependent definitions for terminals. | |
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 | |
20 | |
21 /* Include the proper files. */ | |
22 #ifdef HAVE_TERMIO | |
23 #include <termio.h> | |
24 #include <fcntl.h> | |
25 #else | |
26 #ifdef HAVE_TERMIOS | |
27 #include <termio.h> | |
28 #include <termios.h> | |
29 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */ | |
30 #ifndef VMS | |
31 #include <sgtty.h> | |
32 #endif /* not VMS */ | |
33 #endif /* not HAVE_TERMIOS */ | |
34 #endif /* not HAVE_TERMIO */ | |
35 | |
36 | |
37 /* Special cases - inhibiting the use of certain features. */ | |
38 | |
39 #ifdef APOLLO | |
40 #undef TIOCSTART | |
41 #endif | |
42 | |
43 #ifdef BROKEN_TIOCGETC | |
44 #undef TIOCGETC /* Avoid confusing some conditionals that test this. */ | |
45 #endif | |
46 | |
47 /* UNIPLUS systems may have FIONREAD. */ | |
48 #ifdef UNIPLUS | |
49 #include <sys.ioctl.h> | |
50 #endif | |
51 | |
52 /* Allow m- file to inhibit use of FIONREAD. */ | |
53 #ifdef BROKEN_FIONREAD | |
54 #undef FIONREAD | |
55 #undef ASYNC | |
56 #endif | |
57 | |
58 /* Interupt input is not used if there is no FIONREAD. */ | |
59 #ifndef FIONREAD | |
60 #undef SIGIO | |
61 #endif | |
62 | |
63 | |
64 /* Get the number of characters queued for output. */ | |
65 | |
66 /* EMACS_OUTQSIZE(FD, int *SIZE) stores the number of characters | |
67 queued for output to the terminal FD in *SIZE, if FD is a tty. | |
68 Returns -1 if there was an error (i.e. FD is not a tty), 0 | |
69 otherwise. */ | |
70 #ifdef TIOCOUTQ | |
71 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TIOCOUTQ, (size))) | |
72 #endif | |
73 | |
74 #ifdef HAVE_TERMIO | |
75 #ifdef TCOUTQ | |
76 #undef EMACS_OUTQSIZE | |
77 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TCOUTQ, (size))) | |
78 #endif | |
79 #endif | |
80 | |
81 | |
82 /* Manipulate a terminal's current process group. */ | |
83 | |
84 /* EMACS_HAVE_TTY_PGRP is true if we can get and set the tty's current | |
85 controlling process group. | |
86 | |
87 EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's | |
88 current process group. Return -1 if there is an error. | |
89 | |
90 EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's | |
91 current process group to *PGID. Return -1 if there is an error. */ | |
92 | |
93 #ifdef TIOCGPGRP | |
94 #define EMACS_HAVE_TTY_PGRP | |
95 #else | |
96 #ifdef HAVE_TERMIOS | |
97 #define EMACS_HAVE_TTY_PGRP | |
98 #endif | |
99 #endif | |
100 | |
101 #ifdef EMACS_HAVE_TTY_PGRP | |
102 | |
103 #ifdef HAVE_TERMIOS | |
104 | |
105 #define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp ((fd))) | |
106 #define EMACS_SET_TTY_PGRP(fd, pgid) (*(pgid) = tcsetpgrp ((fd))) | |
107 | |
108 #else | |
109 #ifdef TIOCSPGRP | |
110 | |
111 #define EMACS_GET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCGPGRP, (pgid))) | |
112 #define EMACS_SET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCSPGRP, (pgid))) | |
113 | |
114 #endif | |
115 #endif | |
116 | |
117 #else | |
118 | |
119 /* Just ignore this for now and hope for the best */ | |
120 #define EMACS_GET_TTY_PGRP(fd, pgid) 0 | |
121 | |
122 #endif | |
123 | |
124 | |
125 /* Manipulate a TTY's input/output processing parameters. */ | |
126 | |
127 /* struct emacs_tty is a structure used to hold the current tty | |
128 parameters. If the terminal has several structures describing its | |
129 state, for example a struct tchars, a struct sgttyb, a struct | |
130 tchars, a struct ltchars, and a struct pagechars, struct | |
131 emacs_tty should contain an element for each parameter struct | |
132 that Emacs may change. | |
133 | |
134 EMACS_GET_TTY (int FD, struct emacs_tty *P) stores the | |
135 parameters of the tty on FD in *P. | |
136 | |
137 EMACS_SET_TTY (int FD, struct emacs_tty *P, int waitp) | |
138 sets the parameters of the tty on FD according to the contents of | |
139 *P. If waitp is non-zero, we wait for all queued output to be | |
140 written before making the change; otherwise, we forget any queued | |
141 input and make the change immediately. | |
142 | |
143 EMACS_TTY_TABS_OK (struct emacs_tty *P) is false iff the kernel | |
144 expands tabs to spaces upon output; in that case, there is no | |
145 advantage to using tabs over spaces. */ | |
146 | |
147 | |
148 | |
149 /* For each tty parameter structure that Emacs might want to save and restore, | |
150 - include an element for it in this structure, | |
151 - define a pair of numbered macros to get and set it and return | |
152 true iff the call succeeded, | |
153 - give alternative definitions for when the component is not implemented | |
154 which always succeed, and | |
155 - extend the definition of EMACS_{GET,SET}_TTY_CHARS to include the | |
156 new macros. */ | |
157 | |
158 struct emacs_tty { | |
159 | |
160 /* There is always one of the following elements, so there is no need | |
161 for dummy get and set definitions. */ | |
162 #ifdef HAVE_TERMIOS | |
163 struct termios main; | |
164 #else | |
165 #ifdef HAVE_TERMIO | |
166 struct termio main; | |
167 #else | |
168 #ifdef VMS | |
169 struct sensemode main; | |
170 #else | |
171 struct sgttyb main; | |
172 #endif | |
173 #endif | |
174 #endif | |
175 | |
176 #ifdef HAVE_TERMIOS | |
177 #define HAVE_TCATTR | |
178 #endif | |
179 | |
180 #ifdef HAVE_TCATTR | |
181 | |
182 #define EMACS_GET_TTY_1(fd, p) (tcgetattr ((fd), &(p)->main) != -1) | |
183 #define EMACS_SET_TTY_1(fd, p, waitp) \ | |
184 (tcsetattr ((fd), (waitp) ? TCSAFLUSH : TCSADRAIN, &(p)->main) != -1) | |
185 | |
186 #else | |
187 #ifdef VMS | |
188 | |
189 /* These definitions will really only work in sysdep.c, because of their | |
190 use of input_iosb. I don't know enough about VMS QIO to fix this. */ | |
191 #define EMACS_GET_TTY_1(fd, p) \ | |
192 SYS$QIOW (0, (fd), IO$_SENSEMODE, (p), 0, 0, \ | |
193 &(p)->main.class, 12, 0, 0, 0, 0); | |
194 #define EMACS_SET_TTY_1(fd, p, waitp) \ | |
195 SYS$QIOW (0, (fd), IO$_SETMODE, &input_iosb, 0, 0, \ | |
196 &(p)->main.class, 12, 0, 0, 0, 0); | |
197 | |
198 #else | |
199 | |
200 #define EMACS_GET_TTY_1(fd, p) (ioctl ((fd), TIOCGETP, &(p)->main) != -1) | |
201 #define EMACS_SET_TTY_1(fd, p, waitp) \ | |
202 (ioctl ((fd), (waitp) ? TIOCSETP : TIOCSETN, &(p)->main) != -1) | |
203 | |
204 #endif | |
205 #endif | |
206 | |
207 #ifdef TIOCGLTC | |
208 struct ltchars ltchars; | |
209 #define EMACS_GET_TTY_2(fd, p) \ | |
210 (ioctl ((fd), TIOCGLTC, &(p)->ltchars) != -1) | |
211 #define EMACS_SET_TTY_2(fd, p, waitp) \ | |
212 (ioctl ((fd), TIOCSLTC, &(p)->ltchars) != -1) | |
213 #else | |
214 #define EMACS_GET_TTY_2(fd, p) 1 | |
215 #define EMACS_SET_TTY_2(fd, p, waitp) 1 | |
216 #endif /* TIOCGLTC */ | |
217 | |
218 #ifdef TIOCGETC | |
219 struct tchars tchars; | |
220 int lmode; | |
221 #define EMACS_GET_TTY_3(fd, p) \ | |
222 (ioctl ((fd), TIOCGETC, &(p)->tchars) != -1 \ | |
223 && ioctl ((fd), TIOCLGET, &(p)->lmode) != -1) | |
224 #define EMACS_SET_TTY_3(fd, p, waitp) \ | |
225 (ioctl ((fd), TIOCSETC, &(p)->tchars) != -1 \ | |
226 && ioctl ((fd), TIOCLSET, &(p)->lmode) != -1) | |
227 #else | |
228 #define EMACS_GET_TTY_3(fd, p) 1 | |
229 #define EMACS_SET_TTY_3(fd, p, waitp) 1 | |
230 #endif /* TIOCGLTC */ | |
231 | |
232 }; | |
233 | |
234 /* Define these to be a concatenation of all the EMACS_{GET,SET}_TTY | |
235 macros. */ | |
236 #define EMACS_GET_TTY(fd, tc) \ | |
237 (EMACS_GET_TTY_1 (fd, tc) \ | |
238 && EMACS_GET_TTY_2 (fd, tc) \ | |
239 && EMACS_GET_TTY_3 (fd, tc)) | |
240 | |
241 #define EMACS_SET_TTY(fd, tc, waitp) \ | |
242 (EMACS_SET_TTY_1 (fd, tc, waitp) \ | |
243 && EMACS_SET_TTY_2 (fd, tc, waitp) \ | |
244 && EMACS_SET_TTY_3 (fd, tc, waitp)) | |
245 | |
246 | |
247 #ifdef HAVE_TERMIOS | |
248 | |
249 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3) | |
250 | |
251 #else /* not def HAVE_TERMIOS */ | |
252 #ifdef HAVE_TERMIO | |
253 | |
254 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3) | |
255 | |
256 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */ | |
257 #ifdef VMS | |
258 | |
259 #define EMACS_TTY_TABS_OK(p) (((p)->main.tt_char & TT$M_MECHTAB) != 0) | |
260 | |
261 #else | |
262 | |
263 #define EMACS_TTY_TABS_OK(p) (((p)->main.sg_flags & XTABS) != XTABS) | |
264 | |
265 #endif /* not def VMS */ | |
266 #endif /* not def HAVE_TERMIO */ | |
267 #endif /* not def HAVE_TERMIOS */ |