1 /* Public Domain Curses */
5 RCSID("$Id: inopts.c,v 1.43 2008/07/13 16:08:18 wmcbrine Exp $")
7 /*man-start**************************************************************
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);
22 int nodelay(WINDOW *win, bool bf);
23 int notimeout(WINDOW *win, bool bf);
28 void timeout(int delay);
29 void wtimeout(WINDOW *win, int delay);
30 int typeahead(int fildes);
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
63 nl() enables the translation of a carriage return into a newline
64 on input. nonl() disables this. Initially, the translation does
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.
90 All functions return OK on success and ERR on error.
92 Portability X/Open BSD SYS V
115 **man-end****************************************************************/
119 PDC_LOG(("cbreak() - called\n"));
128 PDC_LOG(("nocbreak() - called\n"));
138 PDC_LOG(("echo() - called\n"));
147 PDC_LOG(("noecho() - called\n"));
154 int halfdelay(int tenths
)
156 PDC_LOG(("halfdelay() - called\n"));
158 if (tenths
< 1 || tenths
> 255)
161 SP
->delaytenths
= tenths
;
166 int intrflush(WINDOW
*win
, bool bf
)
168 PDC_LOG(("intrflush() - called\n"));
173 int keypad(WINDOW
*win
, bool bf
)
175 PDC_LOG(("keypad() - called\n"));
180 win
->_use_keypad
= bf
;
185 int meta(WINDOW
*win
, bool bf
)
187 PDC_LOG(("meta() - called\n"));
196 PDC_LOG(("nl() - called\n"));
205 PDC_LOG(("nonl() - called\n"));
212 int nodelay(WINDOW
*win
, bool flag
)
214 PDC_LOG(("nodelay() - called\n"));
219 win
->_nodelay
= flag
;
224 int notimeout(WINDOW
*win
, bool flag
)
226 PDC_LOG(("notimeout() - called\n"));
233 PDC_LOG(("raw() - called\n"));
235 PDC_set_keyboard_binary(TRUE
);
243 PDC_LOG(("noraw() - called\n"));
245 PDC_set_keyboard_binary(FALSE
);
253 PDC_LOG(("noqiflush() - called\n"));
258 PDC_LOG(("qiflush() - called\n"));
261 int typeahead(int fildes
)
263 PDC_LOG(("typeahead() - called\n"));
268 void wtimeout(WINDOW
*win
, int delay
)
270 PDC_LOG(("wtimeout() - called\n"));
277 /* This causes a blocking read on the window, so turn on delay
280 win
->_nodelay
= FALSE
;
285 /* This causes a non-blocking read on the window, so turn off
288 win
->_nodelay
= TRUE
;
293 /* This causes the read on the window to delay for the number of
294 milliseconds. Also forces the window into non-blocking read
297 /*win->_nodelay = TRUE;*/
298 win
->_delayms
= delay
;
302 void timeout(int delay
)
304 PDC_LOG(("timeout() - called\n"));
306 wtimeout(stdscr
, delay
);
311 PDC_LOG(("crmode() - called\n"));
318 PDC_LOG(("nocrmode() - called\n"));