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
23 * Check KEY_ code supported status
25 * @v kc keycode value to check
26 * @ret TRUE KEY_* supported
27 * @ret FALSE KEY_* unsupported
29 int has_key ( int kc __unused ) {
33 int _wgetc ( WINDOW *win ) {
39 timer = INPUT_DELAY_TIMEOUT;
40 while ( ! win->scr->peek( win->scr ) ) {
41 if ( m_delay == 0 ) // non-blocking read
43 if ( timer > 0 ) { // time-limited blocking read
46 mdelay( INPUT_DELAY );
47 } else { return ERR; } // non-blocking read
50 c = win->scr->getc( win->scr );
52 if ( m_echo && ( c >= 32 && c <= 126 ) ) // printable ASCII characters
53 _wputch( win, (chtype) ( c | win->attrs ), WRAP );
59 * Pop a character from the FIFO into a window
61 * @v *win window in which to echo input
62 * @ret c char from input stream
64 int wgetch ( WINDOW *win ) {
82 _wputch( win, (chtype)( c | win->attrs ), WRAP );
90 * Read at most n characters from the FIFO into a window
92 * @v *win window in which to echo input
93 * @v *str pointer to string in which to store result
94 * @v n maximum number of characters to read into string (inc. NUL)
95 * @ret rc return status code
97 int wgetnstr ( WINDOW *win, char *str, int n ) {
108 while ( ( c = _wgetc( win ) ) != ERR ) {
109 /* termination enforcement - don't let us go past the
110 end of the allocated buffer... */
111 if ( n == 0 && ( c >= 32 && c <= 126 ) ) {
115 if ( c >= KEY_MIN ) {
130 if ( c >= 32 && c <= 126 ) {
151 int noecho ( void ) {