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 ****************************************************************************/
38 #include <curses.priv.h>
39 #include <term.h> /* cur_term */
41 MODULE_ID("$Id: lib_ttyflags.c,v 1.14 2006/12/30 21:37:20 tom Exp $")
44 _nc_get_tty_mode(TTY * buf)
52 if (GET_TTY(cur_term->Filedes, buf) != 0) {
62 memset(buf, 0, sizeof(*buf));
64 TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
65 cur_term->Filedes, _nc_trace_ttymode(buf)));
70 _nc_set_tty_mode(TTY * buf)
78 if (SET_TTY(cur_term->Filedes, buf) != 0) {
81 if ((errno == ENOTTY) && (SP != 0))
88 TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
89 cur_term->Filedes, _nc_trace_ttymode(buf)));
96 T((T_CALLED("def_shell_mode()")));
99 * If XTABS was on, remove the tab and backtab capabilities.
102 if (_nc_get_tty_mode(&cur_term->Ottyb) != OK)
105 if (cur_term->Ottyb.c_oflag & OFLAGS_TABS)
106 tab = back_tab = NULL;
108 if (cur_term->Ottyb.sg_flags & XTABS)
109 tab = back_tab = NULL;
117 T((T_CALLED("def_prog_mode()")));
120 * Turn off the XTABS bit in the tty structure if it was on.
123 if (_nc_get_tty_mode(&cur_term->Nttyb) != OK)
126 cur_term->Nttyb.c_oflag &= ~OFLAGS_TABS;
128 cur_term->Nttyb.sg_flags &= ~XTABS;
134 reset_prog_mode(void)
136 T((T_CALLED("reset_prog_mode()")));
139 if (_nc_set_tty_mode(&cur_term->Nttyb) == OK) {
152 reset_shell_mode(void)
154 T((T_CALLED("reset_shell_mode()")));
162 returnCode(_nc_set_tty_mode(&cur_term->Ottyb));
168 ** savetty() and resetty()
175 T((T_CALLED("savetty()")));
177 returnCode(_nc_get_tty_mode(&(SP->_saved_tty)));
183 T((T_CALLED("resetty()")));
185 returnCode(_nc_set_tty_mode(&(SP->_saved_tty)));