test custom curses implementation

This commit is contained in:
Emile Clark-Boman 2025-09-09 11:25:59 +10:00
parent 04e5688d82
commit 342886a098
2 changed files with 135 additions and 0 deletions

41
lib/cursed.h Normal file
View file

@ -0,0 +1,41 @@
#ifndef CURSED_H
#define CURSED_H
#include <stdbool.h>
#include <sys/termios.h>
#define PACKED __attribute__((packed, aligned(1)))
#define PUBLIC __attribute((visibility("default")))
#define PROTECTED __attribute__((visibility("hidden")))
#define PRIVATE static
#define _INIT __attribute__((constructor))
#define _FINI __attribute__((destructor))
typedef unsigned char uid; // >= 8B
typedef unsigned short int pos; // >= 16B
struct s_framebuffer {
pos *buf; // framebuffer
bool bitmap[];
} PACKED;
struct s_window {
uid id;
pos cols;
pos rows;
struct s_framebuffer frame;
pos x;
pos y;
} PACKED;
struct s_state {
struct termios term;
} PACKED;
// === Public API ===
PRIVATE struct s_framebuffer *init_framebuffer(pos cols, pos rows);
PUBLIC struct s_window *init_window(uid id, pos cols, pos rows);
#endif /* CURSED_H */