1 /* systty.h - System-dependent definitions for terminals.
2 Copyright (C) 1993, 1994 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 2, 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, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
26 /* Include the proper files. */
29 #include <sys/ioctl.h>
33 #endif /* not NO_TERMIO */
34 #ifndef INCLUDED_FCNTL
35 #define INCLUDED_FCNTL
38 #else /* not HAVE_TERMIO */
40 #if defined(_AIX) && defined(_I386)
41 #include <termios.h> /* termios.h needs to be before termio.h */
43 #else /* not (_AIX && _I386) */
48 #endif /* not (_AIX && _I386) */
49 #define INCLUDED_FCNTL
51 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
55 #endif /* not DOS_NT */
66 extern int waiting_for_ast
;
67 extern int stop_input
;
70 extern int process_ef
;
71 extern int input_eflist
;
72 extern int timer_eflist
;
74 static $
DESCRIPTOR (input_dsc
, "TT");
75 static int terminator_mask
[2] = { 0, 0 };
77 static struct sensemode
{
79 unsigned char xmit_baud
;
80 unsigned char rcv_baud
;
88 unsigned long tt_char
: 24, scr_len
: 8;
89 unsigned long tt2_char
;
92 #endif /* not HAVE_TERMIOS */
93 #endif /* not HAVE_TERMIO */
95 #ifdef __GNU_LIBRARY__
96 #include <sys/ioctl.h>
101 /* Get files for keyboard remapping */
104 #include <sys/devinfo.h>
107 /* Get rid of LLITOUT in 4.1, since it is said to stimulate kernel bugs. */
114 #include <sys/bsdtty.h>
117 #if defined (HPUX) && defined (HAVE_PTYS)
118 #include <sys/ptyio.h>
125 #if (defined (POSIX) || defined (NEED_UNISTD_H)) && defined (HAVE_UNISTD_H)
130 #include <sys/types.h>
133 #include <sys/ttyhw.h>
134 #include <sys/stream.h>
141 /* saka@pfu.fujitsu.co.JP writes:
142 FASYNC defined in this file. But, FASYNC don't working.
143 so no problem, because unrequest_sigio only need. */
145 #include <sys/file.h>
149 /* Special cases - inhibiting the use of certain features. */
156 #undef TIOCGETC /* Avoid confusing some conditionals that test this. */
159 #ifdef BROKEN_TIOCGETC
160 #undef TIOCGETC /* Avoid confusing some conditionals that test this. */
163 /* UNIPLUS systems may have FIONREAD. */
165 #include <sys.ioctl.h>
168 /* Allow m- file to inhibit use of FIONREAD. */
169 #ifdef BROKEN_FIONREAD
174 /* Interrupt input is not used if there is no FIONREAD. */
179 /* On TERMIOS systems, the tcmumbleattr calls take care of these
180 parameters, and it's a bad idea to use them (on AIX, it makes the
181 tty hang for a long time). */
182 #if defined (TIOCGLTC) && !defined (HAVE_TERMIOS)
186 #if defined (TIOCGETC) && !defined (HAVE_TERMIOS)
191 /* Try to establish the correct character to disable terminal functions
192 in a system-independent manner. Note that USG (at least) define
193 _POSIX_VDISABLE as 0! */
195 #ifdef _POSIX_VDISABLE
196 #define CDISABLE _POSIX_VDISABLE
197 #else /* not _POSIX_VDISABLE */
200 #define CDISABLE CDEL
203 #endif /* not CDEL */
204 #endif /* not _POSIX_VDISABLE */
206 /* Get the number of characters queued for output. */
208 /* EMACS_OUTQSIZE(FD, int *SIZE) stores the number of characters
209 queued for output to the terminal FD in *SIZE, if FD is a tty.
210 Returns -1 if there was an error (i.e. FD is not a tty), 0
213 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TIOCOUTQ, (size)))
218 #undef EMACS_OUTQSIZE
219 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TCOUTQ, (size)))
224 /* Manipulate a terminal's current process group. */
226 /* EMACS_HAVE_TTY_PGRP is true if we can get and set the tty's current
227 controlling process group.
229 EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's
230 current process group. Return -1 if there is an error.
232 EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's
233 current process group to *PGID. Return -1 if there is an error. */
236 /* HPUX tty process group stuff doesn't work, says the anonymous voice
240 #define EMACS_HAVE_TTY_PGRP
243 #define EMACS_HAVE_TTY_PGRP
248 #ifdef EMACS_HAVE_TTY_PGRP
250 #if defined (HAVE_TERMIOS) && ! defined (BSD_TERMIOS)
252 #define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp ((fd)))
253 #define EMACS_SET_TTY_PGRP(fd, pgid) (tcsetpgrp ((fd), *(pgid)))
258 #define EMACS_GET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCGPGRP, (pgid)))
259 #define EMACS_SET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCSPGRP, (pgid)))
266 /* Just ignore this for now and hope for the best */
267 #define EMACS_GET_TTY_PGRP(fd, pgid) 0
268 #define EMACS_SET_TTY_PGRP(fd, pgif) 0
272 /* EMACS_GETPGRP (arg) returns the process group of the process. */
274 #if defined (GETPGRP_VOID)
275 # define EMACS_GETPGRP(x) getpgrp()
277 # define EMACS_GETPGRP(x) getpgrp(x)
278 #endif /* !GETPGRP_VOID */
280 /* Manipulate a TTY's input/output processing parameters. */
282 /* struct emacs_tty is a structure used to hold the current tty
283 parameters. If the terminal has several structures describing its
284 state, for example a struct tchars, a struct sgttyb, a struct
285 tchars, a struct ltchars, and a struct pagechars, struct
286 emacs_tty should contain an element for each parameter struct
287 that Emacs may change.
289 EMACS_GET_TTY (int FD, struct emacs_tty *P) stores the parameters
290 of the tty on FD in *P. Return zero if all's well, or -1 if we ran
291 into an error we couldn't deal with.
293 EMACS_SET_TTY (int FD, struct emacs_tty *P, int flushp)
294 sets the parameters of the tty on FD according to the contents of
295 *P. If flushp is non-zero, we discard queued input to be
296 written before making the change.
297 Return 0 if all went well, and -1 if anything failed.
299 EMACS_TTY_TABS_OK (struct emacs_tty *P) is false iff the kernel
300 expands tabs to spaces upon output; in that case, there is no
301 advantage to using tabs over spaces. */
304 /* For each tty parameter structure that Emacs might want to save and restore,
305 - include an element for it in this structure, and
306 - extend the emacs_{get,set}_tty functions in sysdep.c to deal with the
311 /* There is always one of the following elements, so there is no need
312 for dummy get and set definitions. */
320 struct sensemode main
;
324 #else /* not DOS_NT */
326 #endif /* not DOS_NT */
331 /* If we have TERMIOS, we don't need to do this - they're taken care of
332 by the tc*attr calls. */
335 struct ltchars ltchars
;
339 struct tchars tchars
;
345 /* Define EMACS_GET_TTY and EMACS_SET_TTY,
346 the macros for reading and setting parts of `struct emacs_tty'.
348 These got pretty unmanageable (huge macros are hard to debug), and
349 finally needed some code which couldn't be done as part of an
350 expression, so we moved them out to their own functions in sysdep.c. */
351 #define EMACS_GET_TTY(fd, p) (emacs_get_tty ((fd), (p)))
352 #define EMACS_SET_TTY(fd, p, waitp) (emacs_set_tty ((fd), (p), (waitp)))
353 #ifdef P_ /* Unfortunately this file is sometimes included before lisp.h */
354 extern int emacs_get_tty
P_ ((int, struct emacs_tty
*));
355 extern int emacs_set_tty
P_ ((int, struct emacs_tty
*, int));
359 /* Define EMACS_TTY_TABS_OK. */
364 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
366 #define EMACS_TTY_TABS_OK(p) 1
369 #else /* not def HAVE_TERMIOS */
372 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
374 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
377 #define EMACS_TTY_TABS_OK(p) (((p)->main.tt_char & TT$M_MECHTAB) != 0)
382 #define EMACS_TTY_TABS_OK(p) 0
383 #else /* not DOS_NT */
384 #define EMACS_TTY_TABS_OK(p) (((p)->main.sg_flags & XTABS) != XTABS)
385 #endif /* not DOS_NT */
387 #endif /* not def VMS */
388 #endif /* not def HAVE_TERMIO */
389 #endif /* not def HAVE_TERMIOS */
391 /* arch-tag: cf4b90bc-be41-401c-be98-40619178a712
392 (do not change this comment) */