Add ncurses 5.4 source code.
[dragonfly.git] / contrib / ncurses-5.4 / man / curs_inopts.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2002,2003 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 .\" $Id: curs_inopts.3x,v 1.11 2003/12/27 18:45:42 tom Exp $
30 .TH curs_inopts 3X ""
31 .SH NAME
32 \fBcbreak\fR, \fBnocbreak\fR, \fBecho\fR,
33 \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR, \fBkeypad\fR,
34 \fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBraw\fR, \fBnoraw\fR,
35 \fBnoqiflush\fR, \fBqiflush\fR, \fBtimeout\fR, \fBwtimeout\fR,
36 \fBtypeahead\fR - \fBcurses\fR input options
37 .SH SYNOPSIS
38 \fB#include <curses.h>\fR
39 .PP
40 \fBint cbreak(void);\fR
41 .br
42 \fBint nocbreak(void);\fR
43 .br
44 \fBint echo(void);\fR
45 .br
46 \fBint noecho(void);\fR
47 .br
48 \fBint halfdelay(int tenths);\fR
49 .br
50 \fBint intrflush(WINDOW *win, bool bf);\fR
51 .br
52 \fBint keypad(WINDOW *win, bool bf);\fR
53 .br
54 \fBint meta(WINDOW *win, bool bf);\fR
55 .br
56 \fBint nodelay(WINDOW *win, bool bf);\fR
57 .br
58 \fBint raw(void);\fR
59 .br
60 \fBint noraw(void);\fR
61 .br
62 \fBvoid noqiflush(void);\fR
63 .br
64 \fBvoid qiflush(void);\fR
65 .br
66 \fBint notimeout(WINDOW *win, bool bf);\fR
67 .br
68 \fBvoid timeout(int delay);\fR
69 .br
70 \fBvoid wtimeout(WINDOW *win, int delay);\fR
71 .br
72 \fBint typeahead(int fd);\fR
73 .br
74 .SH DESCRIPTION
75 Normally, the tty driver buffers typed characters until a newline or carriage
76 return is typed.  The \fBcbreak\fR routine disables line buffering and
77 erase/kill character-processing (interrupt and flow control characters are
78 unaffected), making characters typed by the user immediately available to the
79 program.  The \fBnocbreak\fR routine returns the terminal to normal (cooked)
80 mode.
81 .PP
82 Initially the terminal may or may not be in \fBcbreak\fR mode, as the mode is
83 inherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fR
84 explicitly.  Most interactive programs using \fBcurses\fR set the \fBcbreak\fR
85 mode.  Note that \fBcbreak\fR overrides \fBraw\fR.
86 [See \fBcurs_getch\fR(3X) for a
87 discussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.]
88 .PP
89 The \fBecho\fR and \fBnoecho\fR routines control whether characters typed by
90 the user are echoed by \fBgetch\fR as they are typed.  Echoing by the tty
91 driver is always disabled, but initially \fBgetch\fR is in echo mode, so
92 characters typed are echoed.  Authors of most interactive programs prefer to do
93 their own echoing in a controlled area of the screen, or not to echo at all, so
94 they disable echoing by calling \fBnoecho\fR.
95 [See \fBcurs_getch\fR(3X) for a
96 discussion of how these routines interact with \fBcbreak\fR and
97 \fBnocbreak\fR.]
98 .PP
99 The \fBhalfdelay\fR routine is used for half-delay mode, which is similar to
100 \fBcbreak\fR mode in that characters typed by the user are immediately
101 available to the program.  However, after blocking for \fItenths\fR tenths of
102 seconds, ERR is returned if nothing has been typed.  The value of \fBtenths\fR
103 must be a number between 1 and 255.  Use \fBnocbreak\fR to leave half-delay
104 mode.
105 .PP
106 If the \fBintrflush\fR option is enabled, (\fIbf\fR is \fBTRUE\fR), when an
107 interrupt key is pressed on the keyboard (interrupt, break, quit) all output in
108 the tty driver queue will be flushed, giving the effect of faster response to
109 the interrupt, but causing \fBcurses\fR to have the wrong idea of what is on
110 the screen.  Disabling (\fIbf\fR is \fBFALSE\fR), the option prevents the
111 flush.  The default for the option is inherited from the tty driver settings.
112 The window argument is ignored.
113 .PP
114 The \fBkeypad\fR option enables the keypad of the user's terminal.  If
115 enabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key
116 (such as an arrow key) and \fBwgetch\fR returns a single value
117 representing the function key, as in \fBKEY_LEFT\fR.  If disabled
118 (\fIbf\fR is \fBFALSE\fR), \fBcurses\fR does not treat function keys
119 specially and the program has to interpret the escape sequences
120 itself.  If the keypad in the terminal can be turned on (made to
121 transmit) and off (made to work locally), turning on this option
122 causes the terminal keypad to be turned on when \fBwgetch\fR is
123 called.  The default value for keypad is false.
124 .PP
125 Initially, whether the terminal returns 7 or 8 significant bits on
126 input depends on the control mode of the tty driver [see termio(7)].
127 To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR,
128 \fBTRUE\fR); this is equivalent, under POSIX, to setting the CS8 flag
129 on the terminal.  To force 7 bits to be returned, invoke
130 \fBmeta\fR(\fIwin\fR, \fBFALSE\fR); this is equivalent, under POSIX,
131 to setting the CS7 flag on the terminal.  The window argument,
132 \fIwin\fR, is always ignored.  If the terminfo capabilities \fBsmm\fR
133 (meta_on) and \fBrmm\fR (meta_off) are defined for the terminal,
134 \fBsmm\fR is sent to the terminal when \fBmeta\fR(\fIwin\fR,
135 \fBTRUE\fR) is called and \fBrmm\fR is sent when \fBmeta\fR(\fIwin\fR,
136 \fBFALSE\fR) is called.
137 .PP
138 The \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call.
139 If no input is ready, \fBgetch\fR returns \fBERR\fR.  If disabled
140 (\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed.
141 .PP
142 While interpreting an input escape sequence, \fBwgetch\fR sets a timer
143 while waiting for the next character.  If \fBnotimeout(\fR\fIwin\fR,
144 \fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer.  The
145 purpose of the timeout is to differentiate between sequences received
146 from a function key and those typed by a user.
147 .PP
148 The \fBraw\fR and \fBnoraw\fR routines place the terminal into or out of raw
149 mode.  Raw mode is similar to \fBcbreak\fR mode, in that characters typed are
150 immediately passed through to the user program.  The differences are that in
151 raw mode, the interrupt, quit, suspend, and flow control characters are all
152 passed through uninterpreted, instead of generating a signal.  The behavior of
153 the BREAK key depends on other bits in the tty driver that are not set by
154 \fBcurses\fR.
155 .PP
156 When the \fBnoqiflush\fR routine is used, normal flush of input and
157 output queues associated with the \fBINTR\fR, \fBQUIT\fR and
158 \fBSUSP\fR characters will not be done [see termio(7)].  When
159 \fBqiflush\fR is called, the queues will be flushed when these control
160 characters are read.  You may want to call \fBnoqiflush()\fR in a signal
161 handler if you want output to continue as though the interrupt
162 had not occurred, after the handler exits.
163 .PP
164 The \fBtimeout\fR and \fBwtimeout\fR routines set blocking or
165 non-blocking read for a given window.  If \fIdelay\fR is negative,
166 blocking read is used (i.e., waits indefinitely for
167 input).  If \fIdelay\fR is zero, then non-blocking read is used
168 (i.e., read returns \fBERR\fR if no input is waiting).  If
169 \fIdelay\fR is positive, then read blocks for \fIdelay\fR
170 milliseconds, and returns \fBERR\fR if there is still no input.
171 Hence, these routines provide the same functionality as \fBnodelay\fR,
172 plus the additional capability of being able to block for only
173 \fIdelay\fR milliseconds (where \fIdelay\fR is positive).
174 .PP
175 The \fBcurses\fR library does ``line-breakout optimization'' by looking for
176 typeahead periodically while updating the screen.  If input is found,
177 and it is coming from a tty, the current update is postponed until
178 \fBrefresh\fR or \fBdoupdate\fR is called again.  This allows faster
179 response to commands typed in advance.  Normally, the input FILE
180 pointer passed to \fBnewterm\fR, or \fBstdin\fR in the case that
181 \fBinitscr\fR was used, will be used to do this typeahead checking.
182 The \fBtypeahead\fR routine specifies that the file descriptor
183 \fIfd\fR is to be used to check for typeahead instead.  If \fIfd\fR is
184 -1, then no typeahead checking is done.
185 .SH RETURN VALUE
186 All routines that return an integer return \fBERR\fR upon failure and OK (SVr4
187 specifies only "an integer value other than \fBERR\fR") upon successful
188 completion, unless otherwise noted in the preceding routine descriptions.
189 .SH PORTABILITY
190 These functions are described in the XSI Curses standard, Issue 4.
191 .PP
192 The ncurses library obeys the XPG4 standard and the historical practice of the
193 AT&T curses implementations, in that the echo bit is cleared when curses
194 initializes the terminal state.  BSD curses differed from this slightly; it
195 left the echo bit on at initialization, but the BSD \fBraw\fR call turned it
196 off as a side-effect.  For best portability, set echo or noecho explicitly
197 just after initialization, even if your program remains in cooked mode.
198 .SH NOTES
199 Note that \fBecho\fR, \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR,
200 \fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBnoqiflush\fR,
201 \fBqiflush\fR, \fBtimeout\fR, and \fBwtimeout\fR may be macros.
202 .PP
203 The \fBnoraw\fR and \fBnocbreak\fR calls follow historical practice in that
204 they attempt to restore to normal (`cooked') mode from raw and cbreak modes
205 respectively.  Mixing raw/noraw and cbreak/nocbreak calls leads to tty driver
206 control states that are hard to predict or understand; it is not recommended.
207 .SH SEE ALSO
208 \fBcurses\fR(3X), \fBcurs_getch\fR(3X), \fBcurs_initscr\fR(3X), \fBtermio\fR(7)
209 .\"#
210 .\"# The following sets edit modes for GNU EMACS
211 .\"# Local Variables:
212 .\"# mode:nroff
213 .\"# fill-column:79
214 .\"# End: