libterm.h (596B)
1 #pragma once 2 3 typedef enum { 4 ESC = 27, 5 BACKSPACE = 127, 6 ARROW_LEFT = 1000, 7 ARROW_RIGHT, 8 ARROW_UP, 9 ARROW_DOWN, 10 DEL_KEY, 11 HOME_KEY, 12 END_KEY, 13 PAGE_UP, 14 PAGE_DOWN, 15 } keycode_t; 16 17 typedef struct { 18 char *buffer; 19 int len; 20 } term_t; 21 22 void term_panic(const char *s); 23 void term_disable_raw_mode(void); 24 void term_enable_raw_mode(void); 25 int term_read_cursor_pos(int *rows, int *cols); 26 int term_read_window_size(int *rows, int *cols); 27 int term_poll_key(int timeout); 28 int term_read_key(void); 29 void term_write(char *str); 30 void term_writef(const char *format, ...); 31 void term_flush(void);