diff --git a/NEWS.md b/NEWS.md index d387b3b71..8b47e1364 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,10 @@ This document attempts to list user-visible changes and any major internal rearrangements of Notcurses. +* 2.3.2 (not yet released) + * `ncinput_nomod_p()` has been added. This function returns `true` if and + only if its `ncinput` argument has no modifiers active. + * 2.3.1 (2021-05-18) * Sprixels no longer interact with their associated plane's framebuffer. This means plane contents are maintainted across blitting a sprixel and then diff --git a/USAGE.md b/USAGE.md index a1cb26eb9..8e299a28a 100644 --- a/USAGE.md +++ b/USAGE.md @@ -655,6 +655,11 @@ notcurses_getc_blocking(struct notcurses* n, ncinput* ni){ sigemptyset(&sigmask); return notcurses_getc(n, NULL, &sigmask, ni); } + +static inline bool +ncinput_nomod_p(const ncinput* ni){ + return !ni->alt && !ni->ctrl && !ni->shift; +} ``` By default, certain keys are mapped to signals by the terminal's line diff --git a/doc/man/man3/notcurses_input.3.md b/doc/man/man3/notcurses_input.3.md index a0196088b..559ffa2d9 100644 --- a/doc/man/man3/notcurses_input.3.md +++ b/doc/man/man3/notcurses_input.3.md @@ -27,6 +27,8 @@ typedef struct ncinput { **bool nckey_mouse_p(char32_t ***r***);** +**bool ncinput_nomod_p(const ncinput* ***ni***);** + **char32_t notcurses_getc(struct notcurses* ***n***, const struct timespec* ***ts***, const sigset_t* ***sigmask***, ncinput* ***ni***);** **char32_t notcurses_getc_nblock(struct notcurses* ***n***, ncinput* ***ni***);** diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index d9ab4d79b..74196767d 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -1055,6 +1055,11 @@ notcurses_getc_blocking(struct notcurses* n, ncinput* ni){ return notcurses_getc(n, NULL, &sigmask, ni); } +static inline bool +ncinput_nomod_p(const ncinput* ni){ + return !ni->alt && !ni->ctrl && !ni->shift; +} + // Enable the mouse in "button-event tracking" mode with focus detection and // UTF8-style extended coordinates. On failure, -1 is returned. On success, 0 // is returned, and mouse events will be published to notcurses_getc(). diff --git a/src/poc/tree.c b/src/poc/tree.c index 7f8ceb235..7da5e122d 100644 --- a/src/poc/tree.c +++ b/src/poc/tree.c @@ -399,9 +399,8 @@ tree_ui(struct notcurses* nc, struct nctree* tree){ if(notcurses_render(nc)){ return -1; } - continue; - } - if(ni.id == 'q'){ + }else if(ni.id == '/' && ncinput_nomod_p(&ni)){ + }else if(ni.id == 'q' && ncinput_nomod_p(&ni)){ return 0; } }