8 * MuCurses keyboard input handling functions
11 #define INPUT_DELAY 200 // half-blocking delay timer resolution (ms)
12 #define INPUT_DELAY_TIMEOUT 1000 // half-blocking delay timeout
17 > 0 : timed blocking read
22 static int _wgetc ( WINDOW *win ) {
28 timer = INPUT_DELAY_TIMEOUT;
29 while ( ! win->scr->peek( win->scr ) ) {
30 if ( m_delay == 0 ) // non-blocking read
32 if ( timer > 0 ) { // time-limited blocking read
35 mdelay( INPUT_DELAY );
36 } else { return ERR; } // non-blocking read
39 c = win->scr->getc( win->scr );
41 if ( m_echo && ( c >= 32 && c <= 126 ) ) // printable ASCII characters
42 _wputch( win, (chtype) ( c | win->attrs ), WRAP );
48 * Pop a character from the FIFO into a window
50 * @v *win window in which to echo input
51 * @ret c char from input stream
53 int wgetch ( WINDOW *win ) {
71 _wputch( win, (chtype)( c | win->attrs ), WRAP );
79 * Read at most n characters from the FIFO into a window
81 * @v *win window in which to echo input
82 * @v *str pointer to string in which to store result
83 * @v n maximum number of characters to read into string (inc. NUL)
84 * @ret rc return status code
86 int wgetnstr ( WINDOW *win, char *str, int n ) {
97 while ( ( c = _wgetc( win ) ) != ERR ) {
98 /* termination enforcement - don't let us go past the
99 end of the allocated buffer... */
100 if ( n == 0 && ( c >= 32 && c <= 126 ) ) {
104 if ( c >= KEY_MIN ) {
119 if ( c >= 32 && c <= 126 ) {
140 int noecho ( void ) {