8 void winch_handler(int sig);
10 char** read_todo(FILE* file, int* length);
12 WINDOW* create_list_win(int height, int width, int y, int x);
14 void draw_todo(WINDOW* todo_win, char** todo_list, int todo_length);
19 main(int argc, char** argv)
30 signal(SIGWINCH, winch_handler);
32 // read command line args
33 flag = getopt(argc, argv, "o:n:");
37 // read from task file (might need to check for read and write permissions)
38 board_file = fopen(optarg, "r");
40 printf("%s does not exist\n", optarg);
44 todos = read_todo(board_file, &todo_length);
51 // make sure file does not exist
52 // however, it maybe be possible that an different error has occured (besides the file not existing)
53 if (access(optarg, F_OK) == 0) {
54 printf("%s already exists\n", optarg);
58 board_file = fopen(optarg, "w");
59 // write init stuff here
61 printf("Successfully created %s\n", optarg);
70 printf("Help string\n");
83 init_pair(1, COLOR_CYAN, COLOR_BLACK);
84 init_pair(2, COLOR_BLACK, COLOR_CYAN);
86 getmaxyx(stdscr, height, width);
90 todo_win = create_list_win(20, 40, 5, 5);
91 draw_todo(todo_win, todos, todo_length);
94 while ((ch = getch()) != 113) { // while not q
96 // ofc the first thing we need is vim keys
120 free(todos); // prob need to free each string in list too
126 winch_handler(int sig)
133 read_todo(FILE* file, int* length)
134 { // apparently getline isn't rly that portable, so consider other options
146 while ((nread = getline(&lineptr, &len, file)) != -1) {
148 out_arr = realloc(out_arr, (sizeof(char*))*out_len); // bad to keep resizing?
149 out_arr[out_len-1] = lineptr;
160 create_list_win(int height, int width, int y, int x)
162 WINDOW* new_win = newwin(height, width, y, x);
168 draw_todo(WINDOW* todo_win, char** todo_list, int todo_length) {
169 for (int i = 0; i < todo_length; i++) {
170 mvwprintw(todo_win, i+1, 2, todo_list[i]);