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