1 /****************************************************************************
2 * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
31 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
32 ****************************************************************************/
34 /* $FreeBSD: src/contrib/ncurses/ncurses/tinfo/lib_raw.c,v 1.2.2.2 2000/10/12 18:40:51 peter Exp $ */
50 #include <curses.priv.h>
51 #include <term.h> /* cur_term */
53 MODULE_ID("$Id: lib_raw.c,v 1.8 2000/09/02 18:08:48 tom Exp $")
55 #if SVR4_TERMIO && !defined(_POSIX_SOURCE)
60 #include <sys/termio.h> /* needed for ISC */
67 #define COOKED_INPUT (IXON|BRKINT|PARMRK)
70 #define BEFORE(N) if (_nc_tracing&TRACE_BITS) _tracef("%s before bits: %s", N, _nc_tracebits())
71 #define AFTER(N) if (_nc_tracing&TRACE_BITS) _tracef("%s after bits: %s", N, _nc_tracebits())
80 T((T_CALLED("raw()")));
81 if (SP != 0 && cur_term != 0) {
87 setmode(SP->_ifd, O_BINARY);
92 cur_term->Nttyb.c_lflag &= ~(ICANON | ISIG | IEXTEN);
93 cur_term->Nttyb.c_iflag &= ~(COOKED_INPUT);
94 cur_term->Nttyb.c_cc[VMIN] = 1;
95 cur_term->Nttyb.c_cc[VTIME] = 0;
98 cur_term->Nttyb.sg_flags |= RAW;
100 returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
108 T((T_CALLED("cbreak()")));
113 setmode(SP->_ifd, O_BINARY);
118 cur_term->Nttyb.c_lflag &= ~ICANON;
119 cur_term->Nttyb.c_iflag &= ~ICRNL;
120 cur_term->Nttyb.c_lflag |= ISIG;
121 cur_term->Nttyb.c_cc[VMIN] = 1;
122 cur_term->Nttyb.c_cc[VTIME] = 0;
125 cur_term->Nttyb.sg_flags |= CBREAK;
127 returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
133 T((T_CALLED("qiflush()")));
136 * Note: this implementation may be wrong. See the comment under
142 cur_term->Nttyb.c_lflag &= ~(NOFLSH);
144 (void) _nc_set_tty_mode(&cur_term->Nttyb);
152 T((T_CALLED("noraw()")));
158 setmode(SP->_ifd, O_TEXT);
163 cur_term->Nttyb.c_lflag |= ISIG | ICANON |
164 (cur_term->Ottyb.c_lflag & IEXTEN);
165 cur_term->Nttyb.c_iflag |= COOKED_INPUT;
168 cur_term->Nttyb.sg_flags &= ~(RAW | CBREAK);
170 returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
176 T((T_CALLED("nocbreak()")));
181 setmode(SP->_ifd, O_TEXT);
186 cur_term->Nttyb.c_lflag |= ICANON;
187 cur_term->Nttyb.c_iflag |= ICRNL;
190 cur_term->Nttyb.sg_flags &= ~CBREAK;
192 returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
198 T((T_CALLED("noqiflush()")));
201 * Note: this implementation may be wrong. See the comment under
207 cur_term->Nttyb.c_lflag |= NOFLSH;
209 (void) _nc_set_tty_mode(&cur_term->Nttyb);
215 intrflush(WINDOW *win GCC_UNUSED, bool flag)
217 T((T_CALLED("intrflush(%d)"), flag));
220 * This call does the same thing as the qiflush()/noqiflush() pair. We
221 * know for certain that SVr3 intrflush() tweaks the NOFLSH bit; on the
222 * other hand, the match (in the SVr4 man pages) between the language
223 * describing NOFLSH in termio(7) and the language describing
224 * qiflush()/noqiflush() in curs_inopts(3x) is too exact to be coincidence.
230 cur_term->Nttyb.c_lflag &= ~(NOFLSH);
232 cur_term->Nttyb.c_lflag |= (NOFLSH);
234 returnCode(_nc_set_tty_mode(&cur_term->Nttyb));