8
* MuCurses keyboard input handling functions
11
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
13
#define INPUT_DELAY 200 // half-blocking delay timer resolution (ms)
14
#define INPUT_DELAY_TIMEOUT 1000 // half-blocking delay timeout
19
> 0 : timed blocking read
24
static int _wgetc ( WINDOW *win ) {
30
timer = INPUT_DELAY_TIMEOUT;
31
while ( ! win->scr->peek( win->scr ) ) {
32
if ( m_delay == 0 ) // non-blocking read
34
if ( timer > 0 ) { // time-limited blocking read
37
mdelay( INPUT_DELAY );
38
} else { return ERR; } // non-blocking read
41
c = win->scr->getc( win->scr );
43
if ( m_echo && ( c >= 32 && c <= 126 ) ) // printable ASCII characters
44
_wputch( win, (chtype) ( c | win->attrs ), WRAP );
50
* Pop a character from the FIFO into a window
52
* @v *win window in which to echo input
53
* @ret c char from input stream
55
int wgetch ( WINDOW *win ) {
73
_wputch( win, (chtype)( c | win->attrs ), WRAP );
81
* Read at most n characters from the FIFO into a window
83
* @v *win window in which to echo input
84
* @v *str pointer to string in which to store result
85
* @v n maximum number of characters to read into string (inc. NUL)
86
* @ret rc return status code
88
int wgetnstr ( WINDOW *win, char *str, int n ) {
99
while ( ( c = _wgetc( win ) ) != ERR ) {
100
/* termination enforcement - don't let us go past the
101
end of the allocated buffer... */
102
if ( n == 0 && ( c >= 32 && c <= 126 ) ) {
106
if ( c >= KEY_MIN ) {
121
if ( c >= 32 && c <= 126 ) {
142
int noecho ( void ) {