41 lines
855 B
C
41 lines
855 B
C
#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 */
|