blob: 7b5a17b8f1256364f6e3ceaa97be2ec8e2be6c46 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
2.\" Copyright (c) 1998-2003,2005 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.13 2005/05/15 16:18:07 tom Exp $
30.TH curs_inopts 3X ""
31.na
32.hy 0
33.SH NAME
34\fBcbreak\fR,
35\fBnocbreak\fR,
36\fBecho\fR,
37\fBnoecho\fR,
38\fBhalfdelay\fR,
39\fBintrflush\fR,
40\fBkeypad\fR,
41\fBmeta\fR,
42\fBnodelay\fR,
43\fBnotimeout\fR,
44\fBraw\fR,
45\fBnoraw\fR,
46\fBnoqiflush\fR,
47\fBqiflush\fR,
48\fBtimeout\fR,
49\fBwtimeout\fR,
50\fBtypeahead\fR - \fBcurses\fR input options
51.ad
52.hy
53.SH SYNOPSIS
54\fB#include <curses.h>\fR
55.PP
56\fBint cbreak(void);\fR
57.br
58\fBint nocbreak(void);\fR
59.br
60\fBint echo(void);\fR
61.br
62\fBint noecho(void);\fR
63.br
64\fBint halfdelay(int tenths);\fR
65.br
66\fBint intrflush(WINDOW *win, bool bf);\fR
67.br
68\fBint keypad(WINDOW *win, bool bf);\fR
69.br
70\fBint meta(WINDOW *win, bool bf);\fR
71.br
72\fBint nodelay(WINDOW *win, bool bf);\fR
73.br
74\fBint raw(void);\fR
75.br
76\fBint noraw(void);\fR
77.br
78\fBvoid noqiflush(void);\fR
79.br
80\fBvoid qiflush(void);\fR
81.br
82\fBint notimeout(WINDOW *win, bool bf);\fR
83.br
84\fBvoid timeout(int delay);\fR
85.br
86\fBvoid wtimeout(WINDOW *win, int delay);\fR
87.br
88\fBint typeahead(int fd);\fR
89.br
90.SH DESCRIPTION
91Normally, the tty driver buffers typed characters until a newline or carriage
92return is typed. The \fBcbreak\fR routine disables line buffering and
93erase/kill character-processing (interrupt and flow control characters are
94unaffected), making characters typed by the user immediately available to the
95program. The \fBnocbreak\fR routine returns the terminal to normal (cooked)
96mode.
97.PP
98Initially the terminal may or may not be in \fBcbreak\fR mode, as the mode is
99inherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fR
100explicitly. Most interactive programs using \fBcurses\fR set the \fBcbreak\fR
101mode. Note that \fBcbreak\fR overrides \fBraw\fR.
102[See \fBcurs_getch\fR(3X) for a
103discussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.]
104.PP
105The \fBecho\fR and \fBnoecho\fR routines control whether characters typed by
106the user are echoed by \fBgetch\fR as they are typed. Echoing by the tty
107driver is always disabled, but initially \fBgetch\fR is in echo mode, so
108characters typed are echoed. Authors of most interactive programs prefer to do
109their own echoing in a controlled area of the screen, or not to echo at all, so
110they disable echoing by calling \fBnoecho\fR.
111[See \fBcurs_getch\fR(3X) for a
112discussion of how these routines interact with \fBcbreak\fR and
113\fBnocbreak\fR.]
114.PP
115The \fBhalfdelay\fR routine is used for half-delay mode, which is similar to
116\fBcbreak\fR mode in that characters typed by the user are immediately
117available to the program. However, after blocking for \fItenths\fR tenths of
118seconds, ERR is returned if nothing has been typed. The value of \fBtenths\fR
119must be a number between 1 and 255. Use \fBnocbreak\fR to leave half-delay
120mode.
121.PP
122If the \fBintrflush\fR option is enabled, (\fIbf\fR is \fBTRUE\fR), when an
123interrupt key is pressed on the keyboard (interrupt, break, quit) all output in
124the tty driver queue will be flushed, giving the effect of faster response to
125the interrupt, but causing \fBcurses\fR to have the wrong idea of what is on
126the screen. Disabling (\fIbf\fR is \fBFALSE\fR), the option prevents the
127flush. The default for the option is inherited from the tty driver settings.
128The window argument is ignored.
129.PP
130The \fBkeypad\fR option enables the keypad of the user's terminal. If
131enabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key
132(such as an arrow key) and \fBwgetch\fR returns a single value
133representing the function key, as in \fBKEY_LEFT\fR. If disabled
134(\fIbf\fR is \fBFALSE\fR), \fBcurses\fR does not treat function keys
135specially and the program has to interpret the escape sequences
136itself. If the keypad in the terminal can be turned on (made to
137transmit) and off (made to work locally), turning on this option
138causes the terminal keypad to be turned on when \fBwgetch\fR is
139called. The default value for keypad is false.
140.PP
141Initially, whether the terminal returns 7 or 8 significant bits on
142input depends on the control mode of the tty driver [see termio(7)].
143To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR,
144\fBTRUE\fR); this is equivalent, under POSIX, to setting the CS8 flag
145on the terminal. To force 7 bits to be returned, invoke
146\fBmeta\fR(\fIwin\fR, \fBFALSE\fR); this is equivalent, under POSIX,
147to setting the CS7 flag on the terminal. The window argument,
148\fIwin\fR, is always ignored. If the terminfo capabilities \fBsmm\fR
149(meta_on) and \fBrmm\fR (meta_off) are defined for the terminal,
150\fBsmm\fR is sent to the terminal when \fBmeta\fR(\fIwin\fR,
151\fBTRUE\fR) is called and \fBrmm\fR is sent when \fBmeta\fR(\fIwin\fR,
152\fBFALSE\fR) is called.
153.PP
154The \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call.
155If no input is ready, \fBgetch\fR returns \fBERR\fR. If disabled
156(\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed.
157.PP
158While interpreting an input escape sequence, \fBwgetch\fR sets a timer
159while waiting for the next character. If \fBnotimeout(\fR\fIwin\fR,
160\fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer. The
161purpose of the timeout is to differentiate between sequences received
162from a function key and those typed by a user.
163.PP
164The \fBraw\fR and \fBnoraw\fR routines place the terminal into or out of raw
165mode. Raw mode is similar to \fBcbreak\fR mode, in that characters typed are
166immediately passed through to the user program. The differences are that in
167raw mode, the interrupt, quit, suspend, and flow control characters are all
168passed through uninterpreted, instead of generating a signal. The behavior of
169the BREAK key depends on other bits in the tty driver that are not set by
170\fBcurses\fR.
171.PP
172When the \fBnoqiflush\fR routine is used, normal flush of input and
173output queues associated with the \fBINTR\fR, \fBQUIT\fR and
174\fBSUSP\fR characters will not be done [see termio(7)]. When
175\fBqiflush\fR is called, the queues will be flushed when these control
176characters are read. You may want to call \fBnoqiflush()\fR in a signal
177handler if you want output to continue as though the interrupt
178had not occurred, after the handler exits.
179.PP
180The \fBtimeout\fR and \fBwtimeout\fR routines set blocking or
181non-blocking read for a given window. If \fIdelay\fR is negative,
182blocking read is used (i.e., waits indefinitely for
183input). If \fIdelay\fR is zero, then non-blocking read is used
184(i.e., read returns \fBERR\fR if no input is waiting). If
185\fIdelay\fR is positive, then read blocks for \fIdelay\fR
186milliseconds, and returns \fBERR\fR if there is still no input.
187Hence, these routines provide the same functionality as \fBnodelay\fR,
188plus the additional capability of being able to block for only
189\fIdelay\fR milliseconds (where \fIdelay\fR is positive).
190.PP
191The \fBcurses\fR library does ``line-breakout optimization'' by looking for
192typeahead periodically while updating the screen. If input is found,
193and it is coming from a tty, the current update is postponed until
194\fBrefresh\fR or \fBdoupdate\fR is called again. This allows faster
195response to commands typed in advance. Normally, the input FILE
196pointer passed to \fBnewterm\fR, or \fBstdin\fR in the case that
197\fBinitscr\fR was used, will be used to do this typeahead checking.
198The \fBtypeahead\fR routine specifies that the file descriptor
199\fIfd\fR is to be used to check for typeahead instead. If \fIfd\fR is
200-1, then no typeahead checking is done.
201.SH RETURN VALUE
202All routines that return an integer return \fBERR\fR upon failure and OK (SVr4
203specifies only "an integer value other than \fBERR\fR") upon successful
204completion, unless otherwise noted in the preceding routine descriptions.
205.PP
206X/Open does not define any error conditions.
207In this implementation,
208functions with a window parameter will return an error if it is null.
209Any function will also return an error if the terminal was not initialized.
210Also,
211.RS
212.TP 5
213\fBhalfdelay\fP
214returns an error
215if its parameter is outside the range 1..255.
216.RE
217.SH PORTABILITY
218These functions are described in the XSI Curses standard, Issue 4.
219.PP
220The ncurses library obeys the XPG4 standard and the historical practice of the
221AT&T curses implementations, in that the echo bit is cleared when curses
222initializes the terminal state. BSD curses differed from this slightly; it
223left the echo bit on at initialization, but the BSD \fBraw\fR call turned it
224off as a side-effect. For best portability, set echo or noecho explicitly
225just after initialization, even if your program remains in cooked mode.
226.SH NOTES
227Note that \fBecho\fR, \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR,
228\fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBnoqiflush\fR,
229\fBqiflush\fR, \fBtimeout\fR, and \fBwtimeout\fR may be macros.
230.PP
231The \fBnoraw\fR and \fBnocbreak\fR calls follow historical practice in that
232they attempt to restore to normal (`cooked') mode from raw and cbreak modes
233respectively. Mixing raw/noraw and cbreak/nocbreak calls leads to tty driver
234control states that are hard to predict or understand; it is not recommended.
235.SH SEE ALSO
236\fBcurses\fR(3X), \fBcurs_getch\fR(3X), \fBcurs_initscr\fR(3X), \fBtermio\fR(7)
237.\"#
238.\"# The following sets edit modes for GNU EMACS
239.\"# Local Variables:
240.\"# mode:nroff
241.\"# fill-column:79
242.\"# End: