blob: 7b9a1be310f1b9b713bafe57edc275d9c28dbfaf [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
Steve Kondikae271bc2015-11-15 02:50:53 +01002.\" Copyright (c) 1998-2013,2015 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05303.\" *
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.\"
Steve Kondikae271bc2015-11-15 02:50:53 +010029.\" $Id: curs_inopts.3x,v 1.19 2015/04/11 10:21:38 tom Exp $
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053030.TH curs_inopts 3X ""
Steve Kondikae271bc2015-11-15 02:50:53 +010031.ie \n(.g .ds `` \(lq
32.el .ds `` ``
33.ie \n(.g .ds '' \(rq
34.el .ds '' ''
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053035.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,
Steve Kondikae271bc2015-11-15 02:50:53 +010054\fBtypeahead\fR \- \fBcurses\fR input options
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053055.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
Steve Kondikae271bc2015-11-15 02:50:53 +010095The \fBncurses\fP library provides several functions which let an application
96change way input from the terminal is handled.
97Some are global, applying to all windows.
98Others apply only to a specific window.
99Window-specific settings are not automatically applied to new or derived
100windows.
101An application must apply these to each window, if the same behavior
102is needed.
103.\"
104.SS cbreak
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530105Normally, the tty driver buffers typed characters until a newline or carriage
Steve Kondikae271bc2015-11-15 02:50:53 +0100106return is typed.
107The \fBcbreak\fR routine disables line buffering and
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530108erase/kill character-processing (interrupt and flow control characters are
109unaffected), making characters typed by the user immediately available to the
Steve Kondikae271bc2015-11-15 02:50:53 +0100110program.
111The \fBnocbreak\fR routine returns the terminal to normal (cooked)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530112mode.
113.PP
114Initially the terminal may or may not be in \fBcbreak\fR mode, as the mode is
115inherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fR
Steve Kondikae271bc2015-11-15 02:50:53 +0100116explicitly.
117Most interactive programs using \fBcurses\fR set the \fBcbreak\fR
118mode.
119Note that \fBcbreak\fR overrides \fBraw\fR.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530120[See \fBcurs_getch\fR(3X) for a
121discussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.]
Steve Kondikae271bc2015-11-15 02:50:53 +0100122.\"
123.SS echo/noecho
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530124.PP
125The \fBecho\fR and \fBnoecho\fR routines control whether characters typed by
Steve Kondikae271bc2015-11-15 02:50:53 +0100126the user are echoed by \fBgetch\fR as they are typed.
127Echoing by the tty
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530128driver is always disabled, but initially \fBgetch\fR is in echo mode, so
Steve Kondikae271bc2015-11-15 02:50:53 +0100129characters typed are echoed.
130Authors of most interactive programs prefer to do
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530131their own echoing in a controlled area of the screen, or not to echo at all, so
132they disable echoing by calling \fBnoecho\fR.
133[See \fBcurs_getch\fR(3X) for a
134discussion of how these routines interact with \fBcbreak\fR and
135\fBnocbreak\fR.]
Steve Kondikae271bc2015-11-15 02:50:53 +0100136.\"
137.SS halfdelay
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530138.PP
139The \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
Steve Kondikae271bc2015-11-15 02:50:53 +0100141available to the program.
142However, after blocking for \fItenths\fR tenths of
143seconds, ERR is returned if nothing has been typed.
144The value of \fBtenths\fR
145must be a number between 1 and 255.
146Use \fBnocbreak\fR to leave half-delay
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530147mode.
Steve Kondikae271bc2015-11-15 02:50:53 +0100148.\"
149.SS intrflush
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530150.PP
151If the \fBintrflush\fR option is enabled, (\fIbf\fR is \fBTRUE\fR), when an
152interrupt key is pressed on the keyboard (interrupt, break, quit) all output in
153the tty driver queue will be flushed, giving the effect of faster response to
154the interrupt, but causing \fBcurses\fR to have the wrong idea of what is on
Steve Kondikae271bc2015-11-15 02:50:53 +0100155the screen.
156Disabling (\fIbf\fR is \fBFALSE\fR), the option prevents the
157flush.
158The default for the option is inherited from the tty driver settings.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530159The window argument is ignored.
Steve Kondikae271bc2015-11-15 02:50:53 +0100160.\"
161.SS keypad
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530162.PP
Steve Kondikae271bc2015-11-15 02:50:53 +0100163The \fBkeypad\fR option enables the keypad of the user's terminal.
164If
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530165enabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key
166(such as an arrow key) and \fBwgetch\fR returns a single value
Steve Kondikae271bc2015-11-15 02:50:53 +0100167representing the function key, as in \fBKEY_LEFT\fR.
168If disabled
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530169(\fIbf\fR is \fBFALSE\fR), \fBcurses\fR does not treat function keys
170specially and the program has to interpret the escape sequences
Steve Kondikae271bc2015-11-15 02:50:53 +0100171itself.
172If the keypad in the terminal can be turned on (made to
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530173transmit) and off (made to work locally), turning on this option
174causes the terminal keypad to be turned on when \fBwgetch\fR is
Steve Kondikae271bc2015-11-15 02:50:53 +0100175called.
176The default value for keypad is \fBFALSE\fP.
177.\"
178.SS meta
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530179.PP
180Initially, whether the terminal returns 7 or 8 significant bits on
181input depends on the control mode of the tty driver [see termio(7)].
182To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR,
183\fBTRUE\fR); this is equivalent, under POSIX, to setting the CS8 flag
Steve Kondikae271bc2015-11-15 02:50:53 +0100184on the terminal.
185To force 7 bits to be returned, invoke
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530186\fBmeta\fR(\fIwin\fR, \fBFALSE\fR); this is equivalent, under POSIX,
Steve Kondikae271bc2015-11-15 02:50:53 +0100187to setting the CS7 flag on the terminal.
188The window argument,
189\fIwin\fR, is always ignored.
190If the terminfo capabilities \fBsmm\fR
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530191(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.
Steve Kondikae271bc2015-11-15 02:50:53 +0100195.\"
196.SS nodelay
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530197.PP
198The \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call.
Steve Kondikae271bc2015-11-15 02:50:53 +0100199If no input is ready, \fBgetch\fR returns \fBERR\fR.
200If disabled
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530201(\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed.
202.PP
203While interpreting an input escape sequence, \fBwgetch\fR sets a timer
Steve Kondikae271bc2015-11-15 02:50:53 +0100204while waiting for the next character.
205If \fBnotimeout(\fR\fIwin\fR,
206\fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer.
207The
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530208purpose of the timeout is to differentiate between sequences received
209from a function key and those typed by a user.
Steve Kondikae271bc2015-11-15 02:50:53 +0100210.\"
211.SS raw/noraw
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530212.PP
213The \fBraw\fR and \fBnoraw\fR routines place the terminal into or out of raw
Steve Kondikae271bc2015-11-15 02:50:53 +0100214mode.
215Raw mode is similar to \fBcbreak\fR mode, in that characters typed are
216immediately passed through to the user program.
217The differences are that in
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530218raw mode, the interrupt, quit, suspend, and flow control characters are all
Steve Kondikae271bc2015-11-15 02:50:53 +0100219passed through uninterpreted, instead of generating a signal.
220The behavior of
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530221the BREAK key depends on other bits in the tty driver that are not set by
222\fBcurses\fR.
Steve Kondikae271bc2015-11-15 02:50:53 +0100223.\"
224.SS noqiflush
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530225.PP
226When the \fBnoqiflush\fR routine is used, normal flush of input and
227output queues associated with the \fBINTR\fR, \fBQUIT\fR and
Steve Kondikae271bc2015-11-15 02:50:53 +0100228\fBSUSP\fR characters will not be done [see termio(7)].
229When
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530230\fBqiflush\fR is called, the queues will be flushed when these control
Steve Kondikae271bc2015-11-15 02:50:53 +0100231characters are read.
232You may want to call \fBnoqiflush()\fR in a signal
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530233handler if you want output to continue as though the interrupt
234had not occurred, after the handler exits.
Steve Kondikae271bc2015-11-15 02:50:53 +0100235.\"
236.SS timeout/wtimeout
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530237.PP
238The \fBtimeout\fR and \fBwtimeout\fR routines set blocking or
Steve Kondikae271bc2015-11-15 02:50:53 +0100239non-blocking read for a given window.
240If \fIdelay\fR is negative,
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530241blocking read is used (i.e., waits indefinitely for
Steve Kondikae271bc2015-11-15 02:50:53 +0100242input).
243If \fIdelay\fR is zero, then non-blocking read is used
244(i.e., read returns \fBERR\fR if no input is waiting).
245If
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530246\fIdelay\fR is positive, then read blocks for \fIdelay\fR
247milliseconds, and returns \fBERR\fR if there is still no input.
248Hence, these routines provide the same functionality as \fBnodelay\fR,
249plus the additional capability of being able to block for only
250\fIdelay\fR milliseconds (where \fIdelay\fR is positive).
Steve Kondikae271bc2015-11-15 02:50:53 +0100251.\"
252.SS typeahead
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530253.PP
Steve Kondikae271bc2015-11-15 02:50:53 +0100254The \fBcurses\fR library does \*(``line-breakout optimization\*(''
255by looking for typeahead periodically while updating the screen.
256If input is found, and it is coming from a tty,
257the current update is postponed until
258\fBrefresh\fR or \fBdoupdate\fR is called again.
259This allows faster response to commands typed in advance.
260Normally, the input FILE
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530261pointer passed to \fBnewterm\fR, or \fBstdin\fR in the case that
262\fBinitscr\fR was used, will be used to do this typeahead checking.
263The \fBtypeahead\fR routine specifies that the file descriptor
Steve Kondikae271bc2015-11-15 02:50:53 +0100264\fIfd\fR is to be used to check for typeahead instead.
265If \fIfd\fR is
266\-1, then no typeahead checking is done.
267.\"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530268.SH RETURN VALUE
269All routines that return an integer return \fBERR\fR upon failure and OK (SVr4
270specifies only "an integer value other than \fBERR\fR") upon successful
271completion, unless otherwise noted in the preceding routine descriptions.
272.PP
273X/Open does not define any error conditions.
274In this implementation,
275functions with a window parameter will return an error if it is null.
276Any function will also return an error if the terminal was not initialized.
277Also,
278.RS
279.TP 5
280\fBhalfdelay\fP
281returns an error
282if its parameter is outside the range 1..255.
283.RE
284.SH PORTABILITY
285These functions are described in the XSI Curses standard, Issue 4.
286.PP
287The ncurses library obeys the XPG4 standard and the historical practice of the
288AT&T curses implementations, in that the echo bit is cleared when curses
Steve Kondikae271bc2015-11-15 02:50:53 +0100289initializes the terminal state.
290BSD curses differed from this slightly; it
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530291left the echo bit on at initialization, but the BSD \fBraw\fR call turned it
Steve Kondikae271bc2015-11-15 02:50:53 +0100292off as a side-effect.
293For best portability, set echo or noecho explicitly
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530294just after initialization, even if your program remains in cooked mode.
Steve Kondikae271bc2015-11-15 02:50:53 +0100295.PP
296When \fBkeypad\fP is first enabled,
297ncurses loads the key-definitions for the current terminal description.
298If the terminal description includes extended string capabilities,
299e.g., from using the \fB\-x\fP option of @TIC@,
300then ncurses also defines keys for the capabilities whose names
301begin with "k".
302The corresponding keycodes are generated and (depending on previous
303loads of terminal descriptions) may differ from one execution of a
304program to the next.
305The generated keycodes are recognized by the \fBkeyname\fP function
306(which will then return a name beginning with "k" denoting the
307terminfo capability name rather than "K", used for curses key-names).
308On the other hand, an application can use \fBdefine_key\fP to establish
309a specific keycode for a given string.
310This makes it possible for an application to check for an extended
311capability's presence with \fItigetstr\fP,
312and reassign the keycode to match its own needs.
313.PP
314Low-level applications can use \fBtigetstr\fP to obtain the definition
315of any particular string capability.
316Higher-level applications which use the curses \fBwgetch\fP
317and similar functions to return keycodes rely upon the order in which
318the strings are loaded.
319If more than one key definition has the same string value,
320then \fBwgetch\fP can return only one keycode.
321Most curses implementations (including ncurses)
322load key definitions in the order
323defined by the array of string capability names.
324The last key to be loaded determines the keycode which will be returned.
325In ncurses, you may also have extended capabilities interpreted as
326key definitions.
327These are loaded after the predefined keys,
328and if a capability's value is the same as a previously-loaded
329key definition,
330the later definition is the one used.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530331.SH NOTES
332Note that \fBecho\fR, \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR,
333\fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBnoqiflush\fR,
334\fBqiflush\fR, \fBtimeout\fR, and \fBwtimeout\fR may be macros.
335.PP
336The \fBnoraw\fR and \fBnocbreak\fR calls follow historical practice in that
337they attempt to restore to normal (`cooked') mode from raw and cbreak modes
Steve Kondikae271bc2015-11-15 02:50:53 +0100338respectively.
339Mixing raw/noraw and cbreak/nocbreak calls leads to tty driver
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530340control states that are hard to predict or understand; it is not recommended.
341.SH SEE ALSO
Steve Kondikae271bc2015-11-15 02:50:53 +0100342\fBcurses\fR(3X),
343\fBcurs_getch\fR(3X),
344\fBcurs_initscr\fR(3X),
345\fBcurs_util\fR(3X),
346\fBdefine_key\fR(3X),
347\fBtermio\fR(7)