1/* @ajax/tui-term: the terminal as ratatui::init/restore (crossterm) leave it: raw mode
2 * (cfmakeraw's flags), the alternate screen, the cursor hidden; restore undoes each, and is safe
3 * to call twice or without enter. Reads wait up to a timeout with poll(2); SIGWINCH sets a flag. */
4#ifndef TUI_TERM_H
5#define TUI_TERM_H
67#include <stdbool.h>
8#include <stddef.h>
9#include <stdint.h>
1011/* Raw mode, alternate screen, hidden cursor, a clear screen; false (and nothing changed) when
12 * stdin or stdout isn't a terminal. */
13bool tui_term_enter(void);
14void tui_term_leave(void);
15/* The window's size in cells (TIOCGWINSZ on stdout, then stdin). */
16bool tui_term_size(uint16_t *width, uint16_t *height);
17/* Whether a SIGWINCH arrived since the last call (installed by tui_term_enter). */
18bool tui_term_resized(void);
19/* Reads what is available from stdin within timeout_ms (-1: wait, 0: don't). Returns the bytes
20 * read, 0 on timeout, -1 on error or end of input. */
21long tui_term_read(char *buf, size_t cap, int timeout_ms);
22/* Writes all of buf to stdout (retrying short writes). */
23bool tui_term_write(const char *buf, size_t len);
2425#endif