1 /****************************************************************************
2 * Copyright (c) 1998-2005,2006 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 * and: Thomas E. Dickey 1996-on *
33 ****************************************************************************/
38 ** The routines to handle option setting.
42 #include <curses.priv.h>
46 MODULE_ID("$Id: lib_options.c,v 1.50 2006/12/30 16:03:27 tom Exp $")
49 idlok(WINDOW *win, bool flag)
51 T((T_CALLED("idlok(%p,%d)"), win, flag));
54 _nc_idlok = win->_idlok = (flag && (has_il() || change_scroll_region));
61 idcok(WINDOW *win, bool flag)
63 T((T_CALLED("idcok(%p,%d)"), win, flag));
66 _nc_idcok = win->_idcok = (flag && has_ic());
74 T((T_CALLED("halfdelay(%d)"), t));
76 if (t < 1 || t > 255 || SP == 0)
85 nodelay(WINDOW *win, bool flag)
87 T((T_CALLED("nodelay(%p,%d)"), win, flag));
100 notimeout(WINDOW *win, bool f)
102 T((T_CALLED("notimeout(%p,%d)"), win, f));
112 wtimeout(WINDOW *win, int delay)
114 T((T_CALLED("wtimeout(%p,%d)"), win, delay));
123 keypad(WINDOW *win, bool flag)
125 T((T_CALLED("keypad(%p,%d)"), win, flag));
128 win->_use_keypad = flag;
129 returnCode(_nc_keypad(flag));
135 meta(WINDOW *win GCC_UNUSED, bool flag)
139 /* Ok, we stay relaxed and don't signal an error if win is NULL */
140 T((T_CALLED("meta(%p,%d)"), win, flag));
143 SP->_use_meta = flag;
145 if (flag && meta_on) {
146 TPUTS_TRACE("meta_on");
148 } else if (!flag && meta_off) {
149 TPUTS_TRACE("meta_off");
157 /* curs_set() moved here to narrow the kernel interface */
164 T((T_CALLED("curs_set(%d)"), vis));
165 if (SP != 0 && vis >= 0 && vis <= 2) {
166 int cursor = SP->_cursor;
171 result = (cursor == -1 ? 1 : cursor);
174 if (cursor_visible) {
175 TPUTS_TRACE("cursor_visible");
176 putp(cursor_visible);
182 TPUTS_TRACE("cursor_normal");
188 if (cursor_invisible) {
189 TPUTS_TRACE("cursor_invisible");
190 putp(cursor_invisible);
205 T((T_CALLED("typeahead(%d)"), fd));
217 ** Return TRUE if the current terminal has the given key
221 #if NCURSES_EXT_FUNCS
223 has_key_internal(int keycode, TRIES *tp)
227 else if (tp->value == keycode)
230 return (has_key_internal(keycode, tp->child)
231 || has_key_internal(keycode, tp->sibling));
237 T((T_CALLED("has_key(%d)"), keycode));
238 returnCode(SP != 0 ? has_key_internal(keycode, SP->_keytry) : FALSE);
240 #endif /* NCURSES_EXT_FUNCS */
242 /* Turn the keypad on/off
244 * Note: we flush the output because changing this mode causes some terminals
245 * to emit different escape sequences for cursor and keypad keys. If we don't
246 * flush, then the next wgetch may get the escape sequence that corresponds to
247 * the terminal state _before_ switching modes.
250 _nc_keypad(bool flag)
252 if (flag && keypad_xmit) {
253 TPUTS_TRACE("keypad_xmit");
256 } else if (!flag && keypad_local) {
257 TPUTS_TRACE("keypad_local");
263 if (flag && !SP->_tried) {
267 SP->_keypad_on = flag;