1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Christos Zoulas of Cornell University.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)tty.h 8.1 (Berkeley) 6/4/93
37 * $NetBSD: tty.h,v 1.7 1999/09/26 14:37:47 lukem Exp $
38 * $FreeBSD: head/lib/libedit/tty.h 84260 2001-10-01 08:41:27Z obrien $
39 */
40
41/*
42 * el.tty.h: Local terminal header
43 */
44#ifndef _h_el_tty
45#define _h_el_tty
46
47#include "histedit.h"
48#include <termios.h>
49#include <unistd.h>
50
51/* Define our own since everyone gets it wrong! */
52#define CONTROL(A) ((A) & 037)
53
54/*
55 * Aix compatible names
56 */
57# if defined(VWERSE) && !defined(VWERASE)
58# define VWERASE VWERSE
59# endif /* VWERSE && !VWERASE */
60
61# if defined(VDISCRD) && !defined(VDISCARD)
62# define VDISCARD VDISCRD
63# endif /* VDISCRD && !VDISCARD */
64
65# if defined(VFLUSHO) && !defined(VDISCARD)
66# define VDISCARD VFLUSHO
67# endif /* VFLUSHO && VDISCARD */
68
69# if defined(VSTRT) && !defined(VSTART)
70# define VSTART VSTRT
71# endif /* VSTRT && ! VSTART */
72
73# if defined(VSTAT) && !defined(VSTATUS)
74# define VSTATUS VSTAT
75# endif /* VSTAT && ! VSTATUS */
76
77# ifndef ONLRET
78# define ONLRET 0
79# endif /* ONLRET */
80
81# ifndef TAB3
82# ifdef OXTABS
83# define TAB3 OXTABS
84# else
85# define TAB3 0
86# endif /* OXTABS */
87# endif /* !TAB3 */
88
89# if defined(OXTABS) && !defined(XTABS)
90# define XTABS OXTABS
91# endif /* OXTABS && !XTABS */
92
93# ifndef ONLCR
94# define ONLCR 0
95# endif /* ONLCR */
96
97# ifndef IEXTEN
98# define IEXTEN 0
99# endif /* IEXTEN */
100
101# ifndef ECHOCTL
102# define ECHOCTL 0
103# endif /* ECHOCTL */
104
105# ifndef PARENB
106# define PARENB 0
107# endif /* PARENB */
108
109# ifndef EXTPROC
110# define EXTPROC 0
111# endif /* EXTPROC */
112
113# ifndef FLUSHO
114# define FLUSHO 0
115# endif /* FLUSHO */
116
117
118# if defined(VDISABLE) && !defined(_POSIX_VDISABLE)
119# define _POSIX_VDISABLE VDISABLE
120# endif /* VDISABLE && ! _POSIX_VDISABLE */
121
122/*
123 * Work around ISC's definition of IEXTEN which is
124 * XCASE!
125 */
126# ifdef ISC
127# if defined(IEXTEN) && defined(XCASE)
128# if IEXTEN == XCASE
129# undef IEXTEN
130# define IEXTEN 0
131# endif /* IEXTEN == XCASE */
132# endif /* IEXTEN && XCASE */
133# if defined(IEXTEN) && !defined(XCASE)
134# define XCASE IEXTEN
135# undef IEXTEN
136# define IEXTEN 0
137# endif /* IEXTEN && !XCASE */
138# endif /* ISC */
139
140/*
141 * Work around convex weirdness where turning off IEXTEN makes us
142 * lose all postprocessing!
143 */
144#if defined(convex) || defined(__convex__)
145# if defined(IEXTEN) && IEXTEN != 0
146# undef IEXTEN
147# define IEXTEN 0
148# endif /* IEXTEN != 0 */
149#endif /* convex || __convex__ */
150
151/*
152 * So that we don't lose job control.
153 */
154#ifdef __SVR4
155# undef CSWTCH
156#endif
157
158#ifndef _POSIX_VDISABLE
159# define _POSIX_VDISABLE ((unsigned char) -1)
160#endif /* _POSIX_VDISABLE */
161
162#if !defined(CREPRINT) && defined(CRPRNT)
163# define CREPRINT CRPRNT
164#endif /* !CREPRINT && CRPRNT */
165#if !defined(CDISCARD) && defined(CFLUSH)
166# define CDISCARD CFLUSH
167#endif /* !CDISCARD && CFLUSH */
168
169#ifndef CINTR
170# define CINTR CONTROL('c')
171#endif /* CINTR */
172#ifndef CQUIT
173# define CQUIT 034 /* ^\ */
174#endif /* CQUIT */
175#ifndef CERASE
176# define CERASE 0177 /* ^? */
177#endif /* CERASE */
178#ifndef CKILL
179# define CKILL CONTROL('u')
180#endif /* CKILL */
181#ifndef CEOF
182# define CEOF CONTROL('d')
183#endif /* CEOF */
184#ifndef CEOL
185# define CEOL _POSIX_VDISABLE
186#endif /* CEOL */
187#ifndef CEOL2
188# define CEOL2 _POSIX_VDISABLE
189#endif /* CEOL2 */
190#ifndef CSWTCH
191# define CSWTCH _POSIX_VDISABLE
192#endif /* CSWTCH */
193#ifndef CDSWTCH
194# define CDSWTCH _POSIX_VDISABLE
195#endif /* CDSWTCH */
196#ifndef CERASE2
197# define CERASE2 _POSIX_VDISABLE
198#endif /* CERASE2 */
199#ifndef CSTART
200# define CSTART CONTROL('q')
201#endif /* CSTART */
202#ifndef CSTOP
203# define CSTOP CONTROL('s')
204#endif /* CSTOP */
205#ifndef CSUSP
206# define CSUSP CONTROL('z')
207#endif /* CSUSP */
208#ifndef CDSUSP
209# define CDSUSP CONTROL('y')
210#endif /* CDSUSP */
211
212#ifdef hpux
213
214# ifndef CREPRINT
215# define CREPRINT _POSIX_VDISABLE
216# endif /* CREPRINT */
217# ifndef CDISCARD
218# define CDISCARD _POSIX_VDISABLE
219# endif /* CDISCARD */
220# ifndef CLNEXT
221# define CLNEXT _POSIX_VDISABLE
222# endif /* CLNEXT */
223# ifndef CWERASE
224# define CWERASE _POSIX_VDISABLE
225# endif /* CWERASE */
226
227#else /* !hpux */
228
229# ifndef CREPRINT
230# define CREPRINT CONTROL('r')
231# endif /* CREPRINT */
232# ifndef CDISCARD
233# define CDISCARD CONTROL('o')
234# endif /* CDISCARD */
235# ifndef CLNEXT
236# define CLNEXT CONTROL('v')
237# endif /* CLNEXT */
238# ifndef CWERASE
239# define CWERASE CONTROL('w')
240# endif /* CWERASE */
241
242#endif /* hpux */
243
244#ifndef CSTATUS
245# define CSTATUS CONTROL('t')
246#endif /* CSTATUS */
247#ifndef CPAGE
248# define CPAGE ' '
249#endif /* CPAGE */
250#ifndef CPGOFF
251# define CPGOFF CONTROL('m')
252#endif /* CPGOFF */
253#ifndef CKILL2
254# define CKILL2 _POSIX_VDISABLE
255#endif /* CKILL2 */
256#ifndef CBRK
257# ifndef masscomp
258# define CBRK 0377
259# else
260# define CBRK '\0'
261# endif /* masscomp */
262#endif /* CBRK */
263#ifndef CMIN
264# define CMIN CEOF
265#endif /* CMIN */
266#ifndef CTIME
267# define CTIME CEOL
268#endif /* CTIME */
269
270/*
271 * Fix for sun inconsistency. On termio VSUSP and the rest of the
272 * ttychars > NCC are defined. So we undefine them.
273 */
274#if defined(TERMIO) || defined(POSIX)
275# if defined(POSIX) && defined(NCCS)
276# define NUMCC NCCS
277# else
278# ifdef NCC
279# define NUMCC NCC
280# endif /* NCC */
281# endif /* POSIX && NCCS */
282# ifdef NUMCC
283# ifdef VINTR
284# if NUMCC <= VINTR
285# undef VINTR
286# endif /* NUMCC <= VINTR */
287# endif /* VINTR */
288# ifdef VQUIT
289# if NUMCC <= VQUIT
290# undef VQUIT
291# endif /* NUMCC <= VQUIT */
292# endif /* VQUIT */
293# ifdef VERASE
294# if NUMCC <= VERASE
295# undef VERASE
296# endif /* NUMCC <= VERASE */
297# endif /* VERASE */
298# ifdef VKILL
299# if NUMCC <= VKILL
300# undef VKILL
301# endif /* NUMCC <= VKILL */
302# endif /* VKILL */
303# ifdef VEOF
304# if NUMCC <= VEOF
305# undef VEOF
306# endif /* NUMCC <= VEOF */
307# endif /* VEOF */
308# ifdef VEOL
309# if NUMCC <= VEOL
310# undef VEOL
311# endif /* NUMCC <= VEOL */
312# endif /* VEOL */
313# ifdef VEOL2
314# if NUMCC <= VEOL2
315# undef VEOL2
316# endif /* NUMCC <= VEOL2 */
317# endif /* VEOL2 */
318# ifdef VSWTCH
319# if NUMCC <= VSWTCH
320# undef VSWTCH
321# endif /* NUMCC <= VSWTCH */
322# endif /* VSWTCH */
323# ifdef VDSWTCH
324# if NUMCC <= VDSWTCH
325# undef VDSWTCH
326# endif /* NUMCC <= VDSWTCH */
327# endif /* VDSWTCH */
328# ifdef VERASE2
329# if NUMCC <= VERASE2
330# undef VERASE2
331# endif /* NUMCC <= VERASE2 */
332# endif /* VERASE2 */
333# ifdef VSTART
334# if NUMCC <= VSTART
335# undef VSTART
336# endif /* NUMCC <= VSTART */
337# endif /* VSTART */
338# ifdef VSTOP
339# if NUMCC <= VSTOP
340# undef VSTOP
341# endif /* NUMCC <= VSTOP */
342# endif /* VSTOP */
343# ifdef VWERASE
344# if NUMCC <= VWERASE
345# undef VWERASE
346# endif /* NUMCC <= VWERASE */
347# endif /* VWERASE */
348# ifdef VSUSP
349# if NUMCC <= VSUSP
350# undef VSUSP
351# endif /* NUMCC <= VSUSP */
352# endif /* VSUSP */
353# ifdef VDSUSP
354# if NUMCC <= VDSUSP
355# undef VDSUSP
356# endif /* NUMCC <= VDSUSP */
357# endif /* VDSUSP */
358# ifdef VREPRINT
359# if NUMCC <= VREPRINT
360# undef VREPRINT
361# endif /* NUMCC <= VREPRINT */
362# endif /* VREPRINT */
363# ifdef VDISCARD
364# if NUMCC <= VDISCARD
365# undef VDISCARD
366# endif /* NUMCC <= VDISCARD */
367# endif /* VDISCARD */
368# ifdef VLNEXT
369# if NUMCC <= VLNEXT
370# undef VLNEXT
371# endif /* NUMCC <= VLNEXT */
372# endif /* VLNEXT */
373# ifdef VSTATUS
374# if NUMCC <= VSTATUS
375# undef VSTATUS
376# endif /* NUMCC <= VSTATUS */
377# endif /* VSTATUS */
378# ifdef VPAGE
379# if NUMCC <= VPAGE
380# undef VPAGE
381# endif /* NUMCC <= VPAGE */
382# endif /* VPAGE */
383# ifdef VPGOFF
384# if NUMCC <= VPGOFF
385# undef VPGOFF
386# endif /* NUMCC <= VPGOFF */
387# endif /* VPGOFF */
388# ifdef VKILL2
389# if NUMCC <= VKILL2
390# undef VKILL2
391# endif /* NUMCC <= VKILL2 */
392# endif /* VKILL2 */
393# ifdef VBRK
394# if NUMCC <= VBRK
395# undef VBRK
396# endif /* NUMCC <= VBRK */
397# endif /* VBRK */
398# ifdef VMIN
399# if NUMCC <= VMIN
400# undef VMIN
401# endif /* NUMCC <= VMIN */
402# endif /* VMIN */
403# ifdef VTIME
404# if NUMCC <= VTIME
405# undef VTIME
406# endif /* NUMCC <= VTIME */
407# endif /* VTIME */
408# endif /* NUMCC */
409#endif /* !POSIX */
410
411#define C_INTR 0
412#define C_QUIT 1
413#define C_ERASE 2
414#define C_KILL 3
415#define C_EOF 4
416#define C_EOL 5
417#define C_EOL2 6
418#define C_SWTCH 7
419#define C_DSWTCH 8
420#define C_ERASE2 9
421#define C_START 10
422#define C_STOP 11
423#define C_WERASE 12
424#define C_SUSP 13
425#define C_DSUSP 14
426#define C_REPRINT 15
427#define C_DISCARD 16
428#define C_LNEXT 17
429#define C_STATUS 18
430#define C_PAGE 19
431#define C_PGOFF 20
432#define C_KILL2 21
433#define C_BRK 22
434#define C_MIN 23
435#define C_TIME 24
436#define C_NCC 25
437#define C_SH(A) (1 << (A))
438
439/*
440 * Terminal dependend data structures
441 */
442#define EX_IO 0 /* while we are executing */
443#define ED_IO 1 /* while we are editing */
444#define TS_IO 2 /* new mode from terminal */
445#define QU_IO 2 /* used only for quoted chars */
446#define NN_IO 3 /* The number of entries */
447
448#define MD_INP 0
449#define MD_OUT 1
450#define MD_CTL 2
451#define MD_LIN 3
452#define MD_CHAR 4
453#define MD_NN 5
454
455typedef struct {
456 char *t_name;
457 u_int t_setmask;
458 u_int t_clrmask;
459} ttyperm_t[NN_IO][MD_NN];
460
461typedef unsigned char ttychar_t[NN_IO][C_NCC];
462
463protected int tty_init(EditLine *);
464protected void tty_end(EditLine *);
465protected int tty_stty(EditLine *, int, char**);
466protected int tty_rawmode(EditLine *);
467protected int tty_cookedmode(EditLine *);
468protected int tty_quotemode(EditLine *);
469protected int tty_noquotemode(EditLine *);
470protected void tty_bind_char(EditLine *, int);
471
472typedef struct {
473 ttyperm_t t_t;
474 ttychar_t t_c;
475 struct termios t_ex, t_ed, t_ts;
476 int t_tabs;
477 int t_eight;
478 speed_t t_speed;
479 int t_mode;
480 unsigned char t_vdisable;
481} el_tty_t;
482
483
484#endif /* _h_el_tty */
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Christos Zoulas of Cornell University.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)tty.h 8.1 (Berkeley) 6/4/93
37 * $NetBSD: tty.h,v 1.7 1999/09/26 14:37:47 lukem Exp $
38 * $FreeBSD: head/lib/libedit/tty.h 84260 2001-10-01 08:41:27Z obrien $
39 */
40
41/*
42 * el.tty.h: Local terminal header
43 */
44#ifndef _h_el_tty
45#define _h_el_tty
46
47#include "histedit.h"
48#include <termios.h>
49#include <unistd.h>
50
51/* Define our own since everyone gets it wrong! */
52#define CONTROL(A) ((A) & 037)
53
54/*
55 * Aix compatible names
56 */
57# if defined(VWERSE) && !defined(VWERASE)
58# define VWERASE VWERSE
59# endif /* VWERSE && !VWERASE */
60
61# if defined(VDISCRD) && !defined(VDISCARD)
62# define VDISCARD VDISCRD
63# endif /* VDISCRD && !VDISCARD */
64
65# if defined(VFLUSHO) && !defined(VDISCARD)
66# define VDISCARD VFLUSHO
67# endif /* VFLUSHO && VDISCARD */
68
69# if defined(VSTRT) && !defined(VSTART)
70# define VSTART VSTRT
71# endif /* VSTRT && ! VSTART */
72
73# if defined(VSTAT) && !defined(VSTATUS)
74# define VSTATUS VSTAT
75# endif /* VSTAT && ! VSTATUS */
76
77# ifndef ONLRET
78# define ONLRET 0
79# endif /* ONLRET */
80
81# ifndef TAB3
82# ifdef OXTABS
83# define TAB3 OXTABS
84# else
85# define TAB3 0
86# endif /* OXTABS */
87# endif /* !TAB3 */
88
89# if defined(OXTABS) && !defined(XTABS)
90# define XTABS OXTABS
91# endif /* OXTABS && !XTABS */
92
93# ifndef ONLCR
94# define ONLCR 0
95# endif /* ONLCR */
96
97# ifndef IEXTEN
98# define IEXTEN 0
99# endif /* IEXTEN */
100
101# ifndef ECHOCTL
102# define ECHOCTL 0
103# endif /* ECHOCTL */
104
105# ifndef PARENB
106# define PARENB 0
107# endif /* PARENB */
108
109# ifndef EXTPROC
110# define EXTPROC 0
111# endif /* EXTPROC */
112
113# ifndef FLUSHO
114# define FLUSHO 0
115# endif /* FLUSHO */
116
117
118# if defined(VDISABLE) && !defined(_POSIX_VDISABLE)
119# define _POSIX_VDISABLE VDISABLE
120# endif /* VDISABLE && ! _POSIX_VDISABLE */
121
122/*
123 * Work around ISC's definition of IEXTEN which is
124 * XCASE!
125 */
126# ifdef ISC
127# if defined(IEXTEN) && defined(XCASE)
128# if IEXTEN == XCASE
129# undef IEXTEN
130# define IEXTEN 0
131# endif /* IEXTEN == XCASE */
132# endif /* IEXTEN && XCASE */
133# if defined(IEXTEN) && !defined(XCASE)
134# define XCASE IEXTEN
135# undef IEXTEN
136# define IEXTEN 0
137# endif /* IEXTEN && !XCASE */
138# endif /* ISC */
139
140/*
141 * Work around convex weirdness where turning off IEXTEN makes us
142 * lose all postprocessing!
143 */
144#if defined(convex) || defined(__convex__)
145# if defined(IEXTEN) && IEXTEN != 0
146# undef IEXTEN
147# define IEXTEN 0
148# endif /* IEXTEN != 0 */
149#endif /* convex || __convex__ */
150
151/*
152 * So that we don't lose job control.
153 */
154#ifdef __SVR4
155# undef CSWTCH
156#endif
157
158#ifndef _POSIX_VDISABLE
159# define _POSIX_VDISABLE ((unsigned char) -1)
160#endif /* _POSIX_VDISABLE */
161
162#if !defined(CREPRINT) && defined(CRPRNT)
163# define CREPRINT CRPRNT
164#endif /* !CREPRINT && CRPRNT */
165#if !defined(CDISCARD) && defined(CFLUSH)
166# define CDISCARD CFLUSH
167#endif /* !CDISCARD && CFLUSH */
168
169#ifndef CINTR
170# define CINTR CONTROL('c')
171#endif /* CINTR */
172#ifndef CQUIT
173# define CQUIT 034 /* ^\ */
174#endif /* CQUIT */
175#ifndef CERASE
176# define CERASE 0177 /* ^? */
177#endif /* CERASE */
178#ifndef CKILL
179# define CKILL CONTROL('u')
180#endif /* CKILL */
181#ifndef CEOF
182# define CEOF CONTROL('d')
183#endif /* CEOF */
184#ifndef CEOL
185# define CEOL _POSIX_VDISABLE
186#endif /* CEOL */
187#ifndef CEOL2
188# define CEOL2 _POSIX_VDISABLE
189#endif /* CEOL2 */
190#ifndef CSWTCH
191# define CSWTCH _POSIX_VDISABLE
192#endif /* CSWTCH */
193#ifndef CDSWTCH
194# define CDSWTCH _POSIX_VDISABLE
195#endif /* CDSWTCH */
196#ifndef CERASE2
197# define CERASE2 _POSIX_VDISABLE
198#endif /* CERASE2 */
199#ifndef CSTART
200# define CSTART CONTROL('q')
201#endif /* CSTART */
202#ifndef CSTOP
203# define CSTOP CONTROL('s')
204#endif /* CSTOP */
205#ifndef CSUSP
206# define CSUSP CONTROL('z')
207#endif /* CSUSP */
208#ifndef CDSUSP
209# define CDSUSP CONTROL('y')
210#endif /* CDSUSP */
211
212#ifdef hpux
213
214# ifndef CREPRINT
215# define CREPRINT _POSIX_VDISABLE
216# endif /* CREPRINT */
217# ifndef CDISCARD
218# define CDISCARD _POSIX_VDISABLE
219# endif /* CDISCARD */
220# ifndef CLNEXT
221# define CLNEXT _POSIX_VDISABLE
222# endif /* CLNEXT */
223# ifndef CWERASE
224# define CWERASE _POSIX_VDISABLE
225# endif /* CWERASE */
226
227#else /* !hpux */
228
229# ifndef CREPRINT
230# define CREPRINT CONTROL('r')
231# endif /* CREPRINT */
232# ifndef CDISCARD
233# define CDISCARD CONTROL('o')
234# endif /* CDISCARD */
235# ifndef CLNEXT
236# define CLNEXT CONTROL('v')
237# endif /* CLNEXT */
238# ifndef CWERASE
239# define CWERASE CONTROL('w')
240# endif /* CWERASE */
241
242#endif /* hpux */
243
244#ifndef CSTATUS
245# define CSTATUS CONTROL('t')
246#endif /* CSTATUS */
247#ifndef CPAGE
248# define CPAGE ' '
249#endif /* CPAGE */
250#ifndef CPGOFF
251# define CPGOFF CONTROL('m')
252#endif /* CPGOFF */
253#ifndef CKILL2
254# define CKILL2 _POSIX_VDISABLE
255#endif /* CKILL2 */
256#ifndef CBRK
257# ifndef masscomp
258# define CBRK 0377
259# else
260# define CBRK '\0'
261# endif /* masscomp */
262#endif /* CBRK */
263#ifndef CMIN
264# define CMIN CEOF
265#endif /* CMIN */
266#ifndef CTIME
267# define CTIME CEOL
268#endif /* CTIME */
269
270/*
271 * Fix for sun inconsistency. On termio VSUSP and the rest of the
272 * ttychars > NCC are defined. So we undefine them.
273 */
274#if defined(TERMIO) || defined(POSIX)
275# if defined(POSIX) && defined(NCCS)
276# define NUMCC NCCS
277# else
278# ifdef NCC
279# define NUMCC NCC
280# endif /* NCC */
281# endif /* POSIX && NCCS */
282# ifdef NUMCC
283# ifdef VINTR
284# if NUMCC <= VINTR
285# undef VINTR
286# endif /* NUMCC <= VINTR */
287# endif /* VINTR */
288# ifdef VQUIT
289# if NUMCC <= VQUIT
290# undef VQUIT
291# endif /* NUMCC <= VQUIT */
292# endif /* VQUIT */
293# ifdef VERASE
294# if NUMCC <= VERASE
295# undef VERASE
296# endif /* NUMCC <= VERASE */
297# endif /* VERASE */
298# ifdef VKILL
299# if NUMCC <= VKILL
300# undef VKILL
301# endif /* NUMCC <= VKILL */
302# endif /* VKILL */
303# ifdef VEOF
304# if NUMCC <= VEOF
305# undef VEOF
306# endif /* NUMCC <= VEOF */
307# endif /* VEOF */
308# ifdef VEOL
309# if NUMCC <= VEOL
310# undef VEOL
311# endif /* NUMCC <= VEOL */
312# endif /* VEOL */
313# ifdef VEOL2
314# if NUMCC <= VEOL2
315# undef VEOL2
316# endif /* NUMCC <= VEOL2 */
317# endif /* VEOL2 */
318# ifdef VSWTCH
319# if NUMCC <= VSWTCH
320# undef VSWTCH
321# endif /* NUMCC <= VSWTCH */
322# endif /* VSWTCH */
323# ifdef VDSWTCH
324# if NUMCC <= VDSWTCH
325# undef VDSWTCH
326# endif /* NUMCC <= VDSWTCH */
327# endif /* VDSWTCH */
328# ifdef VERASE2
329# if NUMCC <= VERASE2
330# undef VERASE2
331# endif /* NUMCC <= VERASE2 */
332# endif /* VERASE2 */
333# ifdef VSTART
334# if NUMCC <= VSTART
335# undef VSTART
336# endif /* NUMCC <= VSTART */
337# endif /* VSTART */
338# ifdef VSTOP
339# if NUMCC <= VSTOP
340# undef VSTOP
341# endif /* NUMCC <= VSTOP */
342# endif /* VSTOP */
343# ifdef VWERASE
344# if NUMCC <= VWERASE
345# undef VWERASE
346# endif /* NUMCC <= VWERASE */
347# endif /* VWERASE */
348# ifdef VSUSP
349# if NUMCC <= VSUSP
350# undef VSUSP
351# endif /* NUMCC <= VSUSP */
352# endif /* VSUSP */
353# ifdef VDSUSP
354# if NUMCC <= VDSUSP
355# undef VDSUSP
356# endif /* NUMCC <= VDSUSP */
357# endif /* VDSUSP */
358# ifdef VREPRINT
359# if NUMCC <= VREPRINT
360# undef VREPRINT
361# endif /* NUMCC <= VREPRINT */
362# endif /* VREPRINT */
363# ifdef VDISCARD
364# if NUMCC <= VDISCARD
365# undef VDISCARD
366# endif /* NUMCC <= VDISCARD */
367# endif /* VDISCARD */
368# ifdef VLNEXT
369# if NUMCC <= VLNEXT
370# undef VLNEXT
371# endif /* NUMCC <= VLNEXT */
372# endif /* VLNEXT */
373# ifdef VSTATUS
374# if NUMCC <= VSTATUS
375# undef VSTATUS
376# endif /* NUMCC <= VSTATUS */
377# endif /* VSTATUS */
378# ifdef VPAGE
379# if NUMCC <= VPAGE
380# undef VPAGE
381# endif /* NUMCC <= VPAGE */
382# endif /* VPAGE */
383# ifdef VPGOFF
384# if NUMCC <= VPGOFF
385# undef VPGOFF
386# endif /* NUMCC <= VPGOFF */
387# endif /* VPGOFF */
388# ifdef VKILL2
389# if NUMCC <= VKILL2
390# undef VKILL2
391# endif /* NUMCC <= VKILL2 */
392# endif /* VKILL2 */
393# ifdef VBRK
394# if NUMCC <= VBRK
395# undef VBRK
396# endif /* NUMCC <= VBRK */
397# endif /* VBRK */
398# ifdef VMIN
399# if NUMCC <= VMIN
400# undef VMIN
401# endif /* NUMCC <= VMIN */
402# endif /* VMIN */
403# ifdef VTIME
404# if NUMCC <= VTIME
405# undef VTIME
406# endif /* NUMCC <= VTIME */
407# endif /* VTIME */
408# endif /* NUMCC */
409#endif /* !POSIX */
410
411#define C_INTR 0
412#define C_QUIT 1
413#define C_ERASE 2
414#define C_KILL 3
415#define C_EOF 4
416#define C_EOL 5
417#define C_EOL2 6
418#define C_SWTCH 7
419#define C_DSWTCH 8
420#define C_ERASE2 9
421#define C_START 10
422#define C_STOP 11
423#define C_WERASE 12
424#define C_SUSP 13
425#define C_DSUSP 14
426#define C_REPRINT 15
427#define C_DISCARD 16
428#define C_LNEXT 17
429#define C_STATUS 18
430#define C_PAGE 19
431#define C_PGOFF 20
432#define C_KILL2 21
433#define C_BRK 22
434#define C_MIN 23
435#define C_TIME 24
436#define C_NCC 25
437#define C_SH(A) (1 << (A))
438
439/*
440 * Terminal dependend data structures
441 */
442#define EX_IO 0 /* while we are executing */
443#define ED_IO 1 /* while we are editing */
444#define TS_IO 2 /* new mode from terminal */
445#define QU_IO 2 /* used only for quoted chars */
446#define NN_IO 3 /* The number of entries */
447
448#define MD_INP 0
449#define MD_OUT 1
450#define MD_CTL 2
451#define MD_LIN 3
452#define MD_CHAR 4
453#define MD_NN 5
454
455typedef struct {
456 char *t_name;
457 u_int t_setmask;
458 u_int t_clrmask;
459} ttyperm_t[NN_IO][MD_NN];
460
461typedef unsigned char ttychar_t[NN_IO][C_NCC];
462
463protected int tty_init(EditLine *);
464protected void tty_end(EditLine *);
465protected int tty_stty(EditLine *, int, char**);
466protected int tty_rawmode(EditLine *);
467protected int tty_cookedmode(EditLine *);
468protected int tty_quotemode(EditLine *);
469protected int tty_noquotemode(EditLine *);
470protected void tty_bind_char(EditLine *, int);
471
472typedef struct {
473 ttyperm_t t_t;
474 ttychar_t t_c;
475 struct termios t_ex, t_ed, t_ts;
476 int t_tabs;
477 int t_eight;
478 speed_t t_speed;
479 int t_mode;
480 unsigned char t_vdisable;
481} el_tty_t;
482
483
484#endif /* _h_el_tty */