1 /* systty.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. */
24 /* Include the proper files. */
33 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
46 extern int waiting_for_ast
;
47 extern int stop_input
;
48 #if 0 /* VAX C doeasn't understand initializing declarations */
49 extern int input_ef
= 0;
50 extern int timer_ef
= 0;
51 extern int process_ef
= 0;
55 extern int process_ef
;
57 extern int input_eflist
;
58 extern int timer_eflist
;
60 static $
DESCRIPTOR (input_dsc
, "TT");
61 static int terminator_mask
[2] = { 0, 0 };
63 static struct sensemode
{
65 unsigned char xmit_baud
;
66 unsigned char rcv_baud
;
74 unsigned long tt_char
: 24, scr_len
: 8;
75 unsigned long tt2_char
;
78 #endif /* not HAVE_TERMIOS */
79 #endif /* not HAVE_TERMIO */
82 /* Get files for keyboard remapping */
85 #include <sys/devinfo.h>
88 /* Get rid of LLITOUT in 4.1, since it is said to stimulate kernel bugs. */
95 #include <sys/bsdtty.h>
98 #if defined (HPUX) && defined (HAVE_PTYS)
99 #include <sys/ptyio.h>
110 #include <sys/ttyhw.h>
111 #include <sys/stream.h>
118 /* saka@pfu.fujitsu.co.JP writes:
119 FASYNC defined in this file. But, FASYNC don't working.
120 so no problem, because unrequest_sigio only need. */
122 #include <sys/file.h>
126 /* Special cases - inhibiting the use of certain features. */
133 #undef TIOCGETC /* Avoid confusing some conditionals that test this. */
136 #ifdef BROKEN_TIOCGETC
137 #undef TIOCGETC /* Avoid confusing some conditionals that test this. */
140 /* UNIPLUS systems may have FIONREAD. */
142 #include <sys.ioctl.h>
145 /* Allow m- file to inhibit use of FIONREAD. */
146 #ifdef BROKEN_FIONREAD
151 /* Interupt input is not used if there is no FIONREAD. */
157 /* Try to establish the correct character to disable terminal functions
158 in a system-independent manner. Note that USG (at least) define
159 _POSIX_VDISABLE as 0! */
161 #ifdef _POSIX_VDISABLE
162 #define CDISABLE _POSIX_VDISABLE
163 #else /* not _POSIX_VDISABLE */
165 #define CDISABLE CDEL
168 #endif /* not CDEL */
169 #endif /* not _POSIX_VDISABLE */
171 /* Get the number of characters queued for output. */
173 /* EMACS_OUTQSIZE(FD, int *SIZE) stores the number of characters
174 queued for output to the terminal FD in *SIZE, if FD is a tty.
175 Returns -1 if there was an error (i.e. FD is not a tty), 0
178 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TIOCOUTQ, (size)))
183 #undef EMACS_OUTQSIZE
184 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TCOUTQ, (size)))
189 /* Manipulate a terminal's current process group. */
191 /* EMACS_HAVE_TTY_PGRP is true if we can get and set the tty's current
192 controlling process group.
194 EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's
195 current process group. Return -1 if there is an error.
197 EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's
198 current process group to *PGID. Return -1 if there is an error. */
201 /* HPUX tty process group stuff doesn't work, says the anonymous voice
205 #define EMACS_HAVE_TTY_PGRP
208 #define EMACS_HAVE_TTY_PGRP
213 #ifdef EMACS_HAVE_TTY_PGRP
217 #define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp ((fd)))
218 #define EMACS_SET_TTY_PGRP(fd, pgid) (*(pgid) = tcsetpgrp ((fd)))
223 #define EMACS_GET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCGPGRP, (pgid)))
224 #define EMACS_SET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCSPGRP, (pgid)))
231 /* Just ignore this for now and hope for the best */
232 #define EMACS_GET_TTY_PGRP(fd, pgid) 0
233 #define EMACS_SET_TTY_PGRP(fd, pgif) 0
238 /* Manipulate a TTY's input/output processing parameters. */
240 /* struct emacs_tty is a structure used to hold the current tty
241 parameters. If the terminal has several structures describing its
242 state, for example a struct tchars, a struct sgttyb, a struct
243 tchars, a struct ltchars, and a struct pagechars, struct
244 emacs_tty should contain an element for each parameter struct
245 that Emacs may change.
247 EMACS_GET_TTY (int FD, struct emacs_tty *P) stores the
248 parameters of the tty on FD in *P.
250 EMACS_SET_TTY (int FD, struct emacs_tty *P, int waitp)
251 sets the parameters of the tty on FD according to the contents of
252 *P. If waitp is non-zero, we wait for all queued output to be
253 written before making the change; otherwise, we forget any queued
254 input and make the change immediately.
256 EMACS_TTY_TABS_OK (struct emacs_tty *P) is false iff the kernel
257 expands tabs to spaces upon output; in that case, there is no
258 advantage to using tabs over spaces. */
261 /* For each tty parameter structure that Emacs might want to save and restore,
262 - include an element for it in this structure,
263 - define a pair of numbered macros to get and set it and return
264 true iff the call succeeded,
265 - give alternative definitions for when the component is not implemented
266 which always succeed, and
267 - extend the definition of EMACS_{GET,SET}_TTY_CHARS to include the
272 /* There is always one of the following elements, so there is no need
273 for dummy get and set definitions. */
281 struct sensemode main
;
288 struct ltchars ltchars
;
291 struct tchars tchars
;
296 /* Define EMACS_GET_TTY and EMACS_SET_TTY,
297 the macros for reading and setting parts of `struct emacs_tty'.
299 These got pretty unmanageable (huge macros are hard to debug), and
300 finally needed some code which couldn't be done as part of an
301 expression, so we moved them out to their own functions in sysdep.c. */
302 #define EMACS_GET_TTY(fd, p) (emacs_get_tty ((fd), (p)))
303 #define EMACS_SET_TTY(fd, p, waitp) (emacs_set_tty ((fd), (p), (waitp)))
306 /* Define EMACS_TTY_TABS_OK. */
310 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
312 #else /* not def HAVE_TERMIOS */
315 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
317 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
320 #define EMACS_TTY_TABS_OK(p) (((p)->main.tt_char & TT$M_MECHTAB) != 0)
324 #define EMACS_TTY_TABS_OK(p) (((p)->main.sg_flags & XTABS) != XTABS)
326 #endif /* not def VMS */
327 #endif /* not def HAVE_TERMIO */
328 #endif /* not def HAVE_TERMIOS */