From 06d61b90254e1cffdd4a7a6c9a80c2ca1181d0df Mon Sep 17 00:00:00 2001 From: nick black Date: Wed, 12 Jan 2022 00:36:27 -0500 Subject: [PATCH] [ncmenu] use modifiers in all ncmenu_sections --- src/demo/hud.c | 26 +++++++++++++------------- src/poc/menu.c | 18 +++++++++--------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/demo/hud.c b/src/demo/hud.c index 9d6257f2c..b9bc1853f 100644 --- a/src/demo/hud.c +++ b/src/demo/hud.c @@ -255,37 +255,37 @@ bool menu_or_hud_key(struct notcurses *nc, const struct ncinput *ni){ return false; } // toggle the HUD - if(tmpni.id == 'H' && !tmpni.alt && !tmpni.ctrl){ + if(tmpni.id == 'H' && !ncinput_alt_p(&tmpni) && !ncinput_ctrl_p(&tmpni)){ hud_toggle(nc); return true; } - if(tmpni.id == 'P' && !tmpni.alt && !tmpni.ctrl){ + if(tmpni.id == 'P' && !ncinput_alt_p(&tmpni) && !ncinput_ctrl_p(&tmpni)){ fpsplot_toggle(nc); return true; } - if(tmpni.id == 'U' && !tmpni.alt && tmpni.ctrl){ + if(tmpni.id == 'U' && !ncinput_alt_p(&tmpni) && ncinput_ctrl_p(&tmpni)){ about_toggle(nc); return true; } - if(tmpni.id == 'd' && tmpni.alt && !tmpni.ctrl){ + if(tmpni.id == 'd' && ncinput_alt_p(&tmpni) && !ncinput_ctrl_p(&tmpni)){ debug_toggle(nc); return true; } - if(tmpni.id == 'L' && !tmpni.alt && tmpni.ctrl){ + if(tmpni.id == 'L' && !ncinput_alt_p(&tmpni) && ncinput_ctrl_p(&tmpni)){ if(menu){ ncmenu_rollup(menu); } notcurses_refresh(nc, NULL, NULL); return true; } - if(tmpni.id == 'R' && !tmpni.alt && tmpni.ctrl){ + if(tmpni.id == 'R' && !ncinput_alt_p(&tmpni) && ncinput_ctrl_p(&tmpni)){ if(menu){ ncmenu_rollup(menu); } interrupt_and_restart_demos(); return true; } - if(tmpni.id == 'q' && !tmpni.alt && !tmpni.ctrl){ + if(tmpni.id == 'q' && !ncinput_alt_p(&tmpni) && !ncinput_ctrl_p(&tmpni)){ if(menu){ ncmenu_rollup(menu); } @@ -305,23 +305,23 @@ struct ncmenu* menu_create(struct notcurses* nc){ struct ncmenu_item demo_items[] = { { .desc = MENUSTR_TOGGLE_HUD, .shortcut = { .id = 'H', }, }, { .desc = MENUSTR_TOGGLE_PLOT, .shortcut = { .id = 'P', }, }, - { .desc = MENUSTR_REDRAW_SCREEN, .shortcut = { .id = 'L', .ctrl = true }, }, + { .desc = MENUSTR_REDRAW_SCREEN, .shortcut = { .id = 'L', .modifiers = NCKEY_MOD_CTRL }, }, { .desc = NULL, }, - { .desc = MENUSTR_RESTART, .shortcut = { .id = 'R', .ctrl = true, }, }, + { .desc = MENUSTR_RESTART, .shortcut = { .id = 'R', .modifiers = NCKEY_MOD_CTRL, }, }, { .desc = MENUSTR_QUIT, .shortcut = { .id = 'q', }, }, }; struct ncmenu_item help_items[] = { - { .desc = MENUSTR_ABOUT, .shortcut = { .id = 'U', .ctrl = true, }, }, - { .desc = MENUSTR_DEBUG, .shortcut = { .id = 'd', .alt = true, }, }, + { .desc = MENUSTR_ABOUT, .shortcut = { .id = 'U', .modifiers = NCKEY_MOD_CTRL, }, }, + { .desc = MENUSTR_DEBUG, .shortcut = { .id = 'd', .modifiers = NCKEY_MOD_ALT, }, }, }; struct ncmenu_section sections[] = { { .name = "notcurses-demo", .items = demo_items, .itemcount = sizeof(demo_items) / sizeof(*demo_items), - .shortcut = { .id = 'o', .alt = true, }, }, + .shortcut = { .id = 'o', .modifiers = NCKEY_MOD_ALT, }, }, { .name = NULL, .items = NULL, .itemcount = 0, }, { .name = "help", .items = help_items, .itemcount = sizeof(help_items) / sizeof(*help_items), - .shortcut = { .id = 'h', .alt = true, }, }, + .shortcut = { .id = 'h', .modifiers = NCKEY_MOD_ALT, }, }, }; uint64_t headerchannels = 0; uint64_t sectionchannels = 0; diff --git a/src/poc/menu.c b/src/poc/menu.c index df91a96c7..de61d8a30 100644 --- a/src/poc/menu.c +++ b/src/poc/menu.c @@ -69,30 +69,30 @@ int main(void){ } notcurses_mice_enable(nc, NCMICE_BUTTON_EVENT); struct ncmenu_item demo_items[] = { - { .desc = "Restart", .shortcut = { .id = 'r', .ctrl = true, }, }, - { .desc = "Disabled", .shortcut = { .id = 'd', .ctrl = false, }, }, + { .desc = "Restart", .shortcut = { .id = 'r', .modifiers = NCKEY_MOD_CTRL, }, }, + { .desc = "Disabled", .shortcut = { .id = 'd', }, }, }; struct ncmenu_item file_items[] = { - { .desc = "New", .shortcut = { .id = 'n', .ctrl = true, }, }, - { .desc = "Open", .shortcut = { .id = 'o', .ctrl = true, }, }, - { .desc = "Close", .shortcut = { .id = 'c', .ctrl = true, }, }, + { .desc = "New", .shortcut = { .id = 'n', .modifiers = NCKEY_MOD_CTRL, }, }, + { .desc = "Open", .shortcut = { .id = 'o', .modifiers = NCKEY_MOD_CTRL, }, }, + { .desc = "Close", .shortcut = { .id = 'c', .modifiers = NCKEY_MOD_CTRL, }, }, { .desc = NULL, }, { .desc = "Quit", .shortcut = { .id = 'q', }, }, }; struct ncmenu_item help_items[] = { - { .desc = "About", .shortcut = { .id = 'a', .ctrl = true, }, }, + { .desc = "About", .shortcut = { .id = 'a', .modifiers = NCKEY_MOD_CTRL, }, }, }; struct ncmenu_section sections[] = { { .name = "Schwarzgerät", .items = demo_items, .itemcount = sizeof(demo_items) / sizeof(*demo_items), - .shortcut = { .id = 0x00e4, .alt = true, }, }, + .shortcut = { .id = 0x00e4, .modifiers = NCKEY_MOD_ALT, }, }, { .name = "File", .items = file_items, .itemcount = sizeof(file_items) / sizeof(*file_items), - .shortcut = { .id = 'f', .alt = true, }, }, + .shortcut = { .id = 'f', .modifiers = NCKEY_MOD_ALT, }, }, { .name = NULL, .items = NULL, .itemcount = 0, }, { .name = "Help", .items = help_items, .itemcount = sizeof(help_items) / sizeof(*help_items), - .shortcut = { .id = 'h', .alt = true, }, }, + .shortcut = { .id = 'h', .modifiers = NCKEY_MOD_ALT, }, }, }; ncmenu_options mopts; memset(&mopts, 0, sizeof(mopts));