-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
53 lines (51 loc) · 1.11 KB
/
main.cpp
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
#include "bklk.h"
#include <cstdlib>
#include <getopt.h>
#include <memory>
#include <string.h>
#include <unistd.h>
int main(int argc, char **argv) {
int fg = 7, bg = 0, ch, opt;
bool flags = false;
const char *clktype;
while ((opt = getopt(argc, argv, "msl")) != -1) {
switch (opt) {
case 'l':
flags = true;
clktype = "reduced";
fg = 0;
bg = 7;
break;
case 's':
clktype = "full";
flags = true;
break;
case 'm':
clktype = "reduced";
flags = true;
break;
}
}
if (flags == false) {
printf("\nbklk: usage & display options:\n\t-s\tseconds\n\t-m\tminutes\n\t-l\tlight colorscheme\n\n");
exit(1);
}
curses_init();
auto clk = std::make_unique<binclock>(fg, bg, LINES, COLS, clktype);
while (ch != 'q') {
ch = getch();
if (ch == 'c') {
fg = (fg + 1) % 8;
clk->updateColors(fg, bg);
continue;
}
if (ch == KEY_RESIZE) {
curses_init();
clk = std::make_unique<binclock>(fg, bg, LINES, COLS, clktype);
}
clk->updateTime();
clk->drawTime();
usleep(50000);
}
endwin();
}