int curses_get_count(int first_digit) { long current_count = first_digit; int current_char; current_char = curses_read_char(); while (isdigit(current_char)) { current_count = (current_count * 10) + (current_char - '0'); if (current_count > LARGEST_INT) { current_count = LARGEST_INT; } pline("Count: %ld", current_count); current_char = curses_read_char(); } ungetch(current_char); if (current_char == '\033') /* Cancelled with escape */ { current_count = -1; } return current_count; }
/* int nhgetch() -- Returns a single character input from the user. -- In the tty window-port, nhgetch() assumes that tgetch() will be the routine the OS provides to read a character. Returned character _must_ be non-zero. */ int curses_nhgetch() { int ch; curses_prehousekeeping(); ch = curses_read_char(); curses_posthousekeeping(); return ch; }