soc/mediatek/common: Fix wrong write API for protect_key_setting
[coreboot2.git] / payloads / libpayload / curses / PDCurses / pdcurses / inopts.c
blobb02654f077ab4d1a713731af2219b154ad6498e2
1 /* Public Domain Curses */
3 #include <curspriv.h>
5 RCSID("$Id: inopts.c,v 1.43 2008/07/13 16:08:18 wmcbrine Exp $")
7 /*man-start**************************************************************
9 Name: inopts
11 Synopsis:
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 typeahead(int fildes);
32 int crmode(void);
33 int nocrmode(void);
35 Description:
36 cbreak() and nocbreak() toggle cbreak mode. In cbreak mode,
37 characters typed by the user are made available immediately, and
38 erase/kill character processing is not performed. In nocbreak
39 mode, typed characters are buffered until a newline or carriage
40 return. Interrupt and flow control characters are unaffected by
41 this mode. PDCurses always starts in cbreak mode.
43 echo() and noecho() control whether typed characters are echoed
44 by the input routine. Initially, input characters are echoed.
45 Subsequent calls to echo() and noecho() do not flush type-ahead.
47 halfdelay() is similar to cbreak(), but allows for a time limit
48 to be specified, in tenths of a second. This causes getch() to
49 block for that period before returning ERR if no key has been
50 received. tenths must be between 1 and 255.
52 keypad() controls whether getch() returns function/special keys
53 as single key codes (e.g., the left arrow key as KEY_LEFT). Per
54 X/Open, the default for keypad mode is OFF. You'll probably want
55 it on. With keypad mode off, if a special key is pressed,
56 getch() does nothing or returns ERR.
58 nodelay() controls whether wgetch() is a non-blocking call. If
59 the option is enabled, and no input is ready, wgetch() will
60 return ERR. If disabled, wgetch() will hang until input is
61 ready.
63 nl() enables the translation of a carriage return into a newline
64 on input. nonl() disables this. Initially, the translation does
65 occur.
67 raw() and noraw() toggle raw mode. Raw mode is similar to cbreak
68 mode, in that characters typed are immediately passed through to
69 the user program. The difference is that in raw mode, the INTR,
70 QUIT, SUSP, and STOP characters are passed through without being
71 interpreted, and without generating a signal.
73 In PDCurses, the meta() function sets raw mode on or off.
75 timeout() and wtimeout() set blocking or non-blocking reads for
76 the specified window. The delay is measured in milliseconds. If
77 it's negative, a blocking read is used; if zero, then non-
78 blocking reads are done -- if no input is waiting, ERR is
79 returned immediately. If the delay is positive, the read blocks
80 for the delay period; if the period expires, ERR is returned.
82 intrflush(), notimeout(), noqiflush(), qiflush() and typeahead()
83 do nothing in PDCurses, but are included for compatibility with
84 other curses implementations.
86 crmode() and nocrmode() are archaic equivalents to cbreak() and
87 nocbreak(), respectively.
89 Return Value:
90 All functions return OK on success and ERR on error.
92 Portability X/Open BSD SYS V
93 cbreak Y Y Y
94 nocbreak Y Y Y
95 echo Y Y Y
96 noecho Y Y Y
97 halfdelay Y - Y
98 intrflush Y - Y
99 keypad Y - Y
100 meta Y - Y
101 nl Y Y Y
102 nonl Y Y Y
103 nodelay Y - Y
104 notimeout Y - Y
105 raw Y Y Y
106 noraw Y Y Y
107 noqiflush Y - Y
108 qiflush Y - Y
109 timeout Y - Y
110 wtimeout Y - Y
111 typeahead Y - Y
112 crmode -
113 nocrmode -
115 **man-end****************************************************************/
117 int cbreak(void)
119 PDC_LOG(("cbreak() - called\n"));
121 SP->cbreak = TRUE;
123 return OK;
126 int nocbreak(void)
128 PDC_LOG(("nocbreak() - called\n"));
130 SP->cbreak = FALSE;
131 SP->delaytenths = 0;
133 return OK;
136 int echo(void)
138 PDC_LOG(("echo() - called\n"));
140 SP->echo = TRUE;
142 return OK;
145 int noecho(void)
147 PDC_LOG(("noecho() - called\n"));
149 SP->echo = FALSE;
151 return OK;
154 int halfdelay(int tenths)
156 PDC_LOG(("halfdelay() - called\n"));
158 if (tenths < 1 || tenths > 255)
159 return ERR;
161 SP->delaytenths = tenths;
163 return OK;
166 int intrflush(WINDOW *win, bool bf)
168 PDC_LOG(("intrflush() - called\n"));
170 return OK;
173 int keypad(WINDOW *win, bool bf)
175 PDC_LOG(("keypad() - called\n"));
177 if (!win)
178 return ERR;
180 win->_use_keypad = bf;
182 return OK;
185 int meta(WINDOW *win, bool bf)
187 PDC_LOG(("meta() - called\n"));
189 SP->raw_inp = bf;
191 return OK;
194 int nl(void)
196 PDC_LOG(("nl() - called\n"));
198 SP->autocr = TRUE;
200 return OK;
203 int nonl(void)
205 PDC_LOG(("nonl() - called\n"));
207 SP->autocr = FALSE;
209 return OK;
212 int nodelay(WINDOW *win, bool flag)
214 PDC_LOG(("nodelay() - called\n"));
216 if (!win)
217 return ERR;
219 win->_nodelay = flag;
221 return OK;
224 int notimeout(WINDOW *win, bool flag)
226 PDC_LOG(("notimeout() - called\n"));
228 return OK;
231 int raw(void)
233 PDC_LOG(("raw() - called\n"));
235 PDC_set_keyboard_binary(TRUE);
236 SP->raw_inp = TRUE;
238 return OK;
241 int noraw(void)
243 PDC_LOG(("noraw() - called\n"));
245 PDC_set_keyboard_binary(FALSE);
246 SP->raw_inp = FALSE;
248 return OK;
251 void noqiflush(void)
253 PDC_LOG(("noqiflush() - called\n"));
256 void qiflush(void)
258 PDC_LOG(("qiflush() - called\n"));
261 int typeahead(int fildes)
263 PDC_LOG(("typeahead() - called\n"));
265 return OK;
268 void wtimeout(WINDOW *win, int delay)
270 PDC_LOG(("wtimeout() - called\n"));
272 if (!win)
273 return;
275 if (delay < 0)
277 /* This causes a blocking read on the window, so turn on delay
278 mode */
280 win->_nodelay = FALSE;
281 win->_delayms = 0;
283 else if (!delay)
285 /* This causes a non-blocking read on the window, so turn off
286 delay mode */
288 win->_nodelay = TRUE;
289 win->_delayms = 0;
291 else
293 /* This causes the read on the window to delay for the number of
294 milliseconds. Also forces the window into non-blocking read
295 mode */
297 /*win->_nodelay = TRUE;*/
298 win->_delayms = delay;
302 void timeout(int delay)
304 PDC_LOG(("timeout() - called\n"));
306 wtimeout(stdscr, delay);
309 int crmode(void)
311 PDC_LOG(("crmode() - called\n"));
313 return cbreak();
316 int nocrmode(void)
318 PDC_LOG(("nocrmode() - called\n"));
320 return nocbreak();