koh_term.h

961 B · raw

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. */16int koh_term_raw(int enable);1718/* Fills rows and columns; falls back to 24x80 when the size is unavailable. */19int koh_term_size(int *rows, int *cols);2021/* Reads one keystroke into buf, gathering the rest of an escape sequence when22 * the first byte is ESC. Returns the byte count, or 0 at end of input. */23int koh_read_key(char *buf, int cap);2425#endif