]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ncurses/ncurses/tinfo/lib_ttyflags.c
This commit was generated by cvs2svn to compensate for changes in r163976,
[FreeBSD/FreeBSD.git] / contrib / ncurses / ncurses / tinfo / lib_ttyflags.c
1 /****************************************************************************
2  * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
3  *                                                                          *
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:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
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.                               *
22  *                                                                          *
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       *
26  * authorization.                                                           *
27  ****************************************************************************/
28
29 /*
30  *              def_prog_mode()
31  *              def_shell_mode()
32  *              reset_prog_mode()
33  *              reset_shell_mode()
34  *              savetty()
35  *              resetty()
36  */
37
38 #include <curses.priv.h>
39 #include <term.h>               /* cur_term */
40
41 MODULE_ID("$Id: lib_ttyflags.c,v 1.7 2002/05/25 14:50:00 tom Exp $")
42
43 #undef tabs
44
45 #ifdef TAB3
46 # define tabs TAB3
47 #else
48 # ifdef XTABS
49 #  define tabs XTABS
50 # else
51 #  ifdef OXTABS
52 #   define tabs OXTABS
53 #  else
54 #   define tabs 0
55 #  endif
56 # endif
57 #endif
58
59 NCURSES_EXPORT(int)
60 _nc_get_tty_mode(TTY * buf)
61 {
62     if (cur_term == 0
63         || GET_TTY(cur_term->Filedes, buf) != 0)
64         return (ERR);
65     TR(TRACE_BITS, ("_nc_get_tty_mode: %s", _nc_trace_ttymode(buf)));
66     return (OK);
67 }
68
69 NCURSES_EXPORT(int)
70 _nc_set_tty_mode(TTY * buf)
71 {
72     if (cur_term == 0
73         || SET_TTY(cur_term->Filedes, buf) != 0)
74         return (ERR);
75     TR(TRACE_BITS, ("_nc_set_tty_mode: %s", _nc_trace_ttymode(buf)));
76     return (OK);
77 }
78
79 NCURSES_EXPORT(int)
80 def_shell_mode(void)
81 {
82     T((T_CALLED("def_shell_mode()")));
83
84     /*
85      * Turn off the XTABS bit in the tty structure if it was on.  If XTABS
86      * was on, remove the tab and backtab capabilities.
87      */
88
89     if (_nc_get_tty_mode(&cur_term->Ottyb) != OK)
90         returnCode(ERR);
91 #ifdef TERMIOS
92     if (cur_term->Ottyb.c_oflag & tabs)
93         tab = back_tab = NULL;
94 #else
95     if (cur_term->Ottyb.sg_flags & XTABS)
96         tab = back_tab = NULL;
97 #endif
98     returnCode(OK);
99 }
100
101 NCURSES_EXPORT(int)
102 def_prog_mode(void)
103 {
104     T((T_CALLED("def_prog_mode()")));
105
106     if (_nc_get_tty_mode(&cur_term->Nttyb) != OK)
107         returnCode(ERR);
108 #ifdef TERMIOS
109     cur_term->Nttyb.c_oflag &= ~tabs;
110 #else
111     cur_term->Nttyb.sg_flags &= ~XTABS;
112 #endif
113     returnCode(OK);
114 }
115
116 NCURSES_EXPORT(int)
117 reset_prog_mode(void)
118 {
119     T((T_CALLED("reset_prog_mode()")));
120
121     if (cur_term != 0) {
122         _nc_set_tty_mode(&cur_term->Nttyb);
123         if (SP) {
124             if (SP->_keypad_on)
125                 _nc_keypad(TRUE);
126             NC_BUFFERED(TRUE);
127         }
128         returnCode(OK);
129     }
130     returnCode(ERR);
131 }
132
133 NCURSES_EXPORT(int)
134 reset_shell_mode(void)
135 {
136     T((T_CALLED("reset_shell_mode()")));
137
138     if (cur_term != 0) {
139         if (SP) {
140             _nc_keypad(FALSE);
141             _nc_flush();
142             NC_BUFFERED(FALSE);
143         }
144         returnCode(_nc_set_tty_mode(&cur_term->Ottyb));
145     }
146     returnCode(ERR);
147 }
148
149 /*
150 **      savetty()  and  resetty()
151 **
152 */
153
154 static TTY buf;
155
156 NCURSES_EXPORT(int)
157 savetty(void)
158 {
159     T((T_CALLED("savetty()")));
160
161     returnCode(_nc_get_tty_mode(&buf));
162 }
163
164 NCURSES_EXPORT(int)
165 resetty(void)
166 {
167     T((T_CALLED("resetty()")));
168
169     returnCode(_nc_set_tty_mode(&buf));
170 }