diff --git a/doc/man/man1/notcurses-input.1.md b/doc/man/man1/notcurses-input.1.md index 68138680c..de08bb8a6 100644 --- a/doc/man/man1/notcurses-input.1.md +++ b/doc/man/man1/notcurses-input.1.md @@ -21,7 +21,11 @@ of modifier indicators: * 'A'/'a': Alt was or was not pressed. * 'C'/'c': Ctrl was or was not pressed. * 'S'/'s': Shift was or was not pressed. +* 'U'/'u': Super was or was not pressed * 'M'/'m': Meta was or was not pressed. +* 'H'/'h': Hyper was or was not pressed. +* 'X'/'x': CapsLock was or was not pressed. +* '#'/'.': NumLock was or was not pressed. * 'L'/'R'/'P'/'u': Key was a release, repeat, press, or of unknown type. # OPTIONS diff --git a/include/notcurses/nckeys.h b/include/notcurses/nckeys.h index ff0135938..aef9d4e60 100644 --- a/include/notcurses/nckeys.h +++ b/include/notcurses/nckeys.h @@ -216,14 +216,14 @@ nckey_supppuab_p(uint32_t w){ // used with the modifiers bitmask. definitions come straight from the kitty // keyboard protocol. -#define NCKEY_MOD_SHIFT 1 -#define NCKEY_MOD_ALT 2 -#define NCKEY_MOD_CTRL 4 -#define NCKEY_MOD_SUPER 8 -#define NCKEY_MOD_HYPER 16 -#define NCKEY_MOD_META 32 -#define NCKEY_CAPSLOCK 64 -#define NCKEY_NUMLOCK 128 +#define NCKEY_MOD_SHIFT 1 +#define NCKEY_MOD_ALT 2 +#define NCKEY_MOD_CTRL 4 +#define NCKEY_MOD_SUPER 8 +#define NCKEY_MOD_HYPER 16 +#define NCKEY_MOD_META 32 +#define NCKEY_MOD_CAPSLOCK 64 +#define NCKEY_MOD_NUMLOCK 128 #ifdef __cplusplus } // extern "C" diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index d48f183ac..02387d55c 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -1138,9 +1138,11 @@ typedef struct ncinput { uint32_t id; // Unicode codepoint or synthesized NCKEY event int y, x; // y/x cell coordinate of event, -1 for undefined char utf8[5]; // utf8 representation, if one exists + // DEPRECATED do not use! going away in 4.0 bool alt; // was alt held? bool shift; // was shift held? bool ctrl; // was ctrl held? + // END DEPRECATION enum { NCTYPE_UNKNOWN, NCTYPE_PRESS, @@ -1171,6 +1173,26 @@ ncinput_meta_p(const ncinput* n){ return (n->modifiers & NCKEY_MOD_META); } +static inline bool +ncinput_super_p(const ncinput* n){ + return (n->modifiers & NCKEY_MOD_SUPER); +} + +static inline bool +ncinput_hyper_p(const ncinput* n){ + return (n->modifiers & NCKEY_MOD_HYPER); +} + +static inline bool +ncinput_capslock_p(const ncinput* n){ + return (n->modifiers & NCKEY_MOD_CAPSLOCK); +} + +static inline bool +ncinput_numlock_p(const ncinput* n){ + return (n->modifiers & NCKEY_MOD_NUMLOCK); +} + // compare two ncinput structs for data equality. static inline bool ncinput_equal_p(const ncinput* n1, const ncinput* n2){ diff --git a/src/input/input.cpp b/src/input/input.cpp index 0abb48d70..a985fe2db 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -328,11 +328,15 @@ int input_demo(ncpp::NotCurses* nc) { break; } n->set_fg_rgb8(0xd0, 0xd0, 0xd0); - n->printf("%c%c%c%c%c ", + n->printf("%c%c%c%c%c%c%c%c%c ", + ncinput_shift_p(&ni) ? 'S' : 's', ncinput_alt_p(&ni) ? 'A' : 'a', ncinput_ctrl_p(&ni) ? 'C' : 'c', - ncinput_shift_p(&ni) ? 'S' : 's', + ncinput_super_p(&ni) ? 'U' : 'u', + ncinput_hyper_p(&ni) ? 'H' : 'h', ncinput_meta_p(&ni) ? 'M' : 'm', + ncinput_capslock_p(&ni) ? 'X' : 'x', + ncinput_numlock_p(&ni) ? '#' : '.', evtype_to_char(&ni)); if(r < 0x80){ n->set_fg_rgb8(128, 250, 64); @@ -347,7 +351,7 @@ int input_demo(ncpp::NotCurses* nc) { break; } if(NCKey::IsMouse(r)){ - if(n->printf(-1, NCAlign::Right, " x: %d y: %d", ni.x, ni.y) < 0){ + if(n->printf(-1, NCAlign::Right, " %d/%d", ni.x, ni.y) < 0){ break; } }