(map-keymap): Definition deleted.
[emacs.git] / src / systty.h
bloba975bcd13a0cd35cfe7f4ebfb353981cedc049b3
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)
9 any later version.
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., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 #ifdef HAVE_TERMIOS
22 #define HAVE_TCATTR
23 #endif
26 /* Include the proper files. */
27 #ifdef HAVE_TERMIO
28 #ifdef __DGUX
29 #include <sys/ioctl.h>
30 #endif
31 #ifndef NO_TERMIO
32 #include <termio.h>
33 #endif /* not NO_TERMIO */
34 #ifndef INCLUDED_FCNTL
35 #define INCLUDED_FCNTL
36 #include <fcntl.h>
37 #endif
38 #else /* not HAVE_TERMIO */
39 #ifdef HAVE_TERMIOS
40 #if defined(_AIX) && defined(_I386)
41 #include <termios.h> /* termios.h needs to be before termio.h */
42 #include <termio.h>
43 #else /* not (_AIX && _I386) */
44 #ifndef NO_TERMIO
45 #include <termio.h>
46 #endif
47 #include <termios.h>
48 #endif /* not (_AIX && _I386) */
49 #define INCLUDED_FCNTL
50 #include <fcntl.h>
51 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
52 #ifndef VMS
53 #ifndef DOS_NT
54 #include <sgtty.h>
55 #endif /* not DOS_NT */
56 #else /* VMS */
57 #include <descrip.h>
58 static struct iosb
60 short status;
61 short offset;
62 short termlen;
63 short term;
64 } input_iosb;
66 extern int waiting_for_ast;
67 extern int stop_input;
68 extern int input_ef;
69 extern int timer_ef;
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 {
78 short status;
79 unsigned char xmit_baud;
80 unsigned char rcv_baud;
81 unsigned char crfill;
82 unsigned char lffill;
83 unsigned char parity;
84 unsigned char unused;
85 char class;
86 char type;
87 short scr_wid;
88 unsigned long tt_char : 24, scr_len : 8;
89 unsigned long tt2_char;
90 } sensemode_iosb;
91 #endif /* VMS */
92 #endif /* not HAVE_TERMIOS */
93 #endif /* not HAVE_TERMIO */
95 #ifdef __GNU_LIBRARY__
96 #include <sys/ioctl.h>
97 #include <termios.h>
98 #endif
100 #ifdef AIXHFT
101 /* Get files for keyboard remapping */
102 #define HFNKEYS 2
103 #include <sys/hft.h>
104 #include <sys/devinfo.h>
105 #endif
107 /* Get rid of LLITOUT in 4.1, since it is said to stimulate kernel bugs. */
108 #ifdef BSD4_1
109 #undef LLITOUT
110 #define LLITOUT 0
111 #endif /* 4.1 */
113 #ifdef NEED_BSDTTY
114 #include <sys/bsdtty.h>
115 #endif
117 #if defined (HPUX) && defined (HAVE_PTYS)
118 #include <sys/ptyio.h>
119 #endif
121 #ifdef AIX
122 #include <sys/pty.h>
123 #endif /* AIX */
125 #if (defined (POSIX) || defined (NEED_UNISTD_H)) && defined (HAVE_UNISTD_H)
126 #include <unistd.h>
127 #endif
129 #ifdef SYSV_PTYS
130 #include <sys/types.h>
131 #include <sys/tty.h>
132 #ifdef titan
133 #include <sys/ttyhw.h>
134 #include <sys/stream.h>
135 #endif
136 #ifndef NO_PTY_H
137 #include <sys/pty.h>
138 #endif
139 #endif
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. */
144 #if defined (pfa)
145 #include <sys/file.h>
146 #endif
149 /* Special cases - inhibiting the use of certain features. */
151 #ifdef APOLLO
152 #undef TIOCSTART
153 #endif
155 #ifdef XENIX
156 #undef TIOCGETC /* Avoid confusing some conditionals that test this. */
157 #endif
159 #ifdef BROKEN_TIOCGETC
160 #undef TIOCGETC /* Avoid confusing some conditionals that test this. */
161 #endif
163 /* UNIPLUS systems may have FIONREAD. */
164 #ifdef UNIPLUS
165 #include <sys.ioctl.h>
166 #endif
168 /* Allow m- file to inhibit use of FIONREAD. */
169 #ifdef BROKEN_FIONREAD
170 #undef FIONREAD
171 #undef ASYNC
172 #endif
174 /* Interrupt input is not used if there is no FIONREAD. */
175 #ifndef FIONREAD
176 #undef SIGIO
177 #endif
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)
183 #define HAVE_LTCHARS
184 #endif
186 #if defined (TIOCGETC) && !defined (HAVE_TERMIOS)
187 #define HAVE_TCHARS
188 #endif
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 */
198 #ifdef CDEL
199 #undef CDISABLE
200 #define CDISABLE CDEL
201 #else /* not CDEL */
202 #define CDISABLE 255
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
211 otherwise. */
212 #ifdef TIOCOUTQ
213 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TIOCOUTQ, (size)))
214 #endif
216 #ifdef HAVE_TERMIO
217 #ifdef TCOUTQ
218 #undef EMACS_OUTQSIZE
219 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TCOUTQ, (size)))
220 #endif
221 #endif
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. */
235 #ifdef HPUX
236 /* HPUX tty process group stuff doesn't work, says the anonymous voice
237 from the past. */
238 #else
239 #ifdef TIOCGPGRP
240 #define EMACS_HAVE_TTY_PGRP
241 #else
242 #ifdef HAVE_TERMIOS
243 #define EMACS_HAVE_TTY_PGRP
244 #endif
245 #endif
246 #endif
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)))
255 #else
256 #ifdef TIOCSPGRP
258 #define EMACS_GET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCGPGRP, (pgid)))
259 #define EMACS_SET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCSPGRP, (pgid)))
261 #endif
262 #endif
264 #else
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
270 #endif
272 /* EMACS_GETPGRP (arg) returns the process group of the process. */
274 #if defined (GETPGRP_VOID)
275 # define EMACS_GETPGRP(x) getpgrp()
276 #else
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
307 new members. */
309 struct emacs_tty {
311 /* There is always one of the following elements, so there is no need
312 for dummy get and set definitions. */
313 #ifdef HAVE_TCATTR
314 struct termios main;
315 #else
316 #ifdef HAVE_TERMIO
317 struct termio main;
318 #else
319 #ifdef VMS
320 struct sensemode main;
321 #else
322 #ifdef DOS_NT
323 int main;
324 #else /* not DOS_NT */
325 struct sgttyb main;
326 #endif /* not DOS_NT */
327 #endif
328 #endif
329 #endif
331 /* If we have TERMIOS, we don't need to do this - they're taken care of
332 by the tc*attr calls. */
333 #ifndef HAVE_TERMIOS
334 #ifdef HAVE_LTCHARS
335 struct ltchars ltchars;
336 #endif
338 #ifdef HAVE_TCHARS
339 struct tchars tchars;
340 int lmode;
341 #endif
342 #endif
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));
356 #endif
359 /* Define EMACS_TTY_TABS_OK. */
361 #ifdef HAVE_TERMIOS
363 #ifdef TABDLY
364 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
365 #else
366 #define EMACS_TTY_TABS_OK(p) 1
367 #endif
369 #else /* not def HAVE_TERMIOS */
370 #ifdef HAVE_TERMIO
372 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
374 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
375 #ifdef VMS
377 #define EMACS_TTY_TABS_OK(p) (((p)->main.tt_char & TT$M_MECHTAB) != 0)
379 #else
381 #ifdef DOS_NT
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) */