void PDC_flushinp(void) { PDC_LOG(("PDC_flushinp() - called\n")); while (PDC_check_key()) PDC_get_key(); }
int PDC_get_bios_key(void) { return PDC_get_key(); }
int wgetch(WINDOW *win) { static int buffer[_INBUFSIZ]; /* character buffer */ int key, waitcount; PDC_LOG(("wgetch() - called\n")); if (!win) return ERR; waitcount = 0; /* set the number of 1/20th second napms() calls */ if (SP->delaytenths) waitcount = 2 * SP->delaytenths; else if (win->_delayms) { /* Can't really do millisecond intervals, so delay in 1/20ths of a second (50ms) */ waitcount = win->_delayms / 50; if (!waitcount) waitcount = 1; } /* refresh window when wgetch is called if there have been changes to it and it is not a pad */ if (!(win->_flags & _PAD) && ((!win->_leaveit && (win->_begx + win->_curx != SP->curscol || win->_begy + win->_cury != SP->cursrow)) || is_wintouched(win))) wrefresh(win); /* if ungotten char exists, remove and return it */ if (c_ungind) return c_ungch[--c_ungind]; /* if normal and data in buffer */ if ((!SP->raw_inp && !SP->cbreak) && (c_gindex < c_pindex)) return buffer[c_gindex++]; /* prepare to buffer data */ c_pindex = 0; c_gindex = 0; /* to get here, no keys are buffered. go and get one. */ for (;;) /* loop for any buffering */ { /* is there a keystroke ready? */ if (!PDC_check_key()) { /* if not, handle timeout() and halfdelay() */ if (SP->delaytenths || win->_delayms) { if (!waitcount) return ERR; waitcount--; } else if (win->_nodelay) return ERR; napms(50); /* sleep for 1/20th second */ continue; /* then check again */ } /* if there is, fetch it */ key = PDC_get_key(); if (SP->key_code) { /* filter special keys if not in keypad mode */ if (!win->_use_keypad) key = -1; /* filter mouse events; translate mouse clicks in the slk area to function keys */ else if (key == KEY_MOUSE) key = _mouse_key(); } /* unwanted key? loop back */ if (key == -1) continue; /* translate CR */ if (key == '\r' && SP->autocr && !SP->raw_inp) key = '\n'; /* if echo is enabled */ if (SP->echo && !SP->key_code) { waddch(win, key); wrefresh(win); } /* if no buffering */ if (SP->raw_inp || SP->cbreak) return key; /* if no overflow, put data in buffer */ if (key == '\b') { if (c_pindex > c_gindex) c_pindex--; } else if (c_pindex < _INBUFSIZ - 2) buffer[c_pindex++] = key; /* if we got a line */ if (key == '\n' || key == '\r') return buffer[c_gindex++]; } }