diff options
Diffstat (limited to 'scripts/kconfig/libcurses/inopts.c')
-rw-r--r-- | scripts/kconfig/libcurses/inopts.c | 408 |
1 files changed, 408 insertions, 0 deletions
diff --git a/scripts/kconfig/libcurses/inopts.c b/scripts/kconfig/libcurses/inopts.c new file mode 100644 index 000000000..30e18f611 --- /dev/null +++ b/scripts/kconfig/libcurses/inopts.c | |||
@@ -0,0 +1,408 @@ | |||
1 | /* PDCurses */ | ||
2 | |||
3 | #include "curspriv.h" | ||
4 | |||
5 | /*man-start************************************************************** | ||
6 | |||
7 | inopts | ||
8 | ------ | ||
9 | |||
10 | ### Synopsis | ||
11 | |||
12 | int cbreak(void); | ||
13 | int nocbreak(void); | ||
14 | int echo(void); | ||
15 | int noecho(void); | ||
16 | int halfdelay(int tenths); | ||
17 | int intrflush(WINDOW *win, bool bf); | ||
18 | int keypad(WINDOW *win, bool bf); | ||
19 | int meta(WINDOW *win, bool bf); | ||
20 | int nl(void); | ||
21 | int nonl(void); | ||
22 | int nodelay(WINDOW *win, bool bf); | ||
23 | int notimeout(WINDOW *win, bool bf); | ||
24 | int raw(void); | ||
25 | int noraw(void); | ||
26 | void noqiflush(void); | ||
27 | void qiflush(void); | ||
28 | void timeout(int delay); | ||
29 | void wtimeout(WINDOW *win, int delay); | ||
30 | int wgetdelay(const WINDOW *win); | ||
31 | int typeahead(int fildes); | ||
32 | |||
33 | int crmode(void); | ||
34 | int nocrmode(void); | ||
35 | |||
36 | bool is_keypad(const WINDOW *win); | ||
37 | bool is_nodelay(const WINDOW *win); | ||
38 | bool is_notimeout(const WINDOW *win); | ||
39 | |||
40 | ### Description | ||
41 | |||
42 | cbreak() and nocbreak() toggle cbreak mode. In cbreak mode, | ||
43 | characters typed by the user are made available immediately, and | ||
44 | erase/kill character processing is not performed. In nocbreak mode, | ||
45 | typed characters are buffered until a newline or carriage return. | ||
46 | Interrupt and flow control characters are unaffected by this mode. | ||
47 | PDCurses always starts in cbreak mode. | ||
48 | |||
49 | echo() and noecho() control whether typed characters are echoed by | ||
50 | the input routine. Initially, input characters are echoed. Subsequent | ||
51 | calls to echo() and noecho() do not flush type-ahead. | ||
52 | |||
53 | halfdelay() is similar to cbreak(), but allows for a time limit to be | ||
54 | specified, in tenths of a second. This causes getch() to block for | ||
55 | that period before returning ERR if no key has been received. tenths | ||
56 | must be between 1 and 255. | ||
57 | |||
58 | keypad() controls whether getch() returns function/special keys as | ||
59 | single key codes (e.g., the left arrow key as KEY_LEFT). Per X/Open, | ||
60 | the default for keypad mode is OFF. You'll probably want it on. With | ||
61 | keypad mode off, if a special key is pressed, getch() does nothing or | ||
62 | returns ERR. | ||
63 | |||
64 | nodelay() controls whether wgetch() is a non-blocking call. If the | ||
65 | option is enabled, and no input is ready, wgetch() will return ERR. | ||
66 | If disabled, wgetch() will hang until input is ready. | ||
67 | |||
68 | nl() enables the translation of a carriage return into a newline on | ||
69 | input. nonl() disables this. Initially, the translation does occur. | ||
70 | |||
71 | raw() and noraw() toggle raw mode. Raw mode is similar to cbreak | ||
72 | mode, in that characters typed are immediately passed through to the | ||
73 | user program. The difference is that in raw mode, the INTR, QUIT, | ||
74 | SUSP, and STOP characters are passed through without being | ||
75 | interpreted, and without generating a signal. | ||
76 | |||
77 | In PDCurses, the meta() function sets raw mode on or off. | ||
78 | |||
79 | timeout() and wtimeout() set blocking or non-blocking reads for the | ||
80 | specified window. If the delay is negative, a blocking read is used; | ||
81 | if zero, then non-blocking reads are done -- if no input is waiting, | ||
82 | ERR is returned immediately. If the delay is positive, the read | ||
83 | blocks for the delay period; if the period expires, ERR is returned. | ||
84 | The delay is given in milliseconds, but this is rounded down to 50ms | ||
85 | (1/20th sec) intervals, with a minimum of one interval if a postive | ||
86 | delay is given; i.e., 1-99 will wait 50ms, 100-149 will wait 100ms, | ||
87 | etc. | ||
88 | |||
89 | wgetdelay() returns the delay timeout as set in wtimeout(). | ||
90 | |||
91 | intrflush(), notimeout(), noqiflush(), qiflush() and typeahead() do | ||
92 | nothing in PDCurses, but are included for compatibility with other | ||
93 | curses implementations. | ||
94 | |||
95 | crmode() and nocrmode() are archaic equivalents to cbreak() and | ||
96 | nocbreak(), respectively. | ||
97 | |||
98 | is_keypad() reports whether the specified window is in keypad mode. | ||
99 | |||
100 | is_nodelay() reports whether the specified window is in nodelay mode. | ||
101 | |||
102 | ### Return Value | ||
103 | |||
104 | is_keypad() and is_nodelay() return TRUE or FALSE. is_notimeout() is | ||
105 | provided for compatibility with other curses implementations, and | ||
106 | always returns FALSE. All others return OK on success and ERR on error. | ||
107 | |||
108 | ### Portability | ||
109 | X/Open ncurses NetBSD | ||
110 | cbreak Y Y Y | ||
111 | nocbreak Y Y Y | ||
112 | echo Y Y Y | ||
113 | noecho Y Y Y | ||
114 | halfdelay Y Y Y | ||
115 | intrflush Y Y Y | ||
116 | keypad Y Y Y | ||
117 | meta Y Y Y | ||
118 | nl Y Y Y | ||
119 | nonl Y Y Y | ||
120 | nodelay Y Y Y | ||
121 | notimeout Y Y Y | ||
122 | raw Y Y Y | ||
123 | noraw Y Y Y | ||
124 | noqiflush Y Y Y | ||
125 | qiflush Y Y Y | ||
126 | timeout Y Y Y | ||
127 | wtimeout Y Y Y | ||
128 | wgetdelay - Y - | ||
129 | typeahead Y Y Y | ||
130 | crmode Y Y Y | ||
131 | nocrmode Y Y Y | ||
132 | is_keypad - Y Y | ||
133 | is_nodelay - Y - | ||
134 | is_notimeout - Y - | ||
135 | |||
136 | **man-end****************************************************************/ | ||
137 | |||
138 | int cbreak(void) | ||
139 | { | ||
140 | PDC_LOG(("cbreak() - called\n")); | ||
141 | |||
142 | if (!SP) | ||
143 | return ERR; | ||
144 | |||
145 | SP->cbreak = TRUE; | ||
146 | |||
147 | return OK; | ||
148 | } | ||
149 | |||
150 | int nocbreak(void) | ||
151 | { | ||
152 | PDC_LOG(("nocbreak() - called\n")); | ||
153 | |||
154 | if (!SP) | ||
155 | return ERR; | ||
156 | |||
157 | SP->cbreak = FALSE; | ||
158 | SP->delaytenths = 0; | ||
159 | |||
160 | return OK; | ||
161 | } | ||
162 | |||
163 | int echo(void) | ||
164 | { | ||
165 | PDC_LOG(("echo() - called\n")); | ||
166 | |||
167 | if (!SP) | ||
168 | return ERR; | ||
169 | |||
170 | SP->echo = TRUE; | ||
171 | |||
172 | return OK; | ||
173 | } | ||
174 | |||
175 | int noecho(void) | ||
176 | { | ||
177 | PDC_LOG(("noecho() - called\n")); | ||
178 | |||
179 | if (!SP) | ||
180 | return ERR; | ||
181 | |||
182 | SP->echo = FALSE; | ||
183 | |||
184 | return OK; | ||
185 | } | ||
186 | |||
187 | int halfdelay(int tenths) | ||
188 | { | ||
189 | PDC_LOG(("halfdelay() - called\n")); | ||
190 | |||
191 | if (!SP || tenths < 1 || tenths > 255) | ||
192 | return ERR; | ||
193 | |||
194 | SP->delaytenths = tenths; | ||
195 | |||
196 | return OK; | ||
197 | } | ||
198 | |||
199 | int intrflush(WINDOW *win, bool bf) | ||
200 | { | ||
201 | PDC_LOG(("intrflush() - called\n")); | ||
202 | |||
203 | return OK; | ||
204 | } | ||
205 | |||
206 | int keypad(WINDOW *win, bool bf) | ||
207 | { | ||
208 | PDC_LOG(("keypad() - called\n")); | ||
209 | |||
210 | if (!win) | ||
211 | return ERR; | ||
212 | |||
213 | win->_use_keypad = bf; | ||
214 | |||
215 | return OK; | ||
216 | } | ||
217 | |||
218 | int meta(WINDOW *win, bool bf) | ||
219 | { | ||
220 | PDC_LOG(("meta() - called\n")); | ||
221 | |||
222 | if (!SP) | ||
223 | return ERR; | ||
224 | |||
225 | SP->raw_inp = bf; | ||
226 | |||
227 | return OK; | ||
228 | } | ||
229 | |||
230 | int nl(void) | ||
231 | { | ||
232 | PDC_LOG(("nl() - called\n")); | ||
233 | |||
234 | if (!SP) | ||
235 | return ERR; | ||
236 | |||
237 | SP->autocr = TRUE; | ||
238 | |||
239 | return OK; | ||
240 | } | ||
241 | |||
242 | int nonl(void) | ||
243 | { | ||
244 | PDC_LOG(("nonl() - called\n")); | ||
245 | |||
246 | if (!SP) | ||
247 | return ERR; | ||
248 | |||
249 | SP->autocr = FALSE; | ||
250 | |||
251 | return OK; | ||
252 | } | ||
253 | |||
254 | int nodelay(WINDOW *win, bool flag) | ||
255 | { | ||
256 | PDC_LOG(("nodelay() - called\n")); | ||
257 | |||
258 | if (!win) | ||
259 | return ERR; | ||
260 | |||
261 | win->_nodelay = flag; | ||
262 | |||
263 | return OK; | ||
264 | } | ||
265 | |||
266 | int notimeout(WINDOW *win, bool flag) | ||
267 | { | ||
268 | PDC_LOG(("notimeout() - called\n")); | ||
269 | |||
270 | return OK; | ||
271 | } | ||
272 | |||
273 | int raw(void) | ||
274 | { | ||
275 | PDC_LOG(("raw() - called\n")); | ||
276 | |||
277 | if (!SP) | ||
278 | return ERR; | ||
279 | |||
280 | PDC_set_keyboard_binary(TRUE); | ||
281 | SP->raw_inp = TRUE; | ||
282 | |||
283 | return OK; | ||
284 | } | ||
285 | |||
286 | int noraw(void) | ||
287 | { | ||
288 | PDC_LOG(("noraw() - called\n")); | ||
289 | |||
290 | if (!SP) | ||
291 | return ERR; | ||
292 | |||
293 | PDC_set_keyboard_binary(FALSE); | ||
294 | SP->raw_inp = FALSE; | ||
295 | |||
296 | return OK; | ||
297 | } | ||
298 | |||
299 | void noqiflush(void) | ||
300 | { | ||
301 | PDC_LOG(("noqiflush() - called\n")); | ||
302 | } | ||
303 | |||
304 | void qiflush(void) | ||
305 | { | ||
306 | PDC_LOG(("qiflush() - called\n")); | ||
307 | } | ||
308 | |||
309 | void timeout(int delay) | ||
310 | { | ||
311 | PDC_LOG(("timeout() - called\n")); | ||
312 | |||
313 | wtimeout(stdscr, delay); | ||
314 | } | ||
315 | |||
316 | void wtimeout(WINDOW *win, int delay) | ||
317 | { | ||
318 | PDC_LOG(("wtimeout() - called\n")); | ||
319 | |||
320 | if (!win) | ||
321 | return; | ||
322 | |||
323 | if (delay < 0) | ||
324 | { | ||
325 | /* This causes a blocking read on the window, so turn on delay | ||
326 | mode */ | ||
327 | |||
328 | win->_nodelay = FALSE; | ||
329 | win->_delayms = 0; | ||
330 | } | ||
331 | else if (!delay) | ||
332 | { | ||
333 | /* This causes a non-blocking read on the window, so turn off | ||
334 | delay mode */ | ||
335 | |||
336 | win->_nodelay = TRUE; | ||
337 | win->_delayms = 0; | ||
338 | } | ||
339 | else | ||
340 | { | ||
341 | /* This causes the read on the window to delay for the number of | ||
342 | milliseconds. Also forces the window into non-blocking read | ||
343 | mode */ | ||
344 | |||
345 | /*win->_nodelay = TRUE;*/ | ||
346 | win->_delayms = delay; | ||
347 | } | ||
348 | } | ||
349 | |||
350 | int wgetdelay(const WINDOW *win) | ||
351 | { | ||
352 | PDC_LOG(("wgetdelay() - called\n")); | ||
353 | |||
354 | if (!win) | ||
355 | return 0; | ||
356 | |||
357 | return win->_delayms; | ||
358 | } | ||
359 | |||
360 | int typeahead(int fildes) | ||
361 | { | ||
362 | PDC_LOG(("typeahead() - called\n")); | ||
363 | |||
364 | return OK; | ||
365 | } | ||
366 | |||
367 | int crmode(void) | ||
368 | { | ||
369 | PDC_LOG(("crmode() - called\n")); | ||
370 | |||
371 | return cbreak(); | ||
372 | } | ||
373 | |||
374 | int nocrmode(void) | ||
375 | { | ||
376 | PDC_LOG(("nocrmode() - called\n")); | ||
377 | |||
378 | return nocbreak(); | ||
379 | } | ||
380 | |||
381 | bool is_keypad(const WINDOW *win) | ||
382 | { | ||
383 | PDC_LOG(("is_keypad() - called\n")); | ||
384 | |||
385 | if (!win) | ||
386 | return FALSE; | ||
387 | |||
388 | return win->_use_keypad; | ||
389 | } | ||
390 | |||
391 | bool is_nodelay(const WINDOW *win) | ||
392 | { | ||
393 | PDC_LOG(("is_nodelay() - called\n")); | ||
394 | |||
395 | if (!win) | ||
396 | return FALSE; | ||
397 | |||
398 | return win->_nodelay; | ||
399 | } | ||
400 | |||
401 | bool is_notimeout(const WINDOW *win) | ||
402 | { | ||
403 | (void) win; | ||
404 | |||
405 | PDC_LOG(("is_notimeout() - called - returning FALSE...\n")); | ||
406 | |||
407 | return FALSE; | ||
408 | } | ||