mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
[kitty] add support for capslock, numlock, hyper, and super #2553
This commit is contained in:
parent
1f7f1a8e50
commit
a7a47f8e0c
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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){
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user