mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
[kitty] handle hyper, capslock, numlock #2553
This commit is contained in:
parent
d72ef9fd8b
commit
1f7f1a8e50
@ -188,15 +188,13 @@ nckey_synthesized_p(uint32_t w){
|
||||
return w >= PRETERUNICODEBASE && w <= NCKEY_EOF;
|
||||
}
|
||||
|
||||
// Synonyms (so far as we're concerned)
|
||||
// Synonyms and aliases (so far as we're concerned)
|
||||
#define NCKEY_SCROLL_UP NCKEY_BUTTON4
|
||||
#define NCKEY_SCROLL_DOWN NCKEY_BUTTON5
|
||||
#define NCKEY_RETURN NCKEY_ENTER
|
||||
|
||||
// Just aliases, ma'am, from the 128 characters common to ASCII+UTF8
|
||||
#define NCKEY_TAB 0x09
|
||||
#define NCKEY_ESC 0x1b
|
||||
#define NCKEY_SPACE 0x20
|
||||
#define NCKEY_TAB 0x09
|
||||
#define NCKEY_ESC 0x1b
|
||||
#define NCKEY_SPACE 0x20
|
||||
|
||||
// Is this uint32_t from the Private Use Area in the BMP (Plane 0)?
|
||||
static inline bool
|
||||
@ -216,11 +214,16 @@ nckey_supppuab_p(uint32_t w){
|
||||
return w >= 0x100000 && w <= 0x10fffd; // 65,534 codepoints
|
||||
}
|
||||
|
||||
// modifiers bitmask
|
||||
#define NCKEY_MOD_SHIFT 1
|
||||
#define NCKEY_MOD_CTRL 2
|
||||
#define NCKEY_MOD_ALT 4
|
||||
#define NCKEY_MOD_META 8
|
||||
// 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
@ -1141,14 +1141,13 @@ typedef struct ncinput {
|
||||
bool alt; // was alt held?
|
||||
bool shift; // was shift held?
|
||||
bool ctrl; // was ctrl held?
|
||||
// FIXME kitty protocol also exposes hyper, meta, caps_lock, num_lock
|
||||
enum {
|
||||
NCTYPE_UNKNOWN,
|
||||
NCTYPE_PRESS,
|
||||
NCTYPE_REPEAT,
|
||||
NCTYPE_RELEASE,
|
||||
} evtype;
|
||||
unsigned modifiers;// bitmask over NCMOD_META
|
||||
unsigned modifiers;// bitmask over NCKEY_MOD_*
|
||||
int ypx, xpx; // pixel offsets within cell, -1 for undefined
|
||||
} ncinput;
|
||||
|
||||
|
22
src/lib/in.c
22
src/lib/in.c
@ -481,6 +481,9 @@ mark_pipe_ready(ipipe pipes[static 2]){
|
||||
// the last thing we do. if Ctrl or Shift are among the modifiers, we replace
|
||||
// any lowercase letter with its uppercase form, to maintain compatibility with
|
||||
// other input methods.
|
||||
//
|
||||
// note that this w orks entirely off 'modifiers', not the obsolete
|
||||
// shift/alt/ctrl booleans, which it neither sets nor tests!
|
||||
static void
|
||||
load_ncinput(inputctx* ictx, ncinput *tni){
|
||||
int synth = 0;
|
||||
@ -786,25 +789,18 @@ kitty_kbd(inputctx* ictx, int val, int mods, int evtype){
|
||||
assert(mods >= 0);
|
||||
assert(val > 0);
|
||||
logdebug("v/m/e %d %d %d", val, mods, evtype);
|
||||
// "If the modifier field is not present in the escape code, its default value
|
||||
// is 1 which means no modifiers."
|
||||
if(mods == 0){
|
||||
mods = 1;
|
||||
}
|
||||
ncinput tni = {
|
||||
.id = kitty_functional(val),
|
||||
.shift = mods && !!((mods - 1) & 0x1),
|
||||
.alt = mods && !!((mods - 1) & 0x2),
|
||||
.ctrl = mods && !!((mods - 1) & 0x4),
|
||||
.modifiers = mods - 1,
|
||||
};
|
||||
if(tni.shift){
|
||||
tni.modifiers |= NCKEY_MOD_SHIFT;
|
||||
}
|
||||
if(tni.ctrl){
|
||||
tni.modifiers |= NCKEY_MOD_CTRL;
|
||||
}
|
||||
if(tni.alt){
|
||||
tni.modifiers |= NCKEY_MOD_ALT;
|
||||
}
|
||||
if(mods && ((mods - 1) & 0x20)){
|
||||
tni.modifiers |= NCKEY_MOD_META;
|
||||
}
|
||||
// FIXME decode remaining modifiers super, hyper, caps_lock, num_lock
|
||||
switch(evtype){
|
||||
case 0:
|
||||
__attribute__ ((fallthrough));
|
||||
|
Loading…
x
Reference in New Issue
Block a user