mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
[ncmenu] use modifiers in all ncmenu_sections
This commit is contained in:
parent
a7a47f8e0c
commit
06d61b9025
@ -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;
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user