- // make sure file does not exist
- // however, it maybe be possible that an different error has occured (besides the file not existing)
- if (access(optarg, F_OK) == 0) {
- printf("%s already exists\n", optarg);
- return 1;
- }
- // create a file here
- board_file = fopen(optarg, "w");
- // write init stuff here
- fclose(board_file);
- printf("Successfully created %s\n", optarg);
-
- todos = malloc(0);
- todo_length = 0;
-
- break;
-
- case -1:
- case '?':
- printf("Help string\n");
- return 2;
- }
-
- // start ncurses
- initscr();
- cbreak();
- noecho();
- curs_set(0);
- keypad(stdscr, TRUE);
- start_color();
-
- /* colors */
- init_pair(SELECTED_COLOR, selected_color, COLOR_BLACK);
- init_pair(NON_SELECTED_COLOR, non_selected_color, COLOR_BLACK);
-
- getmaxyx(stdscr, height, width);
-
- todo_win = create_win(20, 40, 5, 5);
- todo_menu = create_todo_menu(todo_win, todos, todo_length);
- post_menu(todo_menu);
- refresh();
- wrefresh(todo_win);
-
- while ((ch = getch()) != BINDING_QUIT) {
-
- switch (ch) {
- case BINDING_SCROLL_UP:
- menu_driver(todo_menu, REQ_UP_ITEM);
- break;
- case BINDING_SCROLL_DOWN:
- menu_driver(todo_menu, REQ_DOWN_ITEM);
- break;
- case BINDING_JUMP_TOP:
- menu_driver(todo_menu, REQ_FIRST_ITEM);
- break;
- case BINDING_JUMP_BOTTOM:
- menu_driver(todo_menu, REQ_LAST_ITEM);
- break;
- case BINDING_SELECT:
- break;
- }
- wrefresh(todo_win);