menu->selected_item = menu->menu_length-1;
}
- wclear(menu->sub_win);
-
return 0;
}
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 */
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
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++) {
#include "config.h"
void render_step(BoardMenu* boardmenu);
+void save_to_file(char* filepath, BoardMenu* boardmenu);
int
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;
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;
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);
+}