1 /* $NetBSD: tty.h,v 1.21 2016/05/09 21:46:56 christos Exp $ */
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Christos Zoulas of Cornell University.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * @(#)tty.h 8.1 (Berkeley) 6/4/93
38 * el.tty.h: Local terminal header
46 /* Define our own since everyone gets it wrong! */
47 #define CONTROL(A) ((A) & 037)
50 * Aix compatible names
52 # if defined(VWERSE) && !defined(VWERASE)
53 # define VWERASE VWERSE
54 # endif /* VWERSE && !VWERASE */
56 # if defined(VDISCRD) && !defined(VDISCARD)
57 # define VDISCARD VDISCRD
58 # endif /* VDISCRD && !VDISCARD */
60 # if defined(VFLUSHO) && !defined(VDISCARD)
61 # define VDISCARD VFLUSHO
62 # endif /* VFLUSHO && VDISCARD */
64 # if defined(VSTRT) && !defined(VSTART)
66 # endif /* VSTRT && ! VSTART */
68 # if defined(VSTAT) && !defined(VSTATUS)
69 # define VSTATUS VSTAT
70 # endif /* VSTAT && ! VSTATUS */
84 # if defined(OXTABS) && !defined(XTABS)
86 # endif /* OXTABS && !XTABS */
106 # endif /* EXTPROC */
113 # if defined(VDISABLE) && !defined(_POSIX_VDISABLE)
114 # define _POSIX_VDISABLE VDISABLE
115 # endif /* VDISABLE && ! _POSIX_VDISABLE */
118 * Work around ISC's definition of IEXTEN which is
122 # if defined(IEXTEN) && defined(XCASE)
126 # endif /* IEXTEN == XCASE */
127 # endif /* IEXTEN && XCASE */
128 # if defined(IEXTEN) && !defined(XCASE)
129 # define XCASE IEXTEN
132 # endif /* IEXTEN && !XCASE */
136 * Work around convex weirdness where turning off IEXTEN makes us
137 * lose all postprocessing!
139 #if defined(convex) || defined(__convex__)
140 # if defined(IEXTEN) && IEXTEN != 0
143 # endif /* IEXTEN != 0 */
144 #endif /* convex || __convex__ */
147 * So that we don't lose job control.
153 #ifndef _POSIX_VDISABLE
154 # define _POSIX_VDISABLE ((unsigned char) -1)
155 #endif /* _POSIX_VDISABLE */
157 #if !defined(CREPRINT) && defined(CRPRNT)
158 # define CREPRINT CRPRNT
159 #endif /* !CREPRINT && CRPRNT */
160 #if !defined(CDISCARD) && defined(CFLUSH)
161 # define CDISCARD CFLUSH
162 #endif /* !CDISCARD && CFLUSH */
165 # define CINTR CONTROL('c')
168 # define CQUIT 034 /* ^\ */
171 # define CERASE 0177 /* ^? */
174 # define CKILL CONTROL('u')
177 # define CEOF CONTROL('d')
180 # define CEOL _POSIX_VDISABLE
183 # define CEOL2 _POSIX_VDISABLE
186 # define CSWTCH _POSIX_VDISABLE
189 # define CDSWTCH _POSIX_VDISABLE
192 # define CERASE2 _POSIX_VDISABLE
195 # define CSTART CONTROL('q')
198 # define CSTOP CONTROL('s')
201 # define CSUSP CONTROL('z')
204 # define CDSUSP CONTROL('y')
210 # define CREPRINT _POSIX_VDISABLE
211 # endif /* CREPRINT */
213 # define CDISCARD _POSIX_VDISABLE
214 # endif /* CDISCARD */
216 # define CLNEXT _POSIX_VDISABLE
219 # define CWERASE _POSIX_VDISABLE
220 # endif /* CWERASE */
225 # define CREPRINT CONTROL('r')
226 # endif /* CREPRINT */
228 # define CDISCARD CONTROL('o')
229 # endif /* CDISCARD */
231 # define CLNEXT CONTROL('v')
234 # define CWERASE CONTROL('w')
235 # endif /* CWERASE */
240 # define CSTATUS CONTROL('t')
246 # define CPGOFF CONTROL('m')
249 # define CKILL2 _POSIX_VDISABLE
256 # endif /* masscomp */
266 * Fix for sun inconsistency. On termio VSUSP and the rest of the
267 * ttychars > NCC are defined. So we undefine them.
269 #if defined(TERMIO) || defined(POSIX)
270 # if defined(POSIX) && defined(NCCS)
276 # endif /* POSIX && NCCS */
281 # endif /* NUMCC <= VINTR */
286 # endif /* NUMCC <= VQUIT */
291 # endif /* NUMCC <= VERASE */
296 # endif /* NUMCC <= VKILL */
301 # endif /* NUMCC <= VEOF */
306 # endif /* NUMCC <= VEOL */
311 # endif /* NUMCC <= VEOL2 */
316 # endif /* NUMCC <= VSWTCH */
319 # if NUMCC <= VDSWTCH
321 # endif /* NUMCC <= VDSWTCH */
322 # endif /* VDSWTCH */
324 # if NUMCC <= VERASE2
326 # endif /* NUMCC <= VERASE2 */
327 # endif /* VERASE2 */
331 # endif /* NUMCC <= VSTART */
336 # endif /* NUMCC <= VSTOP */
339 # if NUMCC <= VWERASE
341 # endif /* NUMCC <= VWERASE */
342 # endif /* VWERASE */
346 # endif /* NUMCC <= VSUSP */
351 # endif /* NUMCC <= VDSUSP */
354 # if NUMCC <= VREPRINT
356 # endif /* NUMCC <= VREPRINT */
357 # endif /* VREPRINT */
359 # if NUMCC <= VDISCARD
361 # endif /* NUMCC <= VDISCARD */
362 # endif /* VDISCARD */
366 # endif /* NUMCC <= VLNEXT */
369 # if NUMCC <= VSTATUS
371 # endif /* NUMCC <= VSTATUS */
372 # endif /* VSTATUS */
376 # endif /* NUMCC <= VPAGE */
381 # endif /* NUMCC <= VPGOFF */
386 # endif /* NUMCC <= VKILL2 */
391 # endif /* NUMCC <= VBRK */
396 # endif /* NUMCC <= VMIN */
401 # endif /* NUMCC <= VTIME */
432 #define C_SH(A) ((unsigned int)(1 << (A)))
435 * Terminal dependend data structures
437 #define EX_IO 0 /* while we are executing */
438 #define ED_IO 1 /* while we are editing */
439 #define TS_IO 2 /* new mode from terminal */
440 #define QU_IO 2 /* used only for quoted chars */
441 #define NN_IO 3 /* The number of entries */
453 unsigned int t_setmask
;
454 unsigned int t_clrmask
;
455 } ttyperm_t
[NN_IO
][MD_NN
];
457 typedef unsigned char ttychar_t
[NN_IO
][C_NCC
];
459 libedit_private
int tty_init(EditLine
*);
460 libedit_private
void tty_end(EditLine
*);
461 libedit_private
int tty_stty(EditLine
*, int, const wchar_t **);
462 libedit_private
int tty_rawmode(EditLine
*);
463 libedit_private
int tty_cookedmode(EditLine
*);
464 libedit_private
int tty_quotemode(EditLine
*);
465 libedit_private
int tty_noquotemode(EditLine
*);
466 libedit_private
void tty_bind_char(EditLine
*, int);
471 struct termios t_or
, t_ex
, t_ed
, t_ts
;
475 unsigned char t_mode
;
476 unsigned char t_vdisable
;
477 unsigned char t_initialized
;
481 #endif /* _h_el_tty */