1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright (c) 1995, by Sun Microsystems, Inc.
24 * All rights reserved.
25 */
26
27 /*
28 * cbreak.c
29 *
30 * XCurses Library
31 *
32 * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved.
33 *
34 */
35
36 #if M_RCSID
37 #ifndef lint
38 static char rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/cbreak.c 1.2 1995/06/19 16:11:50 ant Exp $";
39 #endif
40 #endif
41
42 #include <private.h>
43
44 int
cbreak()45 cbreak()
46 {
47 #ifdef M_CURSES_TRACE
48 __m_trace("cbreak(void)");
49 #endif
50
51 cur_term->_flags &= ~__TERM_HALF_DELAY;
52
53 cur_term->_prog.c_cc[VMIN] = 1;
54 cur_term->_prog.c_cc[VTIME] = 0;
55 cur_term->_prog.c_lflag &= ~ICANON;
56
57 return __m_return_code("cbreak", __m_tty_set(&cur_term->_prog));
58 }
59
60 int
nocbreak()61 nocbreak()
62 {
63 #ifdef M_CURSES_TRACE
64 __m_trace("nocbreak(void)");
65 #endif
66
67 cur_term->_flags &= ~__TERM_HALF_DELAY;
68
69 /* On some systems VMIN and VTIME map to VEOF and VEOL, which
70 * means we have to restore them to their original settings.
71 */
72 cur_term->_prog.c_cc[VEOF] = cur_term->_shell.c_cc[VEOF];
73 cur_term->_prog.c_cc[VEOL] = cur_term->_shell.c_cc[VEOL];
74 cur_term->_prog.c_lflag |= ICANON;
75
76 return __m_return_code("nocbreak", __m_tty_set(&cur_term->_prog));
77 }
78
79 /*
80 * Set global timeout value, which overrides individual window timeout
81 * values (I think believe X/Open specified this wrong).
82 */
83 int
halfdelay(tenths)84 halfdelay(tenths)
85 int tenths;
86 {
87 #ifdef M_CURSES_TRACE
88 __m_trace("halfdelay(%d)", tenths);
89 #endif
90
91 cur_term->_flags |= __TERM_HALF_DELAY;
92
93 cur_term->_prog.c_cc[VMIN] = 0;
94 cur_term->_prog.c_cc[VTIME] = tenths;
95 cur_term->_prog.c_lflag &= ~ICANON;
96
97 return __m_return_code("halfdelay", __m_tty_set(&cur_term->_prog));
98 }
99
100 int
raw()101 raw()
102 {
103 #ifdef M_CURSES_TRACE
104 __m_trace("raw(void)");
105 #endif
106
107 cur_term->_flags &= ~__TERM_HALF_DELAY;
108
109 cur_term->_prog.c_cc[VMIN] = 1;
110 cur_term->_prog.c_cc[VTIME] = 0;
111 cur_term->_prog.c_lflag &= ~(ICANON | ISIG | IXON);
112
113 return __m_return_code("raw", __m_tty_set(&cur_term->_prog));
114 }
115
116 int
noraw()117 noraw()
118 {
119 #ifdef M_CURSES_TRACE
120 __m_trace("noraw(void)");
121 #endif
122
123 cur_term->_flags &= ~__TERM_HALF_DELAY;
124
125 /* On some systems VMIN and VTIME map to VEOF and VEOL, which
126 * means we have to restore them to their original settings.
127 */
128 cur_term->_prog.c_cc[VEOF] = cur_term->_shell.c_cc[VEOF];
129 cur_term->_prog.c_cc[VEOL] = cur_term->_shell.c_cc[VEOL];
130 cur_term->_prog.c_lflag |= ICANON | ISIG | IXON;
131
132 return __m_return_code("noraw", __m_tty_set(&cur_term->_prog));
133 }
134
135