forked from Ruunyox/bklk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
52 lines (50 loc) · 1002 Bytes
/
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
#include "bklk.h"
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include <memory>
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("bklk: usage & display options:\n\t-s\tseconds\n\t-m\tminutes");
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();
}