]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_inopts.3x
ncurses 6.1 - patch 20190121
[ncurses.git] / man / curs_inopts.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2018,2019 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.28 2019/01/20 20:39:35 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 The \fBncurses\fP library provides several functions which let an application
96 change the way input from the terminal is handled.
97 Some are global, applying to all windows.
98 Others apply only to a specific window.
99 Window-specific settings are not automatically applied to new or derived
100 windows.
101 An application must apply these to each window, if the same behavior
102 is needed.
103 .\"
104 .SS cbreak
105 Normally, the tty driver buffers typed characters until a newline or carriage
106 return is typed.
107 The \fBcbreak\fR routine disables line buffering and
108 erase/kill character-processing (interrupt and flow control characters are
109 unaffected), making characters typed by the user immediately available to the
110 program.
111 The \fBnocbreak\fR routine returns the terminal to normal (cooked)
112 mode.
113 .PP
114 Initially the terminal may or may not be in \fBcbreak\fR mode, as the mode is
115 inherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fR
116 explicitly.
117 Most interactive programs using \fBcurses\fR set the \fBcbreak\fR
118 mode.
119 Note that \fBcbreak\fR overrides \fBraw\fR.
120 [See \fBcurs_getch\fR(3X) for a
121 discussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.]
122 .\"
123 .SS echo/noecho
124 .PP
125 The \fBecho\fR and \fBnoecho\fR routines control whether characters typed by
126 the user are echoed by \fBgetch\fR(3X) as they are typed.
127 Echoing by the tty
128 driver is always disabled, but initially \fBgetch\fR is in echo mode, so
129 characters typed are echoed.
130 Authors of most interactive programs prefer to do
131 their own echoing in a controlled area of the screen, or not to echo at all, so
132 they disable echoing by calling \fBnoecho\fR.
133 [See \fBcurs_getch\fR(3X) for a
134 discussion of how these routines interact with \fBcbreak\fR and
135 \fBnocbreak\fR.]
136 .\"
137 .SS halfdelay
138 .PP
139 The \fBhalfdelay\fR routine is used for half-delay mode, which is similar to
140 \fBcbreak\fR mode in that characters typed by the user are immediately
141 available to the program.
142 However, after blocking for \fItenths\fR tenths of
143 seconds, \fBERR\fP is returned if nothing has been typed.
144 The value of \fItenths\fR
145 must be a number between 1 and 255.
146 Use \fBnocbreak\fR to leave half-delay
147 mode.
148 .\"
149 .SS intrflush
150 .PP
151 If the \fBintrflush\fR option is enabled (\fIbf\fR is \fBTRUE\fR), and an
152 interrupt key is pressed on the keyboard (interrupt, break, quit), all output in
153 the tty driver queue will be flushed, giving the effect of faster response to
154 the interrupt, but causing \fBcurses\fR to have the wrong idea of what is on
155 the screen.
156 Disabling the option (\fIbf\fR is \fBFALSE\fR) prevents the
157 flush.
158 The default for the option is inherited from the tty driver settings.
159 The window argument is ignored.
160 .\"
161 .SS keypad
162 .PP
163 The \fBkeypad\fR option enables the keypad of the user's terminal.
164 If
165 enabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key
166 (such as an arrow key) and \fBwgetch\fR(3X) returns a single value
167 representing the function key, as in \fBKEY_LEFT\fR.
168 If disabled
169 (\fIbf\fR is \fBFALSE\fR), \fBcurses\fR does not treat function keys
170 specially and the program has to interpret the escape sequences
171 itself.
172 If the keypad in the terminal can be turned on (made to
173 transmit) and off (made to work locally), turning on this option
174 causes the terminal keypad to be turned on when \fBwgetch\fR(3X) is
175 called.
176 The default value for keypad is \fBFALSE\fP.
177 .\"
178 .SS meta
179 .PP
180 Initially, whether the terminal returns 7 or 8 significant bits on
181 input depends on the control mode of the tty driver [see \fBtermios\fP(3)].
182 To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR,
183 \fBTRUE\fR); this is equivalent, under POSIX, to setting the CS8 flag
184 on the terminal.
185 To force 7 bits to be returned, invoke
186 \fBmeta\fR(\fIwin\fR, \fBFALSE\fR); this is equivalent, under POSIX,
187 to setting the CS7 flag on the terminal.
188 The window argument,
189 \fIwin\fR, is always ignored.
190 If the terminfo capabilities \fBsmm\fR
191 (meta_on) and \fBrmm\fR (meta_off) are defined for the terminal,
192 \fBsmm\fR is sent to the terminal when \fBmeta\fR(\fIwin\fR,
193 \fBTRUE\fR) is called and \fBrmm\fR is sent when \fBmeta\fR(\fIwin\fR,
194 \fBFALSE\fR) is called.
195 .\"
196 .SS nodelay
197 .PP
198 The \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call.
199 If no input is ready, \fBgetch\fR returns \fBERR\fR.
200 If disabled
201 (\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed.
202 .PP
203 While interpreting an input escape sequence, \fBwgetch\fR(3X) sets a timer
204 while waiting for the next character.
205 If \fBnotimeout(\fR\fIwin\fR,
206 \fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer.
207 The
208 purpose of the timeout is to differentiate between sequences received
209 from a function key and those typed by a user.
210 .\"
211 .SS raw/noraw
212 .PP
213 The \fBraw\fR and \fBnoraw\fR routines place the terminal into or out of raw
214 mode.
215 Raw mode is similar to \fBcbreak\fR mode, in that characters typed are
216 immediately passed through to the user program.
217 The differences are that in
218 raw mode, the interrupt, quit, suspend, and flow control characters are all
219 passed through uninterpreted, instead of generating a signal.
220 The behavior of
221 the BREAK key depends on other bits in the tty driver that are not set by
222 \fBcurses\fR.
223 .\"
224 .SS noqiflush
225 .PP
226 When the \fBnoqiflush\fR routine is used, normal flush of input and
227 output queues associated with the \fBINTR\fR, \fBQUIT\fR and
228 \fBSUSP\fR characters will not be done [see \fBtermios\fP(3)].
229 When
230 \fBqiflush\fR is called, the queues will be flushed when these control
231 characters are read.
232 You may want to call \fBnoqiflush\fR in a signal
233 handler if you want output to continue as though the interrupt
234 had not occurred, after the handler exits.
235 .\"
236 .SS timeout/wtimeout
237 .PP
238 The \fBtimeout\fR and \fBwtimeout\fR routines set blocking or
239 non-blocking read for a given window.
240 If \fIdelay\fR is negative,
241 blocking read is used (i.e., waits indefinitely for
242 input).
243 If \fIdelay\fR is zero, then non-blocking read is used
244 (i.e., read returns \fBERR\fR if no input is waiting).
245 If
246 \fIdelay\fR is positive, then read blocks for \fIdelay\fR
247 milliseconds, and returns \fBERR\fR if there is still no input.
248 Hence, these routines provide the same functionality as \fBnodelay\fR,
249 plus the additional capability of being able to block for only
250 \fIdelay\fR milliseconds (where \fIdelay\fR is positive).
251 .\"
252 .SS typeahead
253 .PP
254 The \fBcurses\fR library does \*(``line-breakout optimization\*(''
255 by looking for typeahead periodically while updating the screen.
256 If input is found, and it is coming from a tty,
257 the current update is postponed until
258 \fBrefresh\fR(3X) or \fBdoupdate\fR is called again.
259 This allows faster response to commands typed in advance.
260 Normally, the input FILE
261 pointer passed to \fBnewterm\fR, or \fBstdin\fR in the case that
262 \fBinitscr\fR was used, will be used to do this typeahead checking.
263 The \fBtypeahead\fR routine specifies that the file descriptor
264 \fIfd\fR is to be used to check for typeahead instead.
265 If \fIfd\fR is
266 \-1, then no typeahead checking is done.
267 .\"
268 .SH RETURN VALUE
269 All routines that return an integer return \fBERR\fR upon failure and \fBOK\fP
270 (SVr4 specifies only \*(``an integer value other than \fBERR\fR\*('')
271 upon successful completion,
272 unless otherwise noted in the preceding routine descriptions.
273 .PP
274 X/Open does not define any error conditions.
275 In this implementation,
276 functions with a window parameter will return an error if it is null.
277 Any function will also return an error if the terminal was not initialized.
278 Also,
279 .RS
280 .TP 5
281 \fBhalfdelay\fP
282 returns an error
283 if its parameter is outside the range 1..255.
284 .RE
285 .SH PORTABILITY
286 These functions are described in the XSI Curses standard, Issue 4.
287 .PP
288 The ncurses library obeys the XPG4 standard and the historical practice of the
289 AT&T curses implementations, in that the echo bit is cleared when curses
290 initializes the terminal state.
291 BSD curses differed from this slightly; it
292 left the echo bit on at initialization, but the BSD \fBraw\fR call turned it
293 off as a side-effect.
294 For best portability, set echo or noecho explicitly
295 just after initialization, even if your program remains in cooked mode.
296 .PP
297 When \fBkeypad\fP is first enabled,
298 ncurses loads the key-definitions for the current terminal description.
299 If the terminal description includes extended string capabilities,
300 e.g., from using the \fB\-x\fP option of \fB@TIC@\fP,
301 then ncurses also defines keys for the capabilities whose names
302 begin with \*(``k\*(''.
303 The corresponding keycodes are generated and (depending on previous
304 loads of terminal descriptions) may differ from one execution of a
305 program to the next.
306 The generated keycodes are recognized by the \fBkeyname\fP function
307 (which will then return a name beginning with \*(``k\*('' denoting the
308 terminfo capability name rather than \*(``K\*('', used for curses key-names).
309 On the other hand, an application can use \fBdefine_key\fP to establish
310 a specific keycode for a given string.
311 This makes it possible for an application to check for an extended
312 capability's presence with \fBtigetstr\fP,
313 and reassign the keycode to match its own needs.
314 .PP
315 Low-level applications can use \fBtigetstr\fP to obtain the definition
316 of any particular string capability.
317 Higher-level applications which use the curses \fBwgetch\fP
318 and similar functions to return keycodes rely upon the order in which
319 the strings are loaded.
320 If more than one key definition has the same string value,
321 then \fBwgetch\fP can return only one keycode.
322 Most curses implementations (including ncurses)
323 load key definitions in the order
324 defined by the array of string capability names.
325 The last key to be loaded determines the keycode which will be returned.
326 In ncurses, you may also have extended capabilities interpreted as
327 key definitions.
328 These are loaded after the predefined keys,
329 and if a capability's value is the same as a previously-loaded
330 key definition,
331 the later definition is the one used.
332 .SH NOTES
333 Note that \fBecho\fR, \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR,
334 \fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBnoqiflush\fR,
335 \fBqiflush\fR, \fBtimeout\fR, and \fBwtimeout\fR may be macros.
336 .PP
337 The \fBnoraw\fR and \fBnocbreak\fR calls follow historical practice in that
338 they attempt to restore to normal (\*(``cooked\*('') mode
339 from raw and cbreak modes respectively.
340 Mixing raw/noraw and cbreak/nocbreak calls leads to tty driver
341 control states that are hard to predict or understand; it is not recommended.
342 .SH SEE ALSO
343 \fBcurses\fR(3X),
344 \fBcurs_getch\fR(3X),
345 \fBcurs_initscr\fR(3X),
346 \fBcurs_util\fR(3X),
347 \fBdefine_key\fR(3X),
348 \fBtermios\fR(3)