forked from MagerValp/CGTerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.c
68 lines (58 loc) · 1.85 KB
/
status.c
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
#include <time.h>
#include <string.h>
#include "config.h"
#include "gfx.h"
unsigned char *status_time;
unsigned char status_chars[80];
unsigned char status_colors[80];
static unsigned char status_chars40[] = {
64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 115, '0', '0', ':', '0', '0', 107, 64, 64,
};
static unsigned char status_colors40[] = {
6, 4, 10, 7, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 15, 15, 12, 15, 15, 1, 1, 1
};
static unsigned char status_chars80[] = {
64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 115, '0', '0', ':', '0', '0', 107, 64, 64,
};
static unsigned char status_colors80[] = {
6, 4, 10, 7, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 15, 15, 12, 15, 15, 1, 1, 1
};
void status_init(void) {
memcpy(status_chars, cfg_columns == 40 ? status_chars40 : status_chars80, cfg_columns);
memcpy(status_colors, cfg_columns == 40 ? status_colors40 : status_colors80, cfg_columns);
status_time = status_chars + cfg_columns - 8;
}
void status_clear(void) {
gfx_clear_line(23, 1);
}
void status_draw(void) {
struct tm *tm;
time_t t;
t = time(NULL);
tm = localtime(&t);
status_time[0] = '0' + tm->tm_hour / 10;
status_time[1] = '0' + tm->tm_hour % 10;
status_time[3] = '0' + tm->tm_min / 10;
status_time[4] = '0' + tm->tm_min % 10;
gfx_copy_line(status_chars, status_colors, 23);
}