3 ****************************************************************************
4 * Copyright 2018-2022,2023 Thomas E. Dickey *
5 * Copyright 1998-2016,2017 Free Software Foundation, Inc. *
7 * Permission is hereby granted, free of charge, to any person obtaining a *
8 * copy of this software and associated documentation files (the *
9 * "Software"), to deal in the Software without restriction, including *
10 * without limitation the rights to use, copy, modify, merge, publish, *
11 * distribute, distribute with modifications, sublicense, and/or sell *
12 * copies of the Software, and to permit persons to whom the Software is *
13 * furnished to do so, subject to the following conditions: *
15 * The above copyright notice and this permission notice shall be included *
16 * in all copies or substantial portions of the Software. *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
21 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
24 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
26 * Except as contained in this notice, the name(s) of the above copyright *
27 * holders shall not be used in advertising or otherwise to promote the *
28 * sale, use or other dealings in this Software without prior written *
30 ****************************************************************************
31 * @Id: curs_inopts.3x,v 1.56 2023/10/21 10:28:36 tom Exp @
33 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
36 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
37 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
38 <TITLE>curs_inopts 3x 2023-10-21 ncurses 6.4 Library calls</TITLE>
39 <link rel="author" href="mailto:bug-ncurses@gnu.org">
43 <H1 class="no-header">curs_inopts 3x 2023-10-21 ncurses 6.4 Library calls</H1>
45 <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG> Library calls <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>
50 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
51 <STRONG>cbreak</STRONG>, <STRONG>echo</STRONG>, <STRONG>halfdelay</STRONG>, <STRONG>intrflush</STRONG>, <STRONG>is_cbreak</STRONG>, <STRONG>is_echo</STRONG>, <STRONG>is_nl</STRONG>, <STRONG>is_raw</STRONG>,
52 <STRONG>keypad</STRONG>, <STRONG>meta</STRONG>, <STRONG>nl</STRONG>, <STRONG>nocbreak</STRONG>, <STRONG>nodelay</STRONG>, <STRONG>noecho</STRONG>, <STRONG>nonl</STRONG>, <STRONG>noqiflush</STRONG>, <STRONG>noraw</STRONG>,
53 <STRONG>notimeout</STRONG>, <STRONG>qiflush</STRONG>, <STRONG>raw</STRONG>, <STRONG>timeout</STRONG>, <STRONG>wtimeout</STRONG>, <STRONG>typeahead</STRONG> - get and set
54 <EM>curses</EM> terminal input options
57 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
58 <STRONG>#include</STRONG> <STRONG><curses.h></STRONG>
60 <STRONG>int</STRONG> <STRONG>cbreak(void);</STRONG>
61 <STRONG>int</STRONG> <STRONG>nocbreak(void);</STRONG>
63 <STRONG>int</STRONG> <STRONG>echo(void);</STRONG>
64 <STRONG>int</STRONG> <STRONG>noecho(void);</STRONG>
66 <STRONG>int</STRONG> <STRONG>intrflush(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>bool</STRONG> <EM>bf</EM><STRONG>);</STRONG>
67 <STRONG>int</STRONG> <STRONG>keypad(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>bool</STRONG> <EM>bf</EM><STRONG>);</STRONG>
68 <STRONG>int</STRONG> <STRONG>meta(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>bool</STRONG> <EM>bf</EM><STRONG>);</STRONG>
69 <STRONG>int</STRONG> <STRONG>nodelay(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>bool</STRONG> <EM>bf</EM><STRONG>);</STRONG>
70 <STRONG>int</STRONG> <STRONG>notimeout(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>bool</STRONG> <EM>bf</EM><STRONG>);</STRONG>
72 <STRONG>int</STRONG> <STRONG>nl(void);</STRONG>
73 <STRONG>int</STRONG> <STRONG>nonl(void);</STRONG>
75 <STRONG>int</STRONG> <STRONG>raw(void);</STRONG>
76 <STRONG>int</STRONG> <STRONG>noraw(void);</STRONG>
78 <STRONG>void</STRONG> <STRONG>qiflush(void);</STRONG>
79 <STRONG>void</STRONG> <STRONG>noqiflush(void);</STRONG>
81 <STRONG>int</STRONG> <STRONG>halfdelay(int</STRONG> <EM>tenths</EM><STRONG>);</STRONG>
82 <STRONG>void</STRONG> <STRONG>timeout(int</STRONG> <EM>delay</EM><STRONG>);</STRONG>
83 <STRONG>void</STRONG> <STRONG>wtimeout(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>delay</EM><STRONG>);</STRONG>
85 <STRONG>int</STRONG> <STRONG>typeahead(int</STRONG> <EM>fd</EM><STRONG>);</STRONG>
87 <EM>/*</EM> <EM>extensions</EM> <EM>*/</EM>
88 <STRONG>int</STRONG> <STRONG>is_cbreak(void);</STRONG>
89 <STRONG>int</STRONG> <STRONG>is_echo(void);</STRONG>
90 <STRONG>int</STRONG> <STRONG>is_nl(void);</STRONG>
91 <STRONG>int</STRONG> <STRONG>is_raw(void);</STRONG>
94 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
95 The <EM>ncurses</EM> library provides several functions which let an application
96 change the way input from the terminal is handled. Some are global,
97 applying to all windows. Others apply only to a specific window.
98 Window-specific settings are not automatically applied to new or
99 derived windows. An application must apply these to each window, if
100 the same behavior is needed.
103 </PRE><H3><a name="h3-cbreak_nocbreak">cbreak/nocbreak</a></H3><PRE>
104 Normally, the tty driver buffers typed characters until a newline or
105 carriage return is typed. The <STRONG>cbreak</STRONG> routine disables line buffering
106 and erase/kill character-processing (interrupt and flow control
107 characters are unaffected), making characters typed by the user
108 immediately available to the program. The <STRONG>nocbreak</STRONG> routine returns the
109 terminal to normal (cooked) mode.
111 Initially the terminal may or may not be in <STRONG>cbreak</STRONG> mode, as the mode is
112 inherited; therefore, a program should call <STRONG>cbreak</STRONG> or <STRONG>nocbreak</STRONG>
113 explicitly. Most interactive programs using <EM>curses</EM> set the <STRONG>cbreak</STRONG>
114 mode. Note that <STRONG>cbreak</STRONG> overrides <STRONG>raw</STRONG>. [See <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG> for a
115 discussion of how these routines interact with <STRONG>echo</STRONG> and <STRONG>noecho</STRONG>.]
118 </PRE><H3><a name="h3-echo_noecho">echo/noecho</a></H3><PRE>
119 The <STRONG>echo</STRONG> and <STRONG>noecho</STRONG> routines control whether characters typed by the
120 user are echoed by <STRONG><A HREF="curs_getch.3x.html">getch(3x)</A></STRONG> as they are typed. Echoing by the tty
121 driver is always disabled, but initially <STRONG>getch</STRONG> is in echo mode, so
122 characters typed are echoed. Authors of most interactive programs
123 prefer to do their own echoing in a controlled area of the screen, or
124 not to echo at all, so they disable echoing by calling <STRONG>noecho</STRONG>. [See
125 <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG> for a discussion of how these routines interact with
126 <STRONG>cbreak</STRONG> and <STRONG>nocbreak</STRONG>.]
129 </PRE><H3><a name="h3-halfdelay">halfdelay</a></H3><PRE>
130 The <STRONG>halfdelay</STRONG> routine is used for half-delay mode, which is similar to
131 <STRONG>cbreak</STRONG> mode in that characters typed by the user are immediately
132 available to the program. However, after blocking for <EM>tenths</EM> tenths of
133 seconds, <STRONG>ERR</STRONG> is returned if nothing has been typed. The value of
134 <EM>tenths</EM> must be a number between 1 and 255. Use <STRONG>nocbreak</STRONG> to leave half-
138 </PRE><H3><a name="h3-intrflush">intrflush</a></H3><PRE>
139 If the <STRONG>intrflush</STRONG> option is enabled (<EM>bf</EM> is <STRONG>TRUE</STRONG>), and an interrupt key
140 is pressed on the keyboard (interrupt, break, quit), all output in the
141 tty driver queue will be flushed, giving the effect of faster response
142 to the interrupt, but causing <EM>curses</EM> to have the wrong idea of what is
143 on the screen. Disabling the option (<EM>bf</EM> is <STRONG>FALSE</STRONG>) prevents the flush.
144 The default for the option is inherited from the tty driver settings.
145 The window argument is ignored.
148 </PRE><H3><a name="h3-keypad">keypad</a></H3><PRE>
149 The <STRONG>keypad</STRONG> option enables the keypad of the user's terminal. If
150 enabled (<EM>bf</EM> is <STRONG>TRUE</STRONG>), the user can press a function key (such as an
151 arrow key) and <STRONG><A HREF="curs_getch.3x.html">wgetch(3x)</A></STRONG> returns a single value representing the
152 function key, as in <STRONG>KEY_LEFT</STRONG>. If disabled (<EM>bf</EM> is <STRONG>FALSE</STRONG>), <EM>curses</EM> does
153 not treat function keys specially and the program has to interpret the
154 escape sequences itself. If the keypad in the terminal can be turned
155 on (made to transmit) and off (made to work locally), turning on this
156 option causes the terminal keypad to be turned on when <STRONG><A HREF="curs_getch.3x.html">wgetch(3x)</A></STRONG> is
157 called. The default value for keypad is <STRONG>FALSE</STRONG>.
160 </PRE><H3><a name="h3-meta">meta</a></H3><PRE>
161 Initially, whether the terminal returns 7 or 8 significant bits on
162 input depends on the control mode of the tty driver [see <STRONG>termios(3)</STRONG>].
163 To force 8 bits to be returned, invoke <STRONG>meta</STRONG>(<EM>win</EM>, <STRONG>TRUE</STRONG>); this is
164 equivalent, under POSIX, to setting the CS8 flag on the terminal. To
165 force 7 bits to be returned, invoke <STRONG>meta</STRONG>(<EM>win</EM>, <STRONG>FALSE</STRONG>); this is
166 equivalent, under POSIX, to setting the CS7 flag on the terminal. The
167 window argument, <EM>win</EM>, is always ignored. If the terminfo capabilities
168 <STRONG>smm</STRONG> (meta_on) and <STRONG>rmm</STRONG> (meta_off) are defined for the terminal, <STRONG>smm</STRONG> is
169 sent to the terminal when <STRONG>meta</STRONG>(<EM>win</EM>, <STRONG>TRUE</STRONG>) is called and <STRONG>rmm</STRONG> is sent
170 when <STRONG>meta</STRONG>(<EM>win</EM>, <STRONG>FALSE</STRONG>) is called.
173 </PRE><H3><a name="h3-nl_nonl">nl/nonl</a></H3><PRE>
174 The <STRONG>nl</STRONG> and <STRONG>nonl</STRONG> routines control whether the underlying display device
175 translates the return key into newline on input.
178 </PRE><H3><a name="h3-nodelay">nodelay</a></H3><PRE>
179 The <STRONG>nodelay</STRONG> option causes <STRONG>getch</STRONG> to be a non-blocking call. If no input
180 is ready, <STRONG>getch</STRONG> returns <STRONG>ERR</STRONG>. If disabled (<EM>bf</EM> is <STRONG>FALSE</STRONG>), <STRONG>getch</STRONG> waits
181 until a key is pressed.
184 </PRE><H3><a name="h3-notimeout">notimeout</a></H3><PRE>
185 When interpreting an escape sequence, <STRONG><A HREF="curs_getch.3x.html">wgetch(3x)</A></STRONG> sets a timer while
186 waiting for the next character. If <STRONG>notimeout(</STRONG><EM>win</EM>, <STRONG>TRUE</STRONG>) is called,
187 then <STRONG>wgetch</STRONG> does not set a timer. The purpose of the timeout is to
188 differentiate between sequences received from a function key and those
192 </PRE><H3><a name="h3-raw_noraw">raw/noraw</a></H3><PRE>
193 The <STRONG>raw</STRONG> and <STRONG>noraw</STRONG> routines place the terminal into or out of raw mode.
194 Raw mode is similar to <STRONG>cbreak</STRONG> mode, in that characters typed are
195 immediately passed through to the user program. The differences are
196 that in raw mode, the interrupt, quit, suspend, and flow control
197 characters are all passed through uninterpreted, instead of generating
198 a signal. The behavior of the BREAK key depends on other bits in the
199 tty driver that are not set by <EM>curses</EM>.
202 </PRE><H3><a name="h3-qiflush_noqiflush">qiflush/noqiflush</a></H3><PRE>
203 When the <STRONG>noqiflush</STRONG> routine is used, normal flush of input and output
204 queues associated with the <STRONG>INTR</STRONG>, <STRONG>QUIT</STRONG> and <STRONG>SUSP</STRONG> characters will not be
205 done [see <STRONG>termios(3)</STRONG>]. When <STRONG>qiflush</STRONG> is called, the queues will be
206 flushed when these control characters are read. You may want to call
207 <STRONG>noqiflush</STRONG> in a signal handler if you want output to continue as though
208 the interrupt had not occurred, after the handler exits.
211 </PRE><H3><a name="h3-timeout_wtimeout">timeout/wtimeout</a></H3><PRE>
212 The <STRONG>timeout</STRONG> and <STRONG>wtimeout</STRONG> routines set blocking or non-blocking read for
213 a given window. If <EM>delay</EM> is negative, blocking read is used (i.e.,
214 waits indefinitely for input). If <EM>delay</EM> is zero, then non-blocking
215 read is used (i.e., read returns <STRONG>ERR</STRONG> if no input is waiting). If <EM>delay</EM>
216 is positive, then read blocks for <EM>delay</EM> milliseconds, and returns <STRONG>ERR</STRONG>
217 if there is still no input. Hence, these routines provide the same
218 functionality as <STRONG>nodelay</STRONG>, plus the additional capability of being able
219 to block for only <EM>delay</EM> milliseconds (where <EM>delay</EM> is positive).
222 </PRE><H3><a name="h3-typeahead">typeahead</a></H3><PRE>
223 The <EM>curses</EM> library does "line-breakout optimization" by looking for
224 typeahead periodically while updating the screen. If input is found,
225 and it is coming from a tty, the current update is postponed until
226 <STRONG><A HREF="curs_refresh.3x.html">refresh(3x)</A></STRONG> or <STRONG>doupdate</STRONG> is called again. This allows faster response
227 to commands typed in advance. Normally, the input FILE pointer passed
228 to <STRONG>newterm</STRONG>, or <STRONG>stdin</STRONG> in the case that <STRONG>initscr</STRONG> was used, will be used to
229 do this typeahead checking. The <STRONG>typeahead</STRONG> routine specifies that the
230 file descriptor <EM>fd</EM> is to be used to check for typeahead instead. If <EM>fd</EM>
231 is -1, then no typeahead checking is done.
234 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
235 All routines that return an integer return <STRONG>ERR</STRONG> upon failure and <STRONG>OK</STRONG>
236 (SVr4 specifies only "an integer value other than <STRONG>ERR</STRONG>") upon successful
237 completion, unless otherwise noted in the preceding routine
240 X/Open does not define any error conditions. In this implementation,
241 functions with a window parameter will return an error if it is null.
242 Any function will also return an error if the terminal was not
245 <STRONG>halfdelay</STRONG>
246 returns an error if its parameter is outside the range 1..255.
249 </PRE><H2><a name="h2-EXTENSIONS">EXTENSIONS</a></H2><PRE>
250 This implementation provides four functions which may be used to detect
251 if the corresponding flags were set or reset:
253 <STRONG>Query</STRONG> <STRONG>Set</STRONG> <STRONG>Reset</STRONG>
254 ------------------------------
255 is_cbreak cbreak nocbreak
260 In each case, the function returns
262 1 if the flag is set,
264 0 if the flag is reset, or
266 -1 if the <EM>curses</EM> library was not initialized.
268 These routines are specific to <EM>ncurses</EM>. They were not supported on
269 Version 7, BSD or System V implementations. It is recommended that any
270 code depending on <EM>ncurses</EM> extensions be conditioned using
274 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
275 Except as noted in the section on extensions, these functions are
276 described in the XSI Curses standard, Issue 4.
278 The <EM>ncurses</EM> library obeys the XPG4 standard and the historical practice
279 of the AT&T <EM>curses</EM> implementations, in that the echo bit is cleared
280 when <EM>curses</EM> initializes the terminal state. BSD <EM>curses</EM> differed from
281 this slightly; it left the echo bit on at initialization, but the BSD
282 <STRONG>raw</STRONG> call turned it off as a side-effect. For best portability, set
283 <STRONG>echo</STRONG> or <STRONG>noecho</STRONG> explicitly just after initialization, even if your
284 program remains in cooked mode.
286 The XSI Curses standard is ambiguous on the question of whether <STRONG>raw</STRONG>
287 should disable the CRLF translations controlled by <STRONG>nl</STRONG> and <STRONG>nonl</STRONG>. BSD
288 <EM>curses</EM> did turn off these translations; AT&T <EM>curses</EM> (at least as late
289 as SVr1) did not. We chose to do so, on the theory that a programmer
290 requesting raw input wants a clean (ideally 8-bit clean) connection
291 that the operating system will not alter.
293 When <STRONG>keypad</STRONG> is first enabled, <EM>ncurses</EM> loads the key-definitions for the
294 current terminal description. If the terminal description includes
295 extended string capabilities, e.g., from using the <STRONG>-x</STRONG> option of <STRONG>tic</STRONG>,
296 then <EM>ncurses</EM> also defines keys for the capabilities whose names begin
297 with "k". The corresponding keycodes are generated and (depending on
298 previous loads of terminal descriptions) may differ from one execution
299 of a program to the next. The generated keycodes are recognized by the
300 <STRONG>keyname</STRONG> function (which will then return a name beginning with "k"
301 denoting the terminfo capability name rather than "K", used for <EM>curses</EM>
302 key-names). On the other hand, an application can use <STRONG>define_key</STRONG> to
303 establish a specific keycode for a given string. This makes it
304 possible for an application to check for an extended capability's
305 presence with <STRONG>tigetstr</STRONG>, and reassign the keycode to match its own
308 Low-level applications can use <STRONG>tigetstr</STRONG> to obtain the definition of any
309 particular string capability. Higher-level applications which use the
310 <EM>curses</EM> <STRONG>wgetch</STRONG> and similar functions to return keycodes rely upon the
311 order in which the strings are loaded. If more than one key definition
312 has the same string value, then <STRONG>wgetch</STRONG> can return only one keycode.
313 Most <EM>curses</EM> implementations (including <EM>ncurses</EM>) load key definitions in
314 the order defined by the array of string capability names. The last
315 key to be loaded determines the keycode which will be returned. In
316 <EM>ncurses</EM>, you may also have extended capabilities interpreted as key
317 definitions. These are loaded after the predefined keys, and if a
318 capability's value is the same as a previously-loaded key definition,
319 the later definition is the one used.
322 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
323 Note that <STRONG>echo</STRONG>, <STRONG>noecho</STRONG>, <STRONG>halfdelay</STRONG>, <STRONG>intrflush</STRONG>, <STRONG>meta</STRONG>, <STRONG>nl</STRONG>, <STRONG>nonl</STRONG>, <STRONG>nodelay</STRONG>,
324 <STRONG>notimeout</STRONG>, <STRONG>noqiflush</STRONG>, <STRONG>qiflush</STRONG>, <STRONG>timeout</STRONG>, and <STRONG>wtimeout</STRONG> may be macros.
326 The <STRONG>noraw</STRONG> and <STRONG>nocbreak</STRONG> calls follow historical practice in that they
327 attempt to restore to normal ("cooked") mode from raw and cbreak modes
328 respectively. Mixing raw/noraw and cbreak/nocbreak calls leads to tty
329 driver control states that are hard to predict or understand; it is not
333 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
334 <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG>, <STRONG><A HREF="curs_initscr.3x.html">curs_initscr(3x)</A></STRONG>, <STRONG><A HREF="curs_util.3x.html">curs_util(3x)</A></STRONG>,
335 <STRONG><A HREF="define_key.3x.html">define_key(3x)</A></STRONG>, <STRONG>termios(3)</STRONG>
339 ncurses 6.4 2023-10-21 <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>
343 <li><a href="#h2-NAME">NAME</a></li>
344 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
345 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
347 <li><a href="#h3-cbreak_nocbreak">cbreak/nocbreak</a></li>
348 <li><a href="#h3-echo_noecho">echo/noecho</a></li>
349 <li><a href="#h3-halfdelay">halfdelay</a></li>
350 <li><a href="#h3-intrflush">intrflush</a></li>
351 <li><a href="#h3-keypad">keypad</a></li>
352 <li><a href="#h3-meta">meta</a></li>
353 <li><a href="#h3-nl_nonl">nl/nonl</a></li>
354 <li><a href="#h3-nodelay">nodelay</a></li>
355 <li><a href="#h3-notimeout">notimeout</a></li>
356 <li><a href="#h3-raw_noraw">raw/noraw</a></li>
357 <li><a href="#h3-qiflush_noqiflush">qiflush/noqiflush</a></li>
358 <li><a href="#h3-timeout_wtimeout">timeout/wtimeout</a></li>
359 <li><a href="#h3-typeahead">typeahead</a></li>
362 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
363 <li><a href="#h2-EXTENSIONS">EXTENSIONS</a></li>
364 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
365 <li><a href="#h2-NOTES">NOTES</a></li>
366 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>