1 /* $OpenBSD: tty.h,v 1.12 2016/04/11 20:43:33 schwarze Exp $ */
2 /* $NetBSD: tty.h,v 1.20 2016/04/11 00:50:13 christos Exp $ */
5 * Copyright (c) 1992, 1993
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * Christos Zoulas of Cornell University.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * @(#)tty.h 8.1 (Berkeley) 6/4/93
39 * el.tty.h: Local terminal header
47 /* Define our own since everyone gets it wrong! */
48 #define CONTROL(A) ((A) & 037)
51 * Aix compatible names
53 # if defined(VWERSE) && !defined(VWERASE)
54 # define VWERASE VWERSE
55 # endif /* VWERSE && !VWERASE */
57 # if defined(VDISCRD) && !defined(VDISCARD)
58 # define VDISCARD VDISCRD
59 # endif /* VDISCRD && !VDISCARD */
61 # if defined(VFLUSHO) && !defined(VDISCARD)
62 # define VDISCARD VFLUSHO
63 # endif /* VFLUSHO && VDISCARD */
65 # if defined(VSTRT) && !defined(VSTART)
67 # endif /* VSTRT && ! VSTART */
69 # if defined(VSTAT) && !defined(VSTATUS)
70 # define VSTATUS VSTAT
71 # endif /* VSTAT && ! VSTATUS */
85 # if defined(OXTABS) && !defined(XTABS)
87 # endif /* OXTABS && !XTABS */
107 # endif /* EXTPROC */
114 # if defined(VDISABLE) && !defined(_POSIX_VDISABLE)
115 # define _POSIX_VDISABLE VDISABLE
116 # endif /* VDISABLE && ! _POSIX_VDISABLE */
119 * Work around ISC's definition of IEXTEN which is
123 # if defined(IEXTEN) && defined(XCASE)
127 # endif /* IEXTEN == XCASE */
128 # endif /* IEXTEN && XCASE */
129 # if defined(IEXTEN) && !defined(XCASE)
130 # define XCASE IEXTEN
133 # endif /* IEXTEN && !XCASE */
137 * Work around convex weirdness where turning off IEXTEN makes us
138 * lose all postprocessing!
140 #if defined(convex) || defined(__convex__)
141 # if defined(IEXTEN) && IEXTEN != 0
144 # endif /* IEXTEN != 0 */
145 #endif /* convex || __convex__ */
148 * So that we don't lose job control.
154 #ifndef _POSIX_VDISABLE
155 # define _POSIX_VDISABLE ((unsigned char) -1)
156 #endif /* _POSIX_VDISABLE */
158 #if !defined(CREPRINT) && defined(CRPRNT)
159 # define CREPRINT CRPRNT
160 #endif /* !CREPRINT && CRPRNT */
161 #if !defined(CDISCARD) && defined(CFLUSH)
162 # define CDISCARD CFLUSH
163 #endif /* !CDISCARD && CFLUSH */
166 # define CINTR CONTROL('c')
169 # define CQUIT 034 /* ^\ */
172 # define CERASE 0177 /* ^? */
175 # define CKILL CONTROL('u')
178 # define CEOF CONTROL('d')
181 # define CEOL _POSIX_VDISABLE
184 # define CEOL2 _POSIX_VDISABLE
187 # define CSWTCH _POSIX_VDISABLE
190 # define CDSWTCH _POSIX_VDISABLE
193 # define CERASE2 _POSIX_VDISABLE
196 # define CSTART CONTROL('q')
199 # define CSTOP CONTROL('s')
202 # define CSUSP CONTROL('z')
205 # define CDSUSP CONTROL('y')
211 # define CREPRINT _POSIX_VDISABLE
212 # endif /* CREPRINT */
214 # define CDISCARD _POSIX_VDISABLE
215 # endif /* CDISCARD */
217 # define CLNEXT _POSIX_VDISABLE
220 # define CWERASE _POSIX_VDISABLE
221 # endif /* CWERASE */
226 # define CREPRINT CONTROL('r')
227 # endif /* CREPRINT */
229 # define CDISCARD CONTROL('o')
230 # endif /* CDISCARD */
232 # define CLNEXT CONTROL('v')
235 # define CWERASE CONTROL('w')
236 # endif /* CWERASE */
241 # define CSTATUS CONTROL('t')
247 # define CPGOFF CONTROL('m')
250 # define CKILL2 _POSIX_VDISABLE
257 # endif /* masscomp */
267 * Fix for sun inconsistency. On termio VSUSP and the rest of the
268 * ttychars > NCC are defined. So we undefine them.
270 #if defined(TERMIO) || defined(POSIX)
271 # if defined(POSIX) && defined(NCCS)
277 # endif /* POSIX && NCCS */
282 # endif /* NUMCC <= VINTR */
287 # endif /* NUMCC <= VQUIT */
292 # endif /* NUMCC <= VERASE */
297 # endif /* NUMCC <= VKILL */
302 # endif /* NUMCC <= VEOF */
307 # endif /* NUMCC <= VEOL */
312 # endif /* NUMCC <= VEOL2 */
317 # endif /* NUMCC <= VSWTCH */
320 # if NUMCC <= VDSWTCH
322 # endif /* NUMCC <= VDSWTCH */
323 # endif /* VDSWTCH */
325 # if NUMCC <= VERASE2
327 # endif /* NUMCC <= VERASE2 */
328 # endif /* VERASE2 */
332 # endif /* NUMCC <= VSTART */
337 # endif /* NUMCC <= VSTOP */
340 # if NUMCC <= VWERASE
342 # endif /* NUMCC <= VWERASE */
343 # endif /* VWERASE */
347 # endif /* NUMCC <= VSUSP */
352 # endif /* NUMCC <= VDSUSP */
355 # if NUMCC <= VREPRINT
357 # endif /* NUMCC <= VREPRINT */
358 # endif /* VREPRINT */
360 # if NUMCC <= VDISCARD
362 # endif /* NUMCC <= VDISCARD */
363 # endif /* VDISCARD */
367 # endif /* NUMCC <= VLNEXT */
370 # if NUMCC <= VSTATUS
372 # endif /* NUMCC <= VSTATUS */
373 # endif /* VSTATUS */
377 # endif /* NUMCC <= VPAGE */
382 # endif /* NUMCC <= VPGOFF */
387 # endif /* NUMCC <= VKILL2 */
392 # endif /* NUMCC <= VBRK */
397 # endif /* NUMCC <= VMIN */
402 # endif /* NUMCC <= VTIME */
433 #define C_SH(A) (1 << (A))
436 * Terminal dependend data structures
438 #define EX_IO 0 /* while we are executing */
439 #define ED_IO 1 /* while we are editing */
440 #define TS_IO 2 /* new mode from terminal */
441 #define QU_IO 2 /* used only for quoted chars */
442 #define NN_IO 3 /* The number of entries */
454 unsigned int t_setmask
;
455 unsigned int t_clrmask
;
456 } ttyperm_t
[NN_IO
][MD_NN
];
458 typedef unsigned char ttychar_t
[NN_IO
][C_NCC
];
460 protected int tty_init(EditLine
*);
461 protected void tty_end(EditLine
*);
462 protected int tty_stty(EditLine
*, int, const wchar_t **);
463 protected int tty_rawmode(EditLine
*);
464 protected int tty_cookedmode(EditLine
*);
465 protected int tty_quotemode(EditLine
*);
466 protected int tty_noquotemode(EditLine
*);
467 protected void tty_bind_char(EditLine
*, int);
472 struct termios t_or
, t_ex
, t_ed
, t_ts
;
476 unsigned char t_mode
;
477 unsigned char t_vdisable
;
478 unsigned char t_initialized
;
482 #endif /* _h_el_tty */