1 /* systerm.h - System-dependent definitions for terminals.
2 Copyright (C) 1992 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
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)
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.
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. */
21 /* Include the proper files. */
29 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
33 #endif /* not HAVE_TERMIOS */
34 #endif /* not HAVE_TERMIO */
37 /* Get files for keyboard remapping */
40 #include <sys/devinfo.h>
43 /* Get rid of LLITOUT in 4.1, since it is said to stimulate kernel bugs. */
50 #include <sys/bsdtty.h>
53 #if defined (HPUX) && defined (HAVE_PTYS)
54 #include <sys/ptyio.h>
65 #include <sys/ttyhw.h>
66 #include <sys/stream.h>
71 /* saka@pfu.fujitsu.co.JP writes:
72 FASYNC defined in this file. But, FASYNC don't working.
73 so no problem, because unrequest_sigio only need. */
79 /* Special cases - inhibiting the use of certain features. */
86 #undef TIOCGETC /* Avoid confusing some conditionals that test this. */
89 #ifdef BROKEN_TIOCGETC
90 #undef TIOCGETC /* Avoid confusing some conditionals that test this. */
93 /* UNIPLUS systems may have FIONREAD. */
95 #include <sys.ioctl.h>
98 /* Allow m- file to inhibit use of FIONREAD. */
99 #ifdef BROKEN_FIONREAD
104 /* Interupt input is not used if there is no FIONREAD. */
110 /* Get the number of characters queued for output. */
112 /* EMACS_OUTQSIZE(FD, int *SIZE) stores the number of characters
113 queued for output to the terminal FD in *SIZE, if FD is a tty.
114 Returns -1 if there was an error (i.e. FD is not a tty), 0
117 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TIOCOUTQ, (size)))
122 #undef EMACS_OUTQSIZE
123 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TCOUTQ, (size)))
128 /* Manipulate a terminal's current process group. */
130 /* EMACS_HAVE_TTY_PGRP is true if we can get and set the tty's current
131 controlling process group.
133 EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's
134 current process group. Return -1 if there is an error.
136 EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's
137 current process group to *PGID. Return -1 if there is an error. */
140 /* HPUX tty process group stuff doesn't work, says the anonymous voice
144 #define EMACS_HAVE_TTY_PGRP
147 #define EMACS_HAVE_TTY_PGRP
152 #ifdef EMACS_HAVE_TTY_PGRP
156 #define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp ((fd)))
157 #define EMACS_SET_TTY_PGRP(fd, pgid) (*(pgid) = tcsetpgrp ((fd)))
162 #define EMACS_GET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCGPGRP, (pgid)))
163 #define EMACS_SET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCSPGRP, (pgid)))
170 /* Just ignore this for now and hope for the best */
171 #define EMACS_GET_TTY_PGRP(fd, pgid) 0
176 /* Manipulate a TTY's input/output processing parameters. */
178 /* struct emacs_tty is a structure used to hold the current tty
179 parameters. If the terminal has several structures describing its
180 state, for example a struct tchars, a struct sgttyb, a struct
181 tchars, a struct ltchars, and a struct pagechars, struct
182 emacs_tty should contain an element for each parameter struct
183 that Emacs may change.
185 EMACS_GET_TTY (int FD, struct emacs_tty *P) stores the
186 parameters of the tty on FD in *P.
188 EMACS_SET_TTY (int FD, struct emacs_tty *P, int waitp)
189 sets the parameters of the tty on FD according to the contents of
190 *P. If waitp is non-zero, we wait for all queued output to be
191 written before making the change; otherwise, we forget any queued
192 input and make the change immediately.
194 EMACS_TTY_TABS_OK (struct emacs_tty *P) is false iff the kernel
195 expands tabs to spaces upon output; in that case, there is no
196 advantage to using tabs over spaces. */
200 /* For each tty parameter structure that Emacs might want to save and restore,
201 - include an element for it in this structure,
202 - define a pair of numbered macros to get and set it and return
203 true iff the call succeeded,
204 - give alternative definitions for when the component is not implemented
205 which always succeed, and
206 - extend the definition of EMACS_{GET,SET}_TTY_CHARS to include the
211 /* There is always one of the following elements, so there is no need
212 for dummy get and set definitions. */
220 struct sensemode main
;
233 #define EMACS_GET_TTY_1(fd, p) (tcgetattr ((fd), &(p)->main) != -1)
234 #define EMACS_SET_TTY_1(fd, p, waitp) \
235 (tcsetattr ((fd), (waitp) ? TCSAFLUSH : TCSADRAIN, &(p)->main) != -1)
240 #define EMACS_GET_TTY_1(fd, p) (ioctl ((fd), TCGETA, &(p)->main) != -1)
241 #define EMACS_SET_TTY_1(fd, p, waitp) \
242 (ioctl ((fd), (waitp) ? TCSETAW : TCSETAF, &(p)->main) != -1)
247 /* These definitions will really only work in sysdep.c, because of their
248 use of input_iosb. I don't know enough about VMS QIO to fix this. */
249 #define EMACS_GET_TTY_1(fd, p) \
250 SYS$QIOW (0, (fd), IO$_SENSEMODE, (p), 0, 0, \
251 &(p)->main.class, 12, 0, 0, 0, 0);
252 #define EMACS_SET_TTY_1(fd, p, waitp) \
253 SYS$QIOW (0, (fd), IO$_SETMODE, &input_iosb, 0, 0, \
254 &(p)->main.class, 12, 0, 0, 0, 0);
258 #define EMACS_GET_TTY_1(fd, p) (ioctl ((fd), TIOCGETP, &(p)->main) != -1)
259 #define EMACS_SET_TTY_1(fd, p, waitp) \
260 (ioctl ((fd), (waitp) ? TIOCSETP : TIOCSETN, &(p)->main) != -1)
267 struct ltchars ltchars
;
268 #define EMACS_GET_TTY_2(fd, p) \
269 (ioctl ((fd), TIOCGLTC, &(p)->ltchars) != -1)
270 #define EMACS_SET_TTY_2(fd, p, waitp) \
271 (ioctl ((fd), TIOCSLTC, &(p)->ltchars) != -1)
273 #define EMACS_GET_TTY_2(fd, p) 1
274 #define EMACS_SET_TTY_2(fd, p, waitp) 1
275 #endif /* TIOCGLTC */
278 struct tchars tchars
;
280 #define EMACS_GET_TTY_3(fd, p) \
281 (ioctl ((fd), TIOCGETC, &(p)->tchars) != -1 \
282 && ioctl ((fd), TIOCLGET, &(p)->lmode) != -1)
283 #define EMACS_SET_TTY_3(fd, p, waitp) \
284 (ioctl ((fd), TIOCSETC, &(p)->tchars) != -1 \
285 && ioctl ((fd), TIOCLSET, &(p)->lmode) != -1)
287 #define EMACS_GET_TTY_3(fd, p) 1
288 #define EMACS_SET_TTY_3(fd, p, waitp) 1
289 #endif /* TIOCGLTC */
293 /* Define these to be a concatenation of all the EMACS_{GET,SET}_TTY
295 #define EMACS_GET_TTY(fd, tc) \
296 (EMACS_GET_TTY_1 (fd, tc) \
297 && EMACS_GET_TTY_2 (fd, tc) \
298 && EMACS_GET_TTY_3 (fd, tc))
300 #define EMACS_SET_TTY(fd, tc, waitp) \
301 (EMACS_SET_TTY_1 (fd, tc, waitp) \
302 && EMACS_SET_TTY_2 (fd, tc, waitp) \
303 && EMACS_SET_TTY_3 (fd, tc, waitp))
308 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
310 #else /* not def HAVE_TERMIOS */
313 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
315 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
318 #define EMACS_TTY_TABS_OK(p) (((p)->main.tt_char & TT$M_MECHTAB) != 0)
322 #define EMACS_TTY_TABS_OK(p) (((p)->main.sg_flags & XTABS) != XTABS)
324 #endif /* not def VMS */
325 #endif /* not def HAVE_TERMIO */
326 #endif /* not def HAVE_TERMIOS */