diff --git a/include/tui.h b/include/tui.h index 1558f84..5b6f1b9 100644 --- a/include/tui.h +++ b/include/tui.h @@ -17,6 +17,7 @@ #define MAIN_OPTIONS "Options" #define MAIN_START "Start" #define MAIN_EXIT "Exit" +#define BACK_BUTTON "Back" #define MSG_COLOR 1 #define ICON_COLOR 2 diff --git a/src/tui_screen_main.c b/src/tui_screen_main.c index f0d84d9..64e9bec 100644 --- a/src/tui_screen_main.c +++ b/src/tui_screen_main.c @@ -77,8 +77,8 @@ tui_screen_t tui_screen_main() { set_menu_sub(main_menu, derwin(stdscr, 0, 0, 22, 50)); post_menu(main_menu); raw(); + refresh(); while (1) { - uint8_t target = 0; int ch = getch(); if (ch == KEY_LEFT) { menu_driver(main_menu, REQ_LEFT_ITEM); diff --git a/src/tui_screen_options.c b/src/tui_screen_options.c index 9baaa7a..ae6bc81 100644 --- a/src/tui_screen_options.c +++ b/src/tui_screen_options.c @@ -17,4 +17,35 @@ #include #include -tui_screen_t tui_screen_options() { return MAIN_SCREEN; } +tui_screen_t tui_screen_options() { + tui_screen_t ret = EXIT_SCREEN; + ITEM* back_button[2]; + MENU* back_menu; + back_button[0] = new_item("Back", ""); + back_button[1] = NULL; + back_menu = new_menu(back_button); + + move(21, 1); + hline(ACS_HLINE, 80 - 2); + + set_menu_format(back_menu, 1, 10); + set_menu_sub(back_menu, derwin(stdscr, 0, 0, 22, 68)); + post_menu(back_menu); + + + refresh(); + + while(1) { + int ch = getch(); + if (ch == 10) { + if (!(item_opts(current_item(back_menu)) & O_SELECTABLE)) continue; + if (!strcmp(current_item(back_menu)->name.str, BACK_BUTTON)) { + ret = MAIN_SCREEN; + } + goto end; + } + refresh(); + } +end: + return ret; +}