From 7c249bf9b95a2d5a93e67a65d199863b0d415ce8 Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 24 Nov 2020 03:23:32 -0500 Subject: [PATCH] menu PoC: implement quit item --- src/poc/menu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/poc/menu.c b/src/poc/menu.c index 3525957ff..39c9e4b06 100644 --- a/src/poc/menu.c +++ b/src/poc/menu.c @@ -34,6 +34,15 @@ run_menu(struct notcurses* nc, struct ncmenu* ncm){ ncmenu_destroy(ncm); ncplane_destroy(selplane); return 0; + }else if(keypress == NCKEY_ENTER){ // selected a menu item + const char* sel; + if( (sel = ncmenu_selected(ncm, &ni)) ){ + if(strcmp(sel, "Quit") == 0){ + ncmenu_destroy(ncm); + ncplane_destroy(selplane); + return 0; + } + } } } ncplane_erase(selplane); @@ -71,7 +80,7 @@ int main(void){ { .desc = "Open", .shortcut = { .id = 'o', .ctrl = true, }, }, { .desc = "Close", .shortcut = { .id = 'c', .ctrl = true, }, }, { .desc = NULL, }, - { .desc = "Quit", .shortcut = { .id = 'q', .ctrl = true, }, }, + { .desc = "Quit", .shortcut = { .id = 'q', }, }, }; struct ncmenu_item help_items[] = { { .desc = "About", .shortcut = { .id = 'a', .ctrl = true, }, },