7 void winch_handler(int sig);
9 char** read_todo(FILE* file, int* length);
11 WINDOW* create_list_win(int height, int width, int y, int x);
16 main(int argc, char** argv)
27 signal(SIGWINCH, winch_handler);
29 // read command line args
30 flag = getopt(argc, argv, "o:n:");
34 // read from task file (might need to check for read and write permissions)
35 board_file = fopen(optarg, "r");
37 printf("%s does not exist\n", optarg);
41 todos = read_todo(board_file, &todo_length);
48 // make sure file does not exist
49 // however, it maybe be possible that an different error has occured (besides the file not existing)
50 if (access(optarg, F_OK) == 0) {
51 printf("%s already exists\n", optarg);
55 board_file = fopen(optarg, "w");
56 // write init stuff here
58 printf("Successfully created %s\n", optarg);
67 printf("Help string\n");
80 init_pair(1, COLOR_CYAN, COLOR_BLACK);
81 init_pair(2, COLOR_BLACK, COLOR_CYAN);
83 getmaxyx(stdscr, height, width);
87 todo_win = create_list_win(20, 40, 5, 5);
88 for (int i = 0; i < todo_length; i++) {
89 mvwprintw(todo_win, i+1, 2, todos[i]);
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 // remove new line character (maybe just write own new line func later)
150 /* lineptr = realloc(*lineptr, len-2); */
151 /* *(lineptr+len-1) = '\0'; */
152 /* printf(lineptr); */
153 /* lineptr = realloc(lineptr, len-1); //maybe watch out for empty lines */
154 /* *(lineptr+len-3) = '\0'; */
156 out_arr[out_len-1] = lineptr;
167 create_list_win(int height, int width, int y, int x)
169 WINDOW* new_win = newwin(height, width, y, x);