mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
[kitty] handle some more functional forms #2184
This commit is contained in:
parent
bc011591c1
commit
316c192426
@ -98,6 +98,27 @@ extern "C" {
|
||||
#define NCKEY_EXIT suppuabize(133)
|
||||
#define NCKEY_PRINT suppuabize(134)
|
||||
#define NCKEY_REFRESH suppuabize(135)
|
||||
// these keys aren't generally available outside of the kitty protocol
|
||||
#define NCKEY_CAPS_LOCK suppuabize(150)
|
||||
#define NCKEY_SCROLL_LOCK suppuabize(151)
|
||||
#define NCKEY_NUM_LOCK suppuabize(152)
|
||||
#define NCKEY_PRINT_SCREEN suppuabize(150)
|
||||
#define NCKEY_PAUSE suppuabize(151)
|
||||
#define NCKEY_MENU suppuabize(152)
|
||||
// media keys, similarly only available through kitty's protocol
|
||||
#define NCKEY_MEDIA_PLAY suppuabize(158)
|
||||
#define NCKEY_MEDIA_PAUSE suppuabize(159)
|
||||
#define NCKEY_MEDIA_PPAUSE suppuabize(160)
|
||||
#define NCKEY_MEDIA_REV suppuabize(161)
|
||||
#define NCKEY_MEDIA_STOP suppuabize(162)
|
||||
#define NCKEY_MEDIA_FF suppuabize(163)
|
||||
#define NCKEY_MEDIA_REWIND suppuabize(164)
|
||||
#define NCKEY_MEDIA_NEXT suppuabize(165)
|
||||
#define NCKEY_MEDIA_PREV suppuabize(166)
|
||||
#define NCKEY_MEDIA_RECORD suppuabize(167)
|
||||
#define NCKEY_MEDIA_LVOL suppuabize(168)
|
||||
#define NCKEY_MEDIA_RVOL suppuabize(169)
|
||||
#define NCKEY_MEDIA_MUTE suppuabize(170)
|
||||
// Mouse events. We try to encode some details into the char32_t (i.e. which
|
||||
// button was pressed), but some is embedded in the ncinput event. The release
|
||||
// event is generic across buttons; callers must maintain state, if they care.
|
||||
|
38
src/lib/in.c
38
src/lib/in.c
@ -629,6 +629,20 @@ kitty_kbd(inputctx* ictx, int val, int mods, int evtype){
|
||||
static int
|
||||
kitty_cb_simple(inputctx* ictx){
|
||||
unsigned val = amata_next_numeric(&ictx->amata, "\x1b[", 'u');
|
||||
if(val >= 57344 && val <= 63743){
|
||||
if(val >= 57376 && val <= 57398){
|
||||
val = NCKEY_F13 + val - 57376;
|
||||
}else if(val >= 57428 && val <= 57440){
|
||||
val = NCKEY_MEDIA_PLAY + val - 57428;
|
||||
}else switch(val){
|
||||
case 57358: val = NCKEY_CAPS_LOCK; break;
|
||||
case 57359: val = NCKEY_SCROLL_LOCK; break;
|
||||
case 57360: val = NCKEY_NUM_LOCK; break;
|
||||
case 57361: val = NCKEY_PRINT_SCREEN; break;
|
||||
case 57362: val = NCKEY_PAUSE; break;
|
||||
case 57363: val = NCKEY_MENU; break;
|
||||
}
|
||||
}
|
||||
kitty_kbd(ictx, val, 0, 0);
|
||||
return 2;
|
||||
}
|
||||
@ -647,6 +661,12 @@ kitty_cb_functional(inputctx* ictx){
|
||||
unsigned mods = amata_next_numeric(&ictx->amata, "", ':');
|
||||
unsigned ev = amata_next_numeric(&ictx->amata, "", '~');
|
||||
switch(val){
|
||||
case 2: val = NCKEY_INS; break;
|
||||
case 3: val = NCKEY_DEL; break;
|
||||
case 5: val = NCKEY_PGUP; break;
|
||||
case 6: val = NCKEY_PGDOWN; break;
|
||||
case 7: val = NCKEY_HOME; break;
|
||||
case 8: val = NCKEY_END; break;
|
||||
case 11: val = NCKEY_F01; break;
|
||||
case 12: val = NCKEY_F02; break;
|
||||
case 13: val = NCKEY_F03; break;
|
||||
@ -728,6 +748,22 @@ kitty_cb_up(inputctx* ictx){
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int
|
||||
kitty_cb_end(inputctx* ictx){
|
||||
unsigned mods = amata_next_numeric(&ictx->amata, "\x1b[1;", ':');
|
||||
unsigned ev = amata_next_numeric(&ictx->amata, "", 'F');
|
||||
kitty_kbd(ictx, NCKEY_END, mods, ev);
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int
|
||||
kitty_cb_home(inputctx* ictx){
|
||||
unsigned mods = amata_next_numeric(&ictx->amata, "\x1b[1;", ':');
|
||||
unsigned ev = amata_next_numeric(&ictx->amata, "", 'H');
|
||||
kitty_kbd(ictx, NCKEY_HOME, mods, ev);
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int
|
||||
kitty_cb_complex(inputctx* ictx){
|
||||
unsigned val = amata_next_numeric(&ictx->amata, "\x1b[", ';');
|
||||
@ -1043,6 +1079,8 @@ build_cflow_automaton(inputctx* ictx){
|
||||
{ "[1;\\N:\\NC", kitty_cb_right, },
|
||||
{ "[1;\\N:\\NB", kitty_cb_down, },
|
||||
{ "[1;\\N:\\NA", kitty_cb_up, },
|
||||
{ "[1;\\N:\\NF", kitty_cb_end, },
|
||||
{ "[1;\\N:\\NH", kitty_cb_home, },
|
||||
{ "[?\\Nu", kitty_keyboard_cb, },
|
||||
{ "[?1;2c", da1_cb, }, // CSI ? 1 ; 2 c ("VT100 with Advanced Video Option")
|
||||
{ "[?1;0c", da1_cb, }, // CSI ? 1 ; 0 c ("VT101 with No Options")
|
||||
|
Loading…
Reference in New Issue
Block a user