From 3fed5969034c464e36358fc45a99b57b1f308c11 Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Sun, 21 Jun 2026 13:51:24 +0300 Subject: term_init() and term_cleanup(), mostly --- framebuffer.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'framebuffer.h') diff --git a/framebuffer.h b/framebuffer.h index 1b0254f..373cfb4 100644 --- a/framebuffer.h +++ b/framebuffer.h @@ -5,8 +5,9 @@ #include /* wchar_t */ #include /* ssize_t */ -/* Globals for the terminal size, set by fb_init() */ -extern size_t TERM_WIDTH, TERM_HEIGHT; +/* Globals for the terminal size, set by term_update_size() */ +extern size_t term_width, term_height; +extern struct termios initial_terminal_state; /* Represents a 24 bit colour, 8 bit per channel */ typedef struct Colour_s { @@ -60,12 +61,18 @@ void fb_fill(Framebuffer fb, Pixel pixel); void inline fb_put(Framebuffer fb, size_t row, size_t col, Pixel pixel); /* Initializes the terminal and sets TERM_WIDTH and TERM_HEIGHT */ -void fb_init(void); +void term_init(void); /* Undoes everything fb_init() did */ -void fb_cleanup(void); +void term_cleanup(void); + +/* Updates term_width and term_height */ +void term_update_size(void); /* Prints fb to the screen */ void fb_print(Framebuffer fb); +/* c is a byte */ +#define get_input(c) read(STDIN_FILENO, &c, 1) + #endif /* FRAMEBUFFER_H_ */ -- cgit v1.2.3