1curs_inopts(3CURSES) Curses Library Functions curs_inopts(3CURSES)
2
3
4
6 curs_inopts, cbreak, nocbreak, echo, noecho, halfdelay, intrflush, key‐
7 pad, meta, nodelay, notimeout, raw, noraw, noqiflush, qiflush, timeout,
8 wtimeout, typeahead - curses terminal input option control routines
9
11 cc [ flag ... ] file ... -lcurses [ library ... ]
12 #include <curses.h>
13
14 int cbreak(void);
15
16
17 int nocbreak(void);
18
19
20 int echo(void);
21
22
23 int noecho(void);
24
25
26 int halfdelay(int tenths);
27
28
29 int intrflush(WINDOW *win, bool bf);
30
31
32 int keypad(WINDOW *win, bool bf);
33
34
35 int meta(WINDOW *win, bool bf);
36
37
38 int nodelay(WINDOW *win, bool bf);
39
40
41 int notimeout(WINDOW *win, bool bf);
42
43
44 int raw(void);
45
46
47 int noraw(void);
48
49
50 void noqiflush(void);
51
52
53 void qiflush(void);
54
55
56 void timeout(int delay);
57
58
59 void wtimeout(WINDOW *win, int delay);
60
61
62 int typeahead(int fildes);
63
64
66 The cbreak() and nocbreak() routines put the terminal into and out of
67 cbreak() mode, respectively. In this mode, characters typed by the user
68 are immediately available to the program, and erase/kill character-pro‐
69 cessing is not performed. When out of this mode, the tty driver buffers
70 the typed characters until a newline or carriage return is typed.
71 Interrupt and flow control characters are unaffected by this mode. Ini‐
72 tially the terminal may or may not be in cbreak() mode, as the mode is
73 inherited; therefore, a program should call cbreak() or nocbreak()
74 explicitly. Most interactive programs using curses set the cbreak()
75 mode.
76
77
78 Note that cbreak() overrides raw(). (See curs_getch(3CURSES) for a dis‐
79 cussion of how these routines interact with echo() and noecho().)
80
81
82 The echo() and noecho() routines control whether characters typed by
83 the user are echoed by getch() as they are typed. Echoing by the tty
84 driver is always disabled, but initially getch() is in echo mode, so
85 characters typed are echoed. Authors of most interactive programs pre‐
86 fer to do their own echoing in a controlled area of the screen, or not
87 to echo at all, so they disable echoing by calling noecho(). (See
88 curs_getch(3CURSES) for a discussion of how these routines interact
89 with cbreak() and nocbreak().)
90
91
92 The halfdelay() routine is used for half-delay mode, which is similar
93 to cbreak() mode in that characters typed by the user are immediately
94 available to the program. However, after blocking for tenths tenths of
95 seconds, ERR is returned if nothing has been typed. The value of tenths
96 must be a number between 1 and 255. Use nocbreak() to leave half-delay
97 mode.
98
99
100 If the intrflush() option is enabled, (bf is TRUE), when an interrupt
101 key is pressed on the keyboard (interrupt, break, quit) all output in
102 the tty driver queue will be flushed, giving the effect of faster
103 response to the interrupt, but causing curses to have the wrong idea of
104 what is on the screen. Disabling (bf is FALSE), the option prevents the
105 flush. The default for the option is inherited from the tty driver set‐
106 tings. The window argument is ignored.
107
108
109 The keypad() option enables the keypad of the user's terminal. If
110 enabled (bf is TRUE), the user can press a function key (such as an
111 arrow key) and wgetch() returns a single value representing the func‐
112 tion key, as in KEY_LEFT. If disabled (bf is FALSE), curses does not
113 treat function keys specially and the program has to interpret the
114 escape sequences itself. If the keypad in the terminal can be turned on
115 (made to transmit) and off (made to work locally), turning on this
116 option causes the terminal keypad to be turned on when wgetch() is
117 called. The default value for keypad is false.
118
119
120 Initially, whether the terminal returns 7 or 8 significant bits on
121 input depends on the control mode of the tty driver (see termio(7I)).
122 To force 8 bits to be returned, invoke meta(win, TRUE). To force 7
123 bits to be returned, invoke meta(win, FALSE). The window argument,
124 win, is always ignored. If the terminfo capabilities smm (meta_on) and
125 rmm (meta_off) are defined for the terminal, smm is sent to the termi‐
126 nal when meta( win, TRUE) is called and rmm is sent when meta(win,
127 FALSE) is called.
128
129
130 The nodelay() option causes getch() to be a non-blocking call. If no
131 input is ready, getch() returns ERR. If disabled (bf is FALSE), getch()
132 waits until a key is pressed.
133
134
135 While interpreting an input escape sequence, wgetch() sets a timer
136 while waiting for the next character. If notimeout(win, TRUE) is
137 called, then wgetch() does not set a timer. The purpose of the timeout
138 is to differentiate between sequences received from a function key and
139 those typed by a user.
140
141
142 With the raw() and noraw() routines, the terminal is placed into or out
143 of raw mode. Raw mode is similar to cbreak() mode, in that characters
144 typed are immediately passed through to the user program. The differ‐
145 ences are that in raw mode, the interrupt, quit, suspend, and flow con‐
146 trol characters are all passed through uninterpreted, instead of gener‐
147 ating a signal. The behavior of the BREAK key depends on other bits in
148 the tty driver that are not set by curses.
149
150
151 When the noqiflush() routine is used, normal flush of input and output
152 queues associated with the INTR, QUIT and SUSP characters will not be
153 done (see termio(7I)). When qiflush() is called, the queues will be
154 flushed when these control characters are read.
155
156
157 The timeout() and wtimeout() routines set blocking or non-blocking read
158 for a given window. If delay is negative, blocking read is used (that
159 is, waits indefinitely for input). If delay is zero, then non-blocking
160 read is used (that is, read returns ERR if no input is waiting). If
161 delay is positive, then read blocks for delay milliseconds, and returns
162 ERR if there is still no input. Hence, these routines provide the same
163 functionality as nodelay(), plus the additional capability of being
164 able to block for only delay milliseconds (where delay is positive).
165
166
167 curses does ``line-breakout optimization'' by looking for typeahead
168 periodically while updating the screen. If input is found, and it is
169 coming from a tty, the current update is postponed until refresh() or
170 doupdate() is called again. This allows faster response to commands
171 typed in advance. Normally, the input FILE pointer passed to newterm(),
172 or stdin in the case that initscr() was used, will be used to do this
173 typeahead checking. The typeahead() routine specifies that the file
174 descriptor fildes is to be used to check for typeahead instead. If
175 fildes is −1, then no typeahead checking is done.
176
178 All routines that return an integer return ERR upon failure and an
179 integer value other than ERR upon successful completion, unless other‐
180 wise noted in the preceding routine descriptions.
181
183 See attributes(5) for descriptions of the following attributes:
184
185
186
187
188 ┌─────────────────────────────┬─────────────────────────────┐
189 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
190 ├─────────────────────────────┼─────────────────────────────┤
191 │MT-Level │Unsafe │
192 └─────────────────────────────┴─────────────────────────────┘
193
195 curs_getch(3CURSES), curs_initscr(3CURSES), curses(3CURSES),
196 attributes(5), termio(7I)
197
199 The header <curses.h> automatically includes the headers <stdio.h> and
200 <unctrl.h>.
201
202
203 Note that echo(), noecho(), halfdelay(), intrflush(), meta(), node‐
204 lay(), notimeout(), noqiflush(), qiflush(), timeout(), and wtimeout()
205 may be macros.
206
207
208
209SunOS 5.11 31 Dec 1996 curs_inopts(3CURSES)