diff options
Diffstat (limited to '')
-rw-r--r-- | scripts/kconfig/libcurses/inopts.c | 410 |
1 files changed, 410 insertions, 0 deletions
diff --git a/scripts/kconfig/libcurses/inopts.c b/scripts/kconfig/libcurses/inopts.c new file mode 100644 index 000000000..a1c4b49f8 --- /dev/null +++ b/scripts/kconfig/libcurses/inopts.c | |||
@@ -0,0 +1,410 @@ | |||
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 | |||
110 | Function | X/Open | ncurses | NetBSD | ||
111 | :---------------------|:------:|:-------:|:------: | ||
112 | cbreak | Y | Y | Y | ||
113 | nocbreak | Y | Y | Y | ||
114 | echo | Y | Y | Y | ||
115 | noecho | Y | Y | Y | ||
116 | halfdelay | Y | Y | Y | ||
117 | intrflush | Y | Y | Y | ||
118 | keypad | Y | Y | Y | ||
119 | meta | Y | Y | Y | ||
120 | nl | Y | Y | Y | ||
121 | nonl | Y | Y | Y | ||
122 | nodelay | Y | Y | Y | ||
123 | notimeout | Y | Y | Y | ||
124 | raw | Y | Y | Y | ||
125 | noraw | Y | Y | Y | ||
126 | noqiflush | Y | Y | Y | ||
127 | qiflush | Y | Y | Y | ||
128 | timeout | Y | Y | Y | ||
129 | wtimeout | Y | Y | Y | ||
130 | wgetdelay | - | Y | - | ||
131 | typeahead | Y | Y | Y | ||
132 | crmode | Y | Y | Y | ||
133 | nocrmode | Y | Y | Y | ||
134 | is_keypad | - | Y | Y | ||
135 | is_nodelay | - | Y | - | ||
136 | is_notimeout | - | Y | - | ||
137 | |||
138 | **man-end****************************************************************/ | ||
139 | |||
140 | int cbreak(void) | ||
141 | { | ||
142 | PDC_LOG(("cbreak() - called\n")); | ||
143 | |||
144 | if (!SP) | ||
145 | return ERR; | ||
146 | |||
147 | SP->cbreak = TRUE; | ||
148 | |||
149 | return OK; | ||
150 | } | ||
151 | |||
152 | int nocbreak(void) | ||
153 | { | ||
154 | PDC_LOG(("nocbreak() - called\n")); | ||
155 | |||
156 | if (!SP) | ||
157 | return ERR; | ||
158 | |||
159 | SP->cbreak = FALSE; | ||
160 | SP->delaytenths = 0; | ||
161 | |||
162 | return OK; | ||
163 | } | ||
164 | |||
165 | int echo(void) | ||
166 | { | ||
167 | PDC_LOG(("echo() - called\n")); | ||
168 | |||
169 | if (!SP) | ||
170 | return ERR; | ||
171 | |||
172 | SP->echo = TRUE; | ||
173 | |||
174 | return OK; | ||
175 | } | ||
176 | |||
177 | int noecho(void) | ||
178 | { | ||
179 | PDC_LOG(("noecho() - called\n")); | ||
180 | |||
181 | if (!SP) | ||
182 | return ERR; | ||
183 | |||
184 | SP->echo = FALSE; | ||
185 | |||
186 | return OK; | ||
187 | } | ||
188 | |||
189 | int halfdelay(int tenths) | ||
190 | { | ||
191 | PDC_LOG(("halfdelay() - called\n")); | ||
192 | |||
193 | if (!SP || tenths < 1 || tenths > 255) | ||
194 | return ERR; | ||
195 | |||
196 | SP->delaytenths = tenths; | ||
197 | |||
198 | return OK; | ||
199 | } | ||
200 | |||
201 | int intrflush(WINDOW *win, bool bf) | ||
202 | { | ||
203 | PDC_LOG(("intrflush() - called\n")); | ||
204 | |||
205 | return OK; | ||
206 | } | ||
207 | |||
208 | int keypad(WINDOW *win, bool bf) | ||
209 | { | ||
210 | PDC_LOG(("keypad() - called\n")); | ||
211 | |||
212 | if (!win) | ||
213 | return ERR; | ||
214 | |||
215 | win->_use_keypad = bf; | ||
216 | |||
217 | return OK; | ||
218 | } | ||
219 | |||
220 | int meta(WINDOW *win, bool bf) | ||
221 | { | ||
222 | PDC_LOG(("meta() - called\n")); | ||
223 | |||
224 | if (!SP) | ||
225 | return ERR; | ||
226 | |||
227 | SP->raw_inp = bf; | ||
228 | |||
229 | return OK; | ||
230 | } | ||
231 | |||
232 | int nl(void) | ||
233 | { | ||
234 | PDC_LOG(("nl() - called\n")); | ||
235 | |||
236 | if (!SP) | ||
237 | return ERR; | ||
238 | |||
239 | SP->autocr = TRUE; | ||
240 | |||
241 | return OK; | ||
242 | } | ||
243 | |||
244 | int nonl(void) | ||
245 | { | ||
246 | PDC_LOG(("nonl() - called\n")); | ||
247 | |||
248 | if (!SP) | ||
249 | return ERR; | ||
250 | |||
251 | SP->autocr = FALSE; | ||
252 | |||
253 | return OK; | ||
254 | } | ||
255 | |||
256 | int nodelay(WINDOW *win, bool flag) | ||
257 | { | ||
258 | PDC_LOG(("nodelay() - called\n")); | ||
259 | |||
260 | if (!win) | ||
261 | return ERR; | ||
262 | |||
263 | win->_nodelay = flag; | ||
264 | |||
265 | return OK; | ||
266 | } | ||
267 | |||
268 | int notimeout(WINDOW *win, bool flag) | ||
269 | { | ||
270 | PDC_LOG(("notimeout() - called\n")); | ||
271 | |||
272 | return OK; | ||
273 | } | ||
274 | |||
275 | int raw(void) | ||
276 | { | ||
277 | PDC_LOG(("raw() - called\n")); | ||
278 | |||
279 | if (!SP) | ||
280 | return ERR; | ||
281 | |||
282 | PDC_set_keyboard_binary(TRUE); | ||
283 | SP->raw_inp = TRUE; | ||
284 | |||
285 | return OK; | ||
286 | } | ||
287 | |||
288 | int noraw(void) | ||
289 | { | ||
290 | PDC_LOG(("noraw() - called\n")); | ||
291 | |||
292 | if (!SP) | ||
293 | return ERR; | ||
294 | |||
295 | PDC_set_keyboard_binary(FALSE); | ||
296 | SP->raw_inp = FALSE; | ||
297 | |||
298 | return OK; | ||
299 | } | ||
300 | |||
301 | void noqiflush(void) | ||
302 | { | ||
303 | PDC_LOG(("noqiflush() - called\n")); | ||
304 | } | ||
305 | |||
306 | void qiflush(void) | ||
307 | { | ||
308 | PDC_LOG(("qiflush() - called\n")); | ||
309 | } | ||
310 | |||
311 | void timeout(int delay) | ||
312 | { | ||
313 | PDC_LOG(("timeout() - called\n")); | ||
314 | |||
315 | wtimeout(stdscr, delay); | ||
316 | } | ||
317 | |||
318 | void wtimeout(WINDOW *win, int delay) | ||
319 | { | ||
320 | PDC_LOG(("wtimeout() - called\n")); | ||
321 | |||
322 | if (!win) | ||
323 | return; | ||
324 | |||
325 | if (delay < 0) | ||
326 | { | ||
327 | /* This causes a blocking read on the window, so turn on delay | ||
328 | mode */ | ||
329 | |||
330 | win->_nodelay = FALSE; | ||
331 | win->_delayms = 0; | ||
332 | } | ||
333 | else if (!delay) | ||
334 | { | ||
335 | /* This causes a non-blocking read on the window, so turn off | ||
336 | delay mode */ | ||
337 | |||
338 | win->_nodelay = TRUE; | ||
339 | win->_delayms = 0; | ||
340 | } | ||
341 | else | ||
342 | { | ||
343 | /* This causes the read on the window to delay for the number of | ||
344 | milliseconds. Also forces the window into non-blocking read | ||
345 | mode */ | ||
346 | |||
347 | /*win->_nodelay = TRUE;*/ | ||
348 | win->_delayms = delay; | ||
349 | } | ||
350 | } | ||
351 | |||
352 | int wgetdelay(const WINDOW *win) | ||
353 | { | ||
354 | PDC_LOG(("wgetdelay() - called\n")); | ||
355 | |||
356 | if (!win) | ||
357 | return 0; | ||
358 | |||
359 | return win->_delayms; | ||
360 | } | ||
361 | |||
362 | int typeahead(int fildes) | ||
363 | { | ||
364 | PDC_LOG(("typeahead() - called\n")); | ||
365 | |||
366 | return OK; | ||
367 | } | ||
368 | |||
369 | int crmode(void) | ||
370 | { | ||
371 | PDC_LOG(("crmode() - called\n")); | ||
372 | |||
373 | return cbreak(); | ||
374 | } | ||
375 | |||
376 | int nocrmode(void) | ||
377 | { | ||
378 | PDC_LOG(("nocrmode() - called\n")); | ||
379 | |||
380 | return nocbreak(); | ||
381 | } | ||
382 | |||
383 | bool is_keypad(const WINDOW *win) | ||
384 | { | ||
385 | PDC_LOG(("is_keypad() - called\n")); | ||
386 | |||
387 | if (!win) | ||
388 | return FALSE; | ||
389 | |||
390 | return win->_use_keypad; | ||
391 | } | ||
392 | |||
393 | bool is_nodelay(const WINDOW *win) | ||
394 | { | ||
395 | PDC_LOG(("is_nodelay() - called\n")); | ||
396 | |||
397 | if (!win) | ||
398 | return FALSE; | ||
399 | |||
400 | return win->_nodelay; | ||
401 | } | ||
402 | |||
403 | bool is_notimeout(const WINDOW *win) | ||
404 | { | ||
405 | (void) win; | ||
406 | |||
407 | PDC_LOG(("is_notimeout() - called - returning FALSE...\n")); | ||
408 | |||
409 | return FALSE; | ||
410 | } | ||