1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#include <stddef.h>
#include <stdint.h>
#include <termios.h>
struct display {
struct termios term;
struct termios orig_term;
uint32_t width;
uint32_t height;
};
struct render_command {
uint32_t col;
uint32_t row;
uint8_t *data;
uint32_t len;
};
struct command_list {
struct render_command *cmds;
uint64_t ncmds;
uint64_t capacity;
uint32_t xoffset;
uint32_t yoffset;
uint8_t format[64];
uint32_t format_len;
};
struct display display_create();
void display_destroy(struct display *display);
void display_clear(struct display *display);
void display_move_cursor(struct display *display, uint32_t row, uint32_t col);
void display_begin_render(struct display *display);
void display_render(struct display *display, struct command_list *command_list);
void display_end_render(struct display *display);
typedef void *(*alloc_fn)(size_t);
struct command_list *command_list_create(uint32_t capacity, alloc_fn allocator,
uint32_t xoffset, uint32_t yoffset);
void command_list_set_index_color_bg(struct command_list *list,
uint8_t color_idx);
void command_list_set_color_bg(struct command_list *list, uint8_t red,
uint8_t green, uint8_t blue);
void command_list_set_index_color_fg(struct command_list *list,
uint8_t color_idx);
void command_list_set_color_fg(struct command_list *list, uint8_t red,
uint8_t green, uint8_t blue);
void command_list_reset_color(struct command_list *list);
void command_list_draw_text(struct command_list *list, uint32_t col,
uint32_t row, uint8_t *data, uint32_t len);
|