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