2 .\"***************************************************************************
3 .\" Copyright 2018-2022,2023 Thomas E. Dickey *
4 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
6 .\" Permission is hereby granted, free of charge, to any person obtaining a *
7 .\" copy of this software and associated documentation files (the *
8 .\" "Software"), to deal in the Software without restriction, including *
9 .\" without limitation the rights to use, copy, modify, merge, publish, *
10 .\" distribute, distribute with modifications, sublicense, and/or sell *
11 .\" copies of the Software, and to permit persons to whom the Software is *
12 .\" furnished to do so, subject to the following conditions: *
14 .\" The above copyright notice and this permission notice shall be included *
15 .\" in all copies or substantial portions of the Software. *
17 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 .\" Except as contained in this notice, the name(s) of the above copyright *
26 .\" holders shall not be used in advertising or otherwise to promote the *
27 .\" sale, use or other dealings in this Software without prior written *
29 .\"***************************************************************************
31 .\" $Id: curs_inopts.3x,v 1.60 2023/12/23 16:36:18 tom Exp $
32 .TH curs_inopts 3X 2023-12-23 "ncurses 6.4" "Library calls"
67 get and set \fIcurses\fR terminal input options
70 \fB#include <curses.h>
73 \fBint nocbreak(void);
78 \fBint intrflush(WINDOW *\fIwin\fP, bool \fIbf\fP);
79 \fBint keypad(WINDOW *\fIwin\fP, bool \fIbf\fP);
80 \fBint meta(WINDOW *\fIwin\fP, bool \fIbf\fP);
81 \fBint nodelay(WINDOW *\fIwin\fP, bool \fIbf\fP);
82 \fBint notimeout(WINDOW *\fIwin\fP, bool \fIbf\fP);
90 \fBvoid qiflush(void);
91 \fBvoid noqiflush(void);
93 \fBint halfdelay(int \fItenths\fP);
94 \fBvoid timeout(int \fIdelay\fP);
95 \fBvoid wtimeout(WINDOW *\fIwin\fP, int \fIdelay\fP);
97 \fBint typeahead(int \fIfd\fP);
100 \fBint is_cbreak(void);
101 \fBint is_echo(void);
107 provides several functions that let an application change the way input
108 from the terminal is handled.
110 applying to all windows.
111 Others apply only to a specific window.
112 Window-specific settings are not automatically applied to new or derived
114 An application must apply these to each window if the same behavior is
117 .SS "cbreak, nocbreak"
119 the terminal driver buffers typed characters until a newline or carriage
121 The \fB\%cbreak\fP routine disables line buffering and
122 erase/kill character-processing
123 (interrupt and flow control characters are unaffected),
124 making characters typed by the user immediately available to the
126 The \fB\%nocbreak\fP routine returns the terminal to normal (cooked)
129 Initially the terminal may or may not be in \fB\%cbreak\fP mode,
130 as the mode is inherited;
132 a program should call \fB\%cbreak\fP or \fB\%nocbreak\fP explicitly.
133 Most interactive programs using
135 set the \fB\%cbreak\fP mode.
136 Note that \fB\%cbreak\fP overrides \fBraw\fP.
137 [See \fB\%curs_getch\fP(3X) for a discussion of how these routines
138 interact with \fBecho\fP and \fB\%noecho\fP.]
141 The \fBecho\fP and \fB\%noecho\fP routines control whether characters
142 typed by the user are echoed by \fB\%getch\fP(3X) as they are typed.
143 Echoing by the terminal driver is always disabled,
144 but initially \fB\%getch\fP is in echo mode,
145 so characters typed are echoed.
146 Authors of most interactive programs prefer to do
147 their own echoing in a controlled area of the screen,
148 or not to echo at all,
149 so they disable echoing by calling \fB\%noecho\fP.
150 [See \fB\%curs_getch\fP(3X) for a
151 discussion of how these routines interact with \fB\%cbreak\fP and
155 The \fB\%halfdelay\fP routine is used for half-delay mode,
156 which is similar to \fB\%cbreak\fP mode in that characters typed by the
157 user are immediately available to the program.
159 after blocking for \fItenths\fP tenths of seconds,
160 \fBERR\fP is returned if nothing has been typed.
161 The value of \fItenths\fP must be a number between 1 and 255.
162 Use \fB\%nocbreak\fP to leave half-delay mode.
165 If the \fB\%intrflush\fP option is enabled
169 and an interrupt key is pressed on the keyboard
173 all output in the terminal driver queue is flushed,
174 giving the effect of faster response to the interrupt,
177 to have the wrong idea of what is on the screen.
183 The default for the option is inherited from the terminal driver
190 The \fB\%keypad\fP option enables the keypad of the user's terminal.
196 the user can press a function key
197 (such as an arrow key)
198 and \fB\%wgetch\fP(3X) returns a single value representing the function
200 as in \fB\%KEY_LEFT\fP.
202 (\fIbf\fP is \fBFALSE\fP),
204 does not treat function keys specially and the program has to interpret
205 the escape sequences itself.
206 If the keypad in the terminal can be turned on
209 (made to work locally),
210 turning on this option causes the terminal keypad to be turned on when
211 \fB\%wgetch\fP(3X) is called.
212 The default value for keypad is \fBFALSE\fP.
216 whether the terminal returns 7 or 8 significant bits on input depends on
217 the control mode of the terminal driver [see \fI\%termios\fP(3)].
218 To force 8 bits to be returned,
220 \fBmeta\fP(\fIwin\fP, \fBTRUE\fP);
223 to setting the CS8 flag on the terminal.
224 To force 7 bits to be returned,
226 \fBmeta\fP(\fIwin\fP, \fBFALSE\fP);
229 to setting the CS7 flag on the terminal.
233 If the terminfo capabilities
234 \fBsmm\fP (meta_on) and
235 \fBrmm\fP (meta_off) are defined for the terminal,
236 \fBsmm\fP is sent to the terminal when
237 \fBmeta\fP(\fIwin\fP, \fBTRUE\fP)
238 is called and \fBrmm\fP is sent when
239 \fBmeta\fP(\fIwin\fP, \fBFALSE\fP) is called.
242 The \fBnl\fP and \fBnonl\fP routines control whether the underlying
243 display device translates the return key into newline on input.
246 The \fB\%nodelay\fP option causes \fB\%getch\fP to be a non-blocking
248 If no input is ready,
249 \fB\%getch\fP returns \fBERR\fP.
254 \fB\%getch\fP waits until a key is pressed.
256 When interpreting an escape sequence,
257 \fB\%wgetch\fP(3X) sets a timer
258 while waiting for the next character.
260 \fB\%notimeout(\fIwin\fR, \fBTRUE\fP)
262 then \fB\%wgetch\fP does not set a timer.
263 The purpose of the timeout is to distinguish sequences produced by a
264 function key from those typed by a user.
267 The \fBraw\fP and \fB\%noraw\fP routines place the terminal into or out
269 Raw mode is similar to \fB\%cbreak\fP mode,
270 in that characters typed are immediately passed through to the user
272 The differences are that in raw mode,
276 and flow control characters are all
277 passed through uninterpreted,
278 instead of generating a signal.
279 The behavior of the BREAK key depends on other bits in the terminal
280 driver that are not set by
283 .SS "qiflush, nqiflush"
284 When the \fB\%noqiflush\fP routine is used,
285 normal flush of input and output queues associated with the \fBINTR\fP,
286 \fBQUIT\fP and \fBSUSP\fP characters will not be done
287 [see \fB\%termios\fP(3)].
289 \fB\%qiflush\fP is called,
290 the queues will be flushed when these control characters are read.
291 You may want to call \fB\%noqiflush\fP in a signal handler if you want
292 output to continue as though the interrupt had not occurred,
293 after the handler exits.
295 .SS "timeout, wtimeout"
296 The \fB\%timeout\fP and \fB\%wtimeout\fP routines set blocking or
297 non-blocking read for a given window.
298 If \fIdelay\fP is negative,
299 a blocking read is used
301 waits indefinitely for input).
302 If \fIdelay\fP is zero,
303 then a non-blocking read is used
306 returns \fBERR\fP if no input is waiting).
308 \fIdelay\fP is positive,
311 blocks for \fIdelay\fP milliseconds,
312 and returns \fBERR\fP if there is still no input.
314 these routines provide the same functionality as \fB\%nodelay\fP,
315 plus the additional capability of being able to block for only
316 \fIdelay\fP milliseconds
317 (where \fIdelay\fP is positive).
321 does \*(``line-breakout optimization\*('' by looking for typeahead
322 periodically while updating the screen.
324 and it is coming from a terminal,
325 the current update is postponed until
326 \fB\%refresh\fP(3X) or \fB\%doupdate\fP is called again.
327 This allows faster response to commands typed in advance.
331 pointer passed to \fB\%newterm\fP,
332 or \fBstdin\fP in the case that \fB\%initscr\fP was used,
333 will be used to do this typeahead checking.
334 The \fB\%typeahead\fP routine specifies that the file descriptor
335 \fIfd\fP is to be used to check for typeahead instead.
338 then no typeahead checking is done.
341 All routines that return an integer return \fBERR\fP upon failure and
343 (SVr4 specifies only \*(``an integer value other than \fBERR\fP\*('')
344 upon successful completion,
345 unless otherwise noted in the preceding routine descriptions.
347 X/Open does not define any error conditions.
348 In this implementation,
349 functions with a window parameter will return an error if it is null.
350 Any function will also return an error if the terminal was not
357 if its parameter is outside the range 1..255.
374 may be implemented as macros.
376 \fB\%noraw\fP and \fB\%nocbreak\fP follow historical practice in that
377 they attempt to restore normal (\*(``cooked\*('') mode
378 from raw and cbreak modes respectively.
379 Mixing \fBraw\fP/\fB\%noraw\fP and \fB\%cbreak\fP/\fB\%nocbreak\fP calls
380 leads to terminal driver control states that are hard to predict or
382 doing so is not recommended.
385 provides four \*(``is_\*('' functions that may be used to detect if the
386 corresponding flags were set or reset.
394 is_cbreak cbreak nocbreak
407 if the flag is reset,
411 if the library is not initialized.
413 They were designed for
415 and are not found in SVr4
419 or any other previous
423 Applications employing
425 extensions should condition their use on the visibility of the
429 Except as noted in section \*(``EXTENSIONS\*('' above,
430 X/Open Curses, Issue 4, Version 2 describes these functions.
433 follows X/Open Curses
434 and the historical practice of AT&T
437 in that the echo bit is cleared when
439 initializes the terminal state.
442 differed from this slightly;
443 it left the echo bit on at initialization,
444 but the BSD \fBraw\fP call turned it off as a side effect.
445 For best portability,
446 set \fBecho\fP or \fB\%noecho\fP explicitly just after initialization,
447 even if your program remains in cooked mode.
449 X/Open Curses is ambiguous regarding whether \fBraw\fP should disable
450 the CR/LF translations controlled by \fBnl\fP and \fBnonl\fP.
453 did turn off these translations;
456 (at least as late as SVr1)
460 on the assumption that a programmer requesting raw input wants a clean
463 connection that the operating system will not alter.
465 When \fB\%keypad\fP is first enabled,
467 loads the key definitions for the current terminal description.
468 If the terminal description includes extended string capabilities,
472 option of \fB\%@TIC@\fP,
475 also defines keys for the capabilities whose names begin with
477 The corresponding keycodes are generated and
478 (depending on previous loads of terminal descriptions)
479 may differ from one execution of a program to the next.
480 The generated keycodes are recognized by the \fB\%keyname\fP(3X)
482 (which will then return a name beginning with \*(``k\*('' denoting the
483 terminfo capability name rather than \*(``K\*('',
488 an application can use \fB\%define_key\fP(3X) to establish
489 a specific keycode for a given string.
490 This makes it possible for an application to check for an extended
491 capability's presence with \fB\%tigetstr\fP,
492 and reassign the keycode to match its own needs.
494 Low-level applications can use \fB\%tigetstr\fP to obtain the definition
495 of any particular string capability.
496 Higher-level applications which use the
498 \fB\%wgetch\fP and similar functions to return keycodes rely upon the
499 order in which the strings are loaded.
500 If more than one key definition has the same string value,
501 then \fB\%wgetch\fP can return only one keycode.
507 load key definitions in the order
508 defined by the array of string capability names.
509 The last key to be loaded determines the keycode which will be returned.
512 you may also have extended capabilities interpreted as key definitions.
513 These are loaded after the predefined keys,
514 and if a capability's value is the same as a previously-loaded
516 the later definition is the one used.
519 \fB\%curs_getch\fP(3X),
520 \fB\%curs_initscr\fP(3X),
521 \fB\%curs_util\fP(3X),
522 \fB\%define_key\fP(3X),