[demo] add ctrl+L to menu

This commit is contained in:
nick black 2021-12-06 03:40:55 -05:00
parent b8a548873e
commit 02d95dc5af
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 11 additions and 5 deletions

View File

@ -111,6 +111,7 @@ The following keypresses are recognized (and are also available from the menu):
with the mouse.
* **P**: Toggle the FPS graph.
* **Ctrl-R**: Restart the demo.
* **Ctrl-L**: Redraw the screen.
* **Alt-d**: Toggle a window with debugging information.
* **q**: Quit.

View File

@ -49,6 +49,7 @@ static struct ncplane* debug; // "debug info" modal popup
#define MENUSTR_TOGGLE_HUD "Toggle HUD"
#define MENUSTR_TOGGLE_PLOT "Toggle FPS plot"
#define MENUSTR_REDRAW_SCREEN "Redraw the screen"
#define MENUSTR_RESTART "Restart"
#define MENUSTR_ABOUT "About"
#define MENUSTR_DEBUG "Debug info"
@ -270,6 +271,13 @@ bool menu_or_hud_key(struct notcurses *nc, const struct ncinput *ni){
debug_toggle(nc);
return true;
}
if(tmpni.id == 'L' && !tmpni.alt && tmpni.ctrl){
if(menu){
ncmenu_rollup(menu);
}
notcurses_refresh(nc, NULL, NULL);
return true;
}
if(tmpni.id == 'R' && !tmpni.alt && tmpni.ctrl){
if(menu){
ncmenu_rollup(menu);
@ -297,6 +305,7 @@ 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 = NULL, },
{ .desc = MENUSTR_RESTART, .shortcut = { .id = 'R', .ctrl = true, }, },
{ .desc = MENUSTR_QUIT, .shortcut = { .id = 'q', }, },

View File

@ -87,11 +87,7 @@ uint32_t demo_getc(struct notcurses* nc, const struct timespec* ts, ncinput* ni)
handoff = true;
}
}else{
if(id == 'L' && q->ni.ctrl){
notcurses_refresh(nc, NULL, NULL);
}else{
handoff = true;
}
handoff = true;
}
}
if(handoff && ni){