1/* Terminal control for the history view.2 *3 * The view needs three things V's standard library does not expose directly:4 * raw mode with the terminal restored on exit, the window size, and one5 * keystroke at a time with escape sequences kept together. Keeping this in C6 * means one implementation for macOS and Linux, and no termios struct layout7 * in V.8 */910#ifndef KOH_TERM_H11#define KOH_TERM_H1213/* Switches stdin to raw mode (enable = 1) or back (enable = 0). Returns 1 on14 * success. Ctrl-C is delivered as a key rather than a signal, so the caller15 * can restore the terminal before quitting. While raw mode is on, SIGTERM,16 * SIGHUP and SIGQUIT restore the terminal and exit; turning raw mode off puts17 * the previous handlers back. */18int koh_term_raw(int enable);1920/* Fills rows and columns; falls back to 24x80 when the size is unavailable. */21int koh_term_size(int *rows, int *cols);2223/* Reads one keystroke into buf, gathering the rest of an escape sequence when24 * the first byte is ESC. Returns the byte count, or 0 at end of input. */25int koh_read_key(char *buf, int cap);2627/* Waits up to milliseconds for a keystroke, then reads it exactly as28 * koh_read_key does. Returns the byte count, 0 when no key arrived in time, or29 * -1 when input ended. */30int koh_wait_key(char *buf, int cap, int milliseconds);3132#endif