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