add ncinput_nomod_p()

This commit is contained in:
nick black 2021-05-21 20:06:36 -04:00
parent 08e6fefb25
commit 6969652031
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
5 changed files with 18 additions and 3 deletions

View File

@ -1,6 +1,10 @@
This document attempts to list user-visible changes and any major internal This document attempts to list user-visible changes and any major internal
rearrangements of Notcurses. 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) * 2.3.1 (2021-05-18)
* Sprixels no longer interact with their associated plane's framebuffer. This * Sprixels no longer interact with their associated plane's framebuffer. This
means plane contents are maintainted across blitting a sprixel and then means plane contents are maintainted across blitting a sprixel and then

View File

@ -655,6 +655,11 @@ notcurses_getc_blocking(struct notcurses* n, ncinput* ni){
sigemptyset(&sigmask); sigemptyset(&sigmask);
return notcurses_getc(n, NULL, &sigmask, ni); 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 By default, certain keys are mapped to signals by the terminal's line

View File

@ -27,6 +27,8 @@ typedef struct ncinput {
**bool nckey_mouse_p(char32_t ***r***);** **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(struct notcurses* ***n***, const struct timespec* ***ts***, const sigset_t* ***sigmask***, ncinput* ***ni***);**
**char32_t notcurses_getc_nblock(struct notcurses* ***n***, ncinput* ***ni***);** **char32_t notcurses_getc_nblock(struct notcurses* ***n***, ncinput* ***ni***);**

View File

@ -1055,6 +1055,11 @@ notcurses_getc_blocking(struct notcurses* n, ncinput* ni){
return notcurses_getc(n, NULL, &sigmask, 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 // Enable the mouse in "button-event tracking" mode with focus detection and
// UTF8-style extended coordinates. On failure, -1 is returned. On success, 0 // UTF8-style extended coordinates. On failure, -1 is returned. On success, 0
// is returned, and mouse events will be published to notcurses_getc(). // is returned, and mouse events will be published to notcurses_getc().

View File

@ -399,9 +399,8 @@ tree_ui(struct notcurses* nc, struct nctree* tree){
if(notcurses_render(nc)){ if(notcurses_render(nc)){
return -1; return -1;
} }
continue; }else if(ni.id == '/' && ncinput_nomod_p(&ni)){
} }else if(ni.id == 'q' && ncinput_nomod_p(&ni)){
if(ni.id == 'q'){
return 0; return 0;
} }
} }