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
24 * Check KEY_ code supported status
26 * @v kc keycode value to check
27 * @ret TRUE KEY_* supported
28 * @ret FALSE KEY_* unsupported
30 int has_key ( int kc __unused ) {
36 int _wgetc ( WINDOW *win ) {
42 timer = INPUT_DELAY_TIMEOUT;
43 while ( ! win->scr->peek( win->scr ) ) {
44 if ( m_delay == 0 ) // non-blocking read
46 if ( timer > 0 ) { // time-limited blocking read
49 mdelay( INPUT_DELAY );
50 } else { return ERR; } // non-blocking read
53 c = win->scr->getc( win->scr );
55 if ( m_echo && ( c >= 32 && c <= 126 ) ) // printable ASCII characters
56 _wputch( win, (chtype) ( c | win->attrs ), WRAP );
62 * Pop a character from the FIFO into a window
64 * @v *win window in which to echo input
65 * @ret c char from input stream
67 int wgetch ( WINDOW *win ) {
85 _wputch( win, (chtype)( c | win->attrs ), WRAP );
93 * Read at most n characters from the FIFO into a window
95 * @v *win window in which to echo input
96 * @v *str pointer to string in which to store result
97 * @v n maximum number of characters to read into string (inc. NUL)
98 * @ret rc return status code
100 int wgetnstr ( WINDOW *win, char *str, int n ) {
111 while ( ( c = _wgetc( win ) ) != ERR ) {
112 /* termination enforcement - don't let us go past the
113 end of the allocated buffer... */
114 if ( n == 0 && ( c >= 32 && c <= 126 ) ) {
118 if ( c >= KEY_MIN ) {
133 if ( c >= 32 && c <= 126 ) {
154 int noecho ( void ) {