-char**
-read_todo(FILE* file, int* length)
-{ // apparently getline isn't rly that portable, so consider other options
- char** out_arr;
- int out_len;
- char* lineptr;
- size_t len;
- ssize_t nread;
-
- out_arr = NULL;
- out_len = 0;
- lineptr = NULL;
- len = 0;
-
- while ((nread = getline(&lineptr, &len, file)) != -1) {
- out_len++;
- out_arr = realloc(out_arr, (sizeof(char*))*out_len); // bad to keep resizing?
-
- lineptr[strcspn(lineptr, "\n")] = 0; // remove newline
- out_arr[out_len-1] = lineptr;
-
- lineptr = NULL;
- }
-
- *length = out_len;
- return out_arr;
-}
-
-WINDOW*
-create_win(int height, int width, int y, int x)
-{
- WINDOW* new_win = newwin(height, width, y, x);
- wrefresh(new_win);
- return new_win;
-}
-
-MENU*
-create_todo_menu(WINDOW* win, char** todo_list, int todo_length)
-{
- MENU* todo_menu;
- ITEM** item_list;
- ITEM* cur_item;
- int wheight, wwidth;
-
- item_list = malloc((todo_length+1)*sizeof(ITEM*));
- for (int i = 0; i < todo_length; i++) {
- item_list[i] = new_item(todo_list[i], "");
- set_item_userptr(item_list[i], on_select);
- }
- item_list[todo_length] = NULL; // last item needs to be a null pointer for some reason?
-
- todo_menu = new_menu(item_list);
-
- getmaxyx(win, wheight, wwidth);
- set_menu_win(todo_menu, win);
- set_menu_sub(todo_menu, derwin(win, wheight-2, wwidth-2, 1, 2));
- set_menu_mark(todo_menu, "");
- set_menu_spacing(todo_menu, 1, 2, 1);
- set_menu_fore(todo_menu, COLOR_PAIR(SELECTED_COLOR));
- set_menu_back(todo_menu, COLOR_PAIR(NON_SELECTED_COLOR));
-
- box(win, 0, 0); //temp
-
- return todo_menu;
-}
-
-void
-on_select(char *item)
-{
- printf("lol");
-}
-
-void
-free_todo(char** todo_list, int todo_length)
-{
- // probably check if list is too short or too long
- for (int i = 0; i < todo_length; i++) {
- free(todo_list[i]);
- }
- free(todo_list);
-}