From: Daniel Liu Date: Fri, 19 Feb 2021 17:47:03 +0000 (-0500) Subject: trying to fix term resize X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=edba973b080b9c28bc29fe3e10fd63de5a2f7356;p=taskasaur.git trying to fix term resize --- diff --git a/menu.c b/menu.c index 0ee76a5..7977896 100644 --- a/menu.c +++ b/menu.c @@ -230,8 +230,6 @@ delete_item(Menu* menu, int index) menu->selected_item = menu->menu_length-1; } - wclear(menu->sub_win); - return 0; } @@ -262,10 +260,6 @@ menu_insert_mode(Menu* menu, int insert_index) char temp[MAX_CONTENTS_LENGTH+1]; // remember null char* new_contents; - /* this is bad */ - wclear(menu->sub_win); - render_menu(menu); - curs_on(); /* move cursor to right spot */ @@ -357,9 +351,7 @@ int render_menu(Menu* menu) { /* draw outer menu (prob dont need this every render) */ - int menu_header_color; - - /* menu_header_color = */ + /* wclear(menu->menu_win); */ wattron(menu->menu_win, COLOR_PAIR( (menu->focused == true) ? TS_MENU_SELECTED: TS_MENU_NONSELECTED @@ -368,6 +360,8 @@ render_menu(Menu* menu) wattroff(menu->menu_win, COLOR_PAIR(0)); /* draw inner menu */ + wclear(menu->sub_win); + int cur_line = 0; for (int i = 0; i < menu->menu_length-menu->scroll_offset; i++) { diff --git a/taskasaur.c b/taskasaur.c index cb929e9..783ed90 100644 --- a/taskasaur.c +++ b/taskasaur.c @@ -6,6 +6,7 @@ #include "config.h" void render_step(BoardMenu* boardmenu); +void save_to_file(char* filepath, BoardMenu* boardmenu); int main(int argc, char** argv) @@ -27,7 +28,7 @@ main(int argc, char** argv) /* need to render before user presses anything */ render_step(boardmenu); - char ch; + int ch; while ((ch = getch()) != BINDING_QUIT) { Menu* active_menu; @@ -149,23 +150,28 @@ main(int argc, char** argv) menu_driver(active_menu, MENU_EDIT); break; case BINDING_SELECT: - break; case BINDING_WRITE: - { - Board* writeboard; - writeboard = boardmenu_to_board(boardmenu); - - begin_write(boardfile_name, writeboard); - free_board(writeboard); - } + save_to_file(boardfile_name, boardmenu); + break; + case KEY_RESIZE: + /* ; */ + /* int y, x; */ + /* char out[10]; */ + /* getmaxyx(stdscr, y, x); */ + /* sprintf(out, "%d,%d", y, x); */ + /* mvprintw(20, 20, out); */ + /* resize_term(y, x); */ break; } render_step(boardmenu); } + + /* save on exit - this causes weird stuff to happen, maybe it's not given enough time to write before program exits? */ + /* save_to_file(boardfile_name, boardmenu); */ exit_tscurses(); return 0; @@ -186,3 +192,13 @@ render_step(BoardMenu* boardmenu) render_menu(curmenu); } } + +void +save_to_file(char* filepath, BoardMenu* boardmenu) +{ + Board* writeboard; + writeboard = boardmenu_to_board(boardmenu); + + begin_write(filepath, writeboard); + free_board(writeboard); +}