menu PoC: implement quit item

This commit is contained in:
nick black 2020-11-24 03:23:32 -05:00
parent a7c7b8ff0b
commit 7c249bf9b9
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -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, }, },