-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.cc
64 lines (56 loc) · 1.98 KB
/
main.cc
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
#include <locale.h>
#include <menu.h>
#include <ncurses.h>
#include "doneyet-config.h"
#include "workspace.h"
int main(int argc, char** argv) {
if (argc >= 2) { // at least one argument or more
printf(
"%s does not understand any command line arguments yet.\nHere, have a "
"help page :-)\n",
argv[0]);
printf("%s", __HELPTEXT__);
return 0;
} else { // no arguments supplied
DoneyetConfig* config = DoneyetConfig::GlobalConfig();
if (config == NULL) {
fprintf(stderr, "Unable to parse config file.\n");
return 1;
}
setlocale(
LC_ALL,
""); // setting locale helps drawing (still not entirely sure why)
initscr(); // Create the standard window.
keypad(stdscr, true); // Enable keyboard mappings
nonl(); // Disable weird newline stuff.
cbreak(); // Take input characters one at a time.
noecho(); // We don't want input to be echoed
intrflush(stdscr, FALSE);
// If our terminal has color, start up colors
if (has_colors()) {
start_color();
if (assume_default_colors(config->ForegroundColor(),
config->BackgroundColor()) != OK) {
fprintf(stderr, "Unable to set default colors.\n");
endwin();
return 1;
}
// Make some color pairs
// TODO: Make the task drawing know which color pairs to use.
short background_color = config->BackgroundColor();
init_pair(1, COLOR_RED, background_color);
init_pair(2, COLOR_GREEN, background_color);
init_pair(3, COLOR_YELLOW, background_color);
init_pair(4, COLOR_BLUE, background_color);
init_pair(5, COLOR_CYAN, background_color);
init_pair(6, COLOR_MAGENTA, background_color);
init_pair(7, COLOR_WHITE, background_color);
init_pair(8, COLOR_YELLOW, COLOR_BLUE);
init_pair(9, COLOR_YELLOW, COLOR_BLUE);
}
Workspace w;
endwin();
delete config;
return 0;
}
}