]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_inopts.3x
ncurses 5.9 - patch 20140906
[ncurses.git] / man / curs_inopts.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2012,2013 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.18 2013/07/20 19:42:02 tom Exp $
30 .TH curs_inopts 3X ""
31 .ie \n(.g .ds `` \(lq
32 .el       .ds `` ``
33 .ie \n(.g .ds '' \(rq
34 .el       .ds '' ''
35 .na
36 .hy 0
37 .SH NAME
38 \fBcbreak\fR,
39 \fBnocbreak\fR,
40 \fBecho\fR,
41 \fBnoecho\fR,
42 \fBhalfdelay\fR,
43 \fBintrflush\fR,
44 \fBkeypad\fR,
45 \fBmeta\fR,
46 \fBnodelay\fR,
47 \fBnotimeout\fR,
48 \fBraw\fR,
49 \fBnoraw\fR,
50 \fBnoqiflush\fR,
51 \fBqiflush\fR,
52 \fBtimeout\fR,
53 \fBwtimeout\fR,
54 \fBtypeahead\fR \- \fBcurses\fR input options
55 .ad
56 .hy
57 .SH SYNOPSIS
58 \fB#include <curses.h>\fR
59 .PP
60 \fBint cbreak(void);\fR
61 .br
62 \fBint nocbreak(void);\fR
63 .br
64 \fBint echo(void);\fR
65 .br
66 \fBint noecho(void);\fR
67 .br
68 \fBint halfdelay(int tenths);\fR
69 .br
70 \fBint intrflush(WINDOW *win, bool bf);\fR
71 .br
72 \fBint keypad(WINDOW *win, bool bf);\fR
73 .br
74 \fBint meta(WINDOW *win, bool bf);\fR
75 .br
76 \fBint nodelay(WINDOW *win, bool bf);\fR
77 .br
78 \fBint raw(void);\fR
79 .br
80 \fBint noraw(void);\fR
81 .br
82 \fBvoid noqiflush(void);\fR
83 .br
84 \fBvoid qiflush(void);\fR
85 .br
86 \fBint notimeout(WINDOW *win, bool bf);\fR
87 .br
88 \fBvoid timeout(int delay);\fR
89 .br
90 \fBvoid wtimeout(WINDOW *win, int delay);\fR
91 .br
92 \fBint typeahead(int fd);\fR
93 .br
94 .SH DESCRIPTION
95 Normally, the tty driver buffers typed characters until a newline or carriage
96 return is typed.  The \fBcbreak\fR routine disables line buffering and
97 erase/kill character-processing (interrupt and flow control characters are
98 unaffected), making characters typed by the user immediately available to the
99 program.  The \fBnocbreak\fR routine returns the terminal to normal (cooked)
100 mode.
101 .PP
102 Initially the terminal may or may not be in \fBcbreak\fR mode, as the mode is
103 inherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fR
104 explicitly.  Most interactive programs using \fBcurses\fR set the \fBcbreak\fR
105 mode.  Note that \fBcbreak\fR overrides \fBraw\fR.
106 [See \fBcurs_getch\fR(3X) for a
107 discussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.]
108 .PP
109 The \fBecho\fR and \fBnoecho\fR routines control whether characters typed by
110 the user are echoed by \fBgetch\fR as they are typed.  Echoing by the tty
111 driver is always disabled, but initially \fBgetch\fR is in echo mode, so
112 characters typed are echoed.  Authors of most interactive programs prefer to do
113 their own echoing in a controlled area of the screen, or not to echo at all, so
114 they disable echoing by calling \fBnoecho\fR.
115 [See \fBcurs_getch\fR(3X) for a
116 discussion of how these routines interact with \fBcbreak\fR and
117 \fBnocbreak\fR.]
118 .PP
119 The \fBhalfdelay\fR routine is used for half-delay mode, which is similar to
120 \fBcbreak\fR mode in that characters typed by the user are immediately
121 available to the program.  However, after blocking for \fItenths\fR tenths of
122 seconds, ERR is returned if nothing has been typed.  The value of \fBtenths\fR
123 must be a number between 1 and 255.  Use \fBnocbreak\fR to leave half-delay
124 mode.
125 .PP
126 If the \fBintrflush\fR option is enabled, (\fIbf\fR is \fBTRUE\fR), when an
127 interrupt key is pressed on the keyboard (interrupt, break, quit) all output in
128 the tty driver queue will be flushed, giving the effect of faster response to
129 the interrupt, but causing \fBcurses\fR to have the wrong idea of what is on
130 the screen.  Disabling (\fIbf\fR is \fBFALSE\fR), the option prevents the
131 flush.  The default for the option is inherited from the tty driver settings.
132 The window argument is ignored.
133 .PP
134 The \fBkeypad\fR option enables the keypad of the user's terminal.  If
135 enabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key
136 (such as an arrow key) and \fBwgetch\fR returns a single value
137 representing the function key, as in \fBKEY_LEFT\fR.  If disabled
138 (\fIbf\fR is \fBFALSE\fR), \fBcurses\fR does not treat function keys
139 specially and the program has to interpret the escape sequences
140 itself.  If the keypad in the terminal can be turned on (made to
141 transmit) and off (made to work locally), turning on this option
142 causes the terminal keypad to be turned on when \fBwgetch\fR is
143 called.  The default value for keypad is false.
144 .PP
145 Initially, whether the terminal returns 7 or 8 significant bits on
146 input depends on the control mode of the tty driver [see termio(7)].
147 To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR,
148 \fBTRUE\fR); this is equivalent, under POSIX, to setting the CS8 flag
149 on the terminal.  To force 7 bits to be returned, invoke
150 \fBmeta\fR(\fIwin\fR, \fBFALSE\fR); this is equivalent, under POSIX,
151 to setting the CS7 flag on the terminal.  The window argument,
152 \fIwin\fR, is always ignored.  If the terminfo capabilities \fBsmm\fR
153 (meta_on) and \fBrmm\fR (meta_off) are defined for the terminal,
154 \fBsmm\fR is sent to the terminal when \fBmeta\fR(\fIwin\fR,
155 \fBTRUE\fR) is called and \fBrmm\fR is sent when \fBmeta\fR(\fIwin\fR,
156 \fBFALSE\fR) is called.
157 .PP
158 The \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call.
159 If no input is ready, \fBgetch\fR returns \fBERR\fR.  If disabled
160 (\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed.
161 .PP
162 While interpreting an input escape sequence, \fBwgetch\fR sets a timer
163 while waiting for the next character.  If \fBnotimeout(\fR\fIwin\fR,
164 \fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer.  The
165 purpose of the timeout is to differentiate between sequences received
166 from a function key and those typed by a user.
167 .PP
168 The \fBraw\fR and \fBnoraw\fR routines place the terminal into or out of raw
169 mode.  Raw mode is similar to \fBcbreak\fR mode, in that characters typed are
170 immediately passed through to the user program.  The differences are that in
171 raw mode, the interrupt, quit, suspend, and flow control characters are all
172 passed through uninterpreted, instead of generating a signal.  The behavior of
173 the BREAK key depends on other bits in the tty driver that are not set by
174 \fBcurses\fR.
175 .PP
176 When the \fBnoqiflush\fR routine is used, normal flush of input and
177 output queues associated with the \fBINTR\fR, \fBQUIT\fR and
178 \fBSUSP\fR characters will not be done [see termio(7)].  When
179 \fBqiflush\fR is called, the queues will be flushed when these control
180 characters are read.  You may want to call \fBnoqiflush()\fR in a signal
181 handler if you want output to continue as though the interrupt
182 had not occurred, after the handler exits.
183 .PP
184 The \fBtimeout\fR and \fBwtimeout\fR routines set blocking or
185 non-blocking read for a given window.  If \fIdelay\fR is negative,
186 blocking read is used (i.e., waits indefinitely for
187 input).  If \fIdelay\fR is zero, then non-blocking read is used
188 (i.e., read returns \fBERR\fR if no input is waiting).  If
189 \fIdelay\fR is positive, then read blocks for \fIdelay\fR
190 milliseconds, and returns \fBERR\fR if there is still no input.
191 Hence, these routines provide the same functionality as \fBnodelay\fR,
192 plus the additional capability of being able to block for only
193 \fIdelay\fR milliseconds (where \fIdelay\fR is positive).
194 .PP
195 The \fBcurses\fR library does \*(``line-breakout optimization\*(''
196 by looking for typeahead periodically while updating the screen.
197 If input is found, and it is coming from a tty,
198 the current update is postponed until
199 \fBrefresh\fR or \fBdoupdate\fR is called again.
200 This allows faster response to commands typed in advance.
201 Normally, the input FILE
202 pointer passed to \fBnewterm\fR, or \fBstdin\fR in the case that
203 \fBinitscr\fR was used, will be used to do this typeahead checking.
204 The \fBtypeahead\fR routine specifies that the file descriptor
205 \fIfd\fR is to be used to check for typeahead instead.  If \fIfd\fR is
206 \-1, then no typeahead checking is done.
207 .SH RETURN VALUE
208 All routines that return an integer return \fBERR\fR upon failure and OK (SVr4
209 specifies only "an integer value other than \fBERR\fR") upon successful
210 completion, unless otherwise noted in the preceding routine descriptions.
211 .PP
212 X/Open does not define any error conditions.
213 In this implementation,
214 functions with a window parameter will return an error if it is null.
215 Any function will also return an error if the terminal was not initialized.
216 Also,
217 .RS
218 .TP 5
219 \fBhalfdelay\fP
220 returns an error
221 if its parameter is outside the range 1..255.
222 .RE
223 .SH PORTABILITY
224 These functions are described in the XSI Curses standard, Issue 4.
225 .PP
226 The ncurses library obeys the XPG4 standard and the historical practice of the
227 AT&T curses implementations, in that the echo bit is cleared when curses
228 initializes the terminal state.  BSD curses differed from this slightly; it
229 left the echo bit on at initialization, but the BSD \fBraw\fR call turned it
230 off as a side-effect.  For best portability, set echo or noecho explicitly
231 just after initialization, even if your program remains in cooked mode.
232 .PP
233 When \fBkeypad\fP is first enabled,
234 ncurses loads the key-definitions for the current terminal description.
235 If the terminal description includes extended string capabilities,
236 e.g., from using the \fB\-x\fP option of @TIC@,
237 then ncurses also defines keys for the capabilities whose names
238 begin with "k".
239 The corresponding keycodes are generated and (depending on previous
240 loads of terminal descriptions) may differ from one execution of a
241 program to the next.
242 The generated keycodes are recognized by the \fBkeyname\fP function
243 (which will then return a name beginning with "k" denoting the
244 terminfo capability name rather than "K", used for curses key-names).
245 On the other hand, an application can use \fBdefine_key\fP to establish
246 a specific keycode for a given string.
247 This makes it possible for an application to check for an extended
248 capability's presence with \fItigetstr\fP,
249 and reassign the keycode to match its own needs.
250 .PP
251 Low-level applications can use \fBtigetstr\fP to obtain the definition
252 of any particular string capability.
253 Higher-level applications which use the curses \fBwgetch\fP
254 and similar functions to return keycodes rely upon the order in which
255 the strings are loaded.
256 If more than one key definition has the same string value,
257 then \fBwgetch\fP can return only one keycode.
258 Most curses implementations (including ncurses)
259 load key definitions in the order
260 defined by the array of string capability names.
261 The last key to be loaded determines the keycode which will be returned.
262 In ncurses, you may also have extended capabilities interpreted as
263 key definitions.
264 These are loaded after the predefined keys,
265 and if a capability's value is the same as a previously-loaded
266 key definition,
267 the later definition is the one used.
268 .SH NOTES
269 Note that \fBecho\fR, \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR,
270 \fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBnoqiflush\fR,
271 \fBqiflush\fR, \fBtimeout\fR, and \fBwtimeout\fR may be macros.
272 .PP
273 The \fBnoraw\fR and \fBnocbreak\fR calls follow historical practice in that
274 they attempt to restore to normal (`cooked') mode from raw and cbreak modes
275 respectively.  Mixing raw/noraw and cbreak/nocbreak calls leads to tty driver
276 control states that are hard to predict or understand; it is not recommended.
277 .SH SEE ALSO
278 \fBcurses\fR(3X),
279 \fBcurs_getch\fR(3X),
280 \fBcurs_initscr\fR(3X),
281 \fBcurs_util\fR(3X),
282 \fBdefine_key\fR(3X),
283 \fBtermio\fR(7)