2 .\"***************************************************************************
3 .\" Copyright 2018-2023,2024 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.75 2024/06/15 19:49:39 tom Exp $
32 .TH curs_inopts 3X 2024-06-15 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
72 get and set \fIcurses\fR terminal input options
75 \fB#include <curses.h>
78 \fBint nocbreak(void);
83 \fBint intrflush(WINDOW * \fIwin\fP \fI/* ignored */\fP, bool \fIbf\fP);
84 \fBint keypad(WINDOW * \fIwin\fP, bool \fIbf\fP);
85 \fBint meta(WINDOW * \fIwin\fP \fI/* ignored */\fP, bool \fIbf\fP);
86 \fBint nodelay(WINDOW * \fIwin\fP, bool \fIbf\fP);
87 \fBint notimeout(WINDOW * \fIwin\fP, bool \fIbf\fP);
92 \fBvoid qiflush(void);
93 \fBvoid noqiflush(void);
98 \fBint halfdelay(int \fItenths\fP);
99 \fBvoid timeout(int \fIdelay\fP);
100 \fBvoid wtimeout(WINDOW * \fIwin\fP, int \fIdelay\fP);
102 \fBint typeahead(int \fIfd\fP);
105 \fBint is_cbreak(void);
106 \fBint is_echo(void);
112 offers configurable parameters permitting an application to control the
113 handling of input from the terminal.
115 applying to all windows;
116 others apply only to a specific window.
117 The library does not automatically apply such parameters to new or
119 an application must configure each window for the desired behavior.
121 Some descriptions below make reference to an
122 .IR "input character reading function" ":"
123 this is \fB\%wgetch\fP(3X) in the non-wide character
125 API and \fB\%wget_wch\fP(3X) in the wide character API.
126 In addition to the variant forms of these described in
130 functions \fB\%wgetstr\fP(3X) and \fB\%wget_wstr\fP(3X) and their own
131 variants call the appropriate input character reading function.
133 .SS "cbreak, nocbreak"
135 the terminal driver buffers typed characters,
136 not delivering them to an application
137 until a line feed or carriage return is typed.
139 configures the terminal in
140 .IR "cbreak mode" ","
141 which disables line buffering
142 and erase and kill character processing
146 and flow control characters are unaffected)
147 and makes characters typed by the user immediately available to the
150 returns the terminal to normal (\*(``cooked\*('') mode.
152 The state of the terminal is unknown to a
154 application when it starts;
156 a program should call
161 Most interactive programs using
169 The man page for the input character reading function
183 determine whether characters typed by the user are written to the
185 window by the input character reading function as they are typed.
187 always disables the terminal driver's own echoing.
191 screen's echo option is set.
192 Authors of most interactive programs prefer
193 to do their own echoing in a controlled area of the screen,
194 or not to echo at all,
197 The man page for the input character reading function
210 .IR "half-delay mode" ","
211 which is similar to \%cbreak mode in that characters typed by the user
212 are immediately available to the program.
217 an input character reading function returns
219 if no input is pending.
222 must be between 1 and 255.
225 to leave half-delay mode.
248 enables recognition of a terminal's function keys.
254 the input character reading function returns a value representing
258 (Wide-character API users:
259 \fB\%wget_wch\fP(3X) returns
261 to indicate the availability of a function key code in its
269 does not treat function keys specially and the program has to interpret
270 escape sequences itself.
271 If the terminal's keypad can be turned on
274 (made to work locally),
276 configures it consistently with the
280 a window's keypad mode is off.
284 whether the terminal returns 7- or 8-bit character codes on input
285 depends on the configuration of the terminal driver;
286 see \fI\%termios\fP(3).
287 To force 8 bits to be returned,
293 to setting the CS8 flag on the terminal.
294 To force 7 bits to be returned,
300 to setting the CS7 flag on the terminal.
312 are defined for the terminal type,
313 enabling meta mode sends
315 to the terminal and disabling it sends
321 whether the terminal reports a carriage return
322 using the character code for a line feed
323 in cbreak or raw modes
324 depends on the configuration of the terminal driver;
325 see \fI\%termios\fP(3).
327 configures the terminal to perform this translation.
330 In normal (or \*(``cooked\*('') mode,
331 the terminal driver always translates carriage returns to line feeds.
335 configures the input character reading function to be non-blocking for
338 If no input is ready,
339 the reading function returns
345 the reading function does not return until it has input.
347 When the input character reading function reads an ESC character,
348 it sets a timer while waiting for the next character.
349 .BI \%notimeout( win ,
352 The purpose of the timeout is to distinguish sequences produced by a
353 function key from those typed by a user.
354 To configure the timeout rather than disabling it,
359 .SS "qiflush, noqiflush"
364 configure the terminal driver's treatment of its input and output queues
365 when it handles the interrupt,
367 or quit characters in
369 and \*(``cooked\*('' modes;
371 see \fI\%termios\fP(3).
372 The default behavior is inherited from the terminal driver settings.
375 configures the terminal to flush the queues when any of these events
377 giving the impression of faster response to user input,
378 but making the library's model of the screen contents incorrect.
381 prevents such flushing,
382 but might frustrate impatient users on slow connections if a
384 update of the screen is in progress when the event occurs;
387 below for a mitigation of this problem.
391 if you want output to continue
392 after the handler exits
393 as though the interrupt had not occurred.
397 configures the terminal to read input in
399 which is similar to cbreak mode
403 except that it furthermore passes through the terminal's configured
407 and flow control characters
408 uninterpreted to the application,
409 instead of generating a signal or acting on I/O flow.
410 The behavior of the terminal's \*(``Break\*('' key
412 depends on terminal driver configuration parameters that
416 returns the terminal to normal (\*(``cooked\*('') mode.
418 .SS "timeout, wtimeout"
422 input character reading function called on window
424 uses blocking or non-blocking reads.
428 a blocking read is used,
429 waiting indefinitely for input.
433 a non-blocking read is used;
434 an input character reading function returns
436 if no input is pending.
440 an input character reading function
446 if the delay elapses and there is still no input pending.
457 library checks the terminal for input while updating the screen.
459 the update is postponed until the next \fB\%wrefresh\fP(3X) or
460 \fB\%doupdate\fP(3X) call,
461 allowing faster response to user key strokes.
462 The library tests the file descriptor corresponding to the
464 stream pointer passed to \fB\%newterm\fP(3X)
467 if \fB\%initscr\fP(3X) was called),
472 to test file descriptor
511 the functions in the previous paragraph return
515 the terminal is not initialized or
524 which ignore its value).
532 is outside the range 1..255.
534 See section \*(``EXTENSIONS\*('' below for the
556 may be implemented as macros.
561 follow historical practice in that they attempt to restore normal
562 (\*(``cooked\*('') mode from raw and cbreak modes,
567 .BR \%cbreak / nocbreak
568 calls leads to terminal driver control states that are hard to predict
570 doing so is not recommended.
573 provides four \*(``is_\*('' functions corresponding to
579 permitting their states to be queried by the application.
587 is_cbreak cbreak nocbreak
595 .TP 5 \" "-1" + 2n tag separation + 1n fudge for typesetters like grops
597 if the option is set,
600 if the option is reset,
604 if the library is not initialized.
606 Applications employing
608 extensions should condition their use on the visibility of the
612 Except as noted in section \*(``EXTENSIONS\*('' above,
614 Issue 4 describes these functions.
615 It specifies no error conditions for them.
619 describes a successful return value only as
620 \*(``an integer value other than
624 follows X/Open Curses
625 and the historical practice of System\ V
627 clearing the terminal driver's \*(``echo\*('' flag when initializing the
634 function turned it off as a side effect.
635 .\" SGTTY's sg_flags had a "RAW" symbol; termio in SVr1 for the PDP-11
637 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/include/curses.h
638 .\" https://github.com/ryanwoodsmall/oldsysv/blob/master/sysv-pdp11_man/a_man/man7/termio.7
639 For best portability,
644 explicitly just after initialization,
645 even if your program remains in normal (\*(``cooked\*('') mode.
647 X/Open Curses is ambiguous regarding whether
649 should disable the carriage return and line feed translation feature
656 did turn off these translations;
662 on the assumption that a programmer requesting raw input wants a clean
665 connection that the operating system will not alter.
671 loads the key definitions for the current terminal description.
672 If the terminal description includes extended string capabilities,
676 option of \fB\%@TIC@\fP(1),
679 also defines keys for the capabilities whose names begin with
681 Corresponding key codes are generated and
682 (depending on previous loads of terminal descriptions)
683 may differ from one execution of a program to the next.
684 The generated key codes are recognized by \fB\%keyname\fP(3X),
685 which then returns a name beginning with \*(``k\*('' denoting the
687 capability name rather than \*(``K\*('',
692 an application can use \fB\%define_key\fP(3X) to bind
693 a specific key to a string of the programmer's choice.
694 This feature enables an application to check for its presence
695 with \fB\%tigetstr\fP(3X),
696 and reassign the key code to match its own needs.
698 Low-level applications can use \fB\%tigetstr\fP(3X) to obtain the
699 definition of any string capability.
701 applications use the input character reading function
702 to obtain key codes from input
703 and rely upon the order in which the string capabilities are loaded.
704 Multiple key capability strings can have the same value,
705 but the input character reading function can report only one key code.
711 load key definitions in the order
714 array of string capability names;
715 see \fB\%term_variables\fP(3X).
716 .\" ncurses/tinfo/parse_entry.c:lookup_fullname, I think --GBR
717 The last capability read using a particular definition determines the
718 key code to be reported.
721 extended capabilities can be interpreted as key definitions.
722 These are loaded after the predefined keys,
723 and if a capability's value is the same as a previously loaded
725 the later definition is the one used.
737 .IR \%noraw "." \" also crmod and nocrmod, never standardized
739 SVr2 (1984) featured a new terminal driver,
742 API to support it with
761 appeared in SVr3.1 (1987),
764 became a wrapper for either of these functions,
765 depending on the value of its Boolean argument.
770 6.5 (2024) introduced
783 to control the conversion of newlines to carriage return/line feed
784 on output as well as input.
785 X/Open Curses documents the use of these functions only for input.
786 This difference arose from converting the
790 \fI\%ioctl\fP(2) calls and the
795 (the POSIX terminal API).
797 both input and output were controlled via a single option
799 while the latter separates these features.
800 Because that conversion interferes with output optimization,
806 to eliminate their effect on output.
809 \fB\%curs_getch\fP(3X),
810 \fB\%curs_initscr\fP(3X),
811 \fB\%curs_util\fP(3X),
812 \fB\%define_key\fP(3X),
814 \fB\%term_variables\fP(3X)