aboutsummaryrefslogtreecommitdiff
path: root/termkit.c
blob: 9775f7dec9966e9ccd4b63a874bd4076059cfdcd (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>

#include <termbox.h>
#include "termkit.h"

#define OK      0
#define ER      1
#define USR_ERR 2

int tk_sty_init(tk_style_t **sty, uint16_t fg, uint16_t bg)
{
    (*sty) = calloc(sizeof(tk_style_t), 1);
    CHECK(*sty, ERR)

    err_t e;
    e = bowl_malloc(&(*sty)->styles, HASH);
    if(e) goto fail;

    e = bowl_malloc(&(*sty)->decorators, HASH);
    if(e) goto fail;
    
    return OK;

fail:
    free((*sty)->styles);
    free((*sty)->decorators);
    free(*sty);
    return ERR;
}

int tk_sty_add_col(tk_style_t *sty, char *name, uint16_t fg, uint16_t bg)
{
    CHECK(sty, USR_ERR)

    

    return OK;
}

// int init()
// {
//     return tb_init();
// }

// void draw(char *str, int rootX, int rootY, uint16_t fg, uint16_t bg)
// {
//     size_t len = strlen(str);
//     int x = rootX;
    
//     for(int i = 0; i < len; i++) {
//         tb_change_cell(x, rootY, str[i], fg, bg);
//         x += 1;
//     }
// }

// void draw_xy(char *str, int rootX, int rootY,
//             int8_t h, int8_t v,
//             uint16_t fg, uint16_t bg)
// {
//     size_t len = strlen(str);
//     int x = rootX;
//     int y = rootY;

//     for(int i = 0; i < len; i++) {
//         tb_change_cell(x, y, str[i], fg, bg);
//         x += h; y += v;
//     }
// }