mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
keymap: add more (keypad) keycodes #9793
- K_KORIGIN instead of K_KCENTER: This name is similar to what is used by xev. Alternative could be K_KBEGIN as hinted here: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-PC-Style-Function-Keys But I find Begin and Home too similar, and it might induced some confusion. The naming looked related to some old keyboard configuration. - keymap.c: alias KPPeriod to kDel instead of kPoint. This might seems weird, but this is actually the behaviour that should be expected. libtermkey produces "KPPeriod" when num lock is off. To fix this would need to change this name in termkey. closes #9780 closes #9793
This commit is contained in:
parent
33f99431dc
commit
f6fb370b1b
@ -359,10 +359,16 @@ notation meaning equivalent decimal value(s) ~
|
||||
<End> end *end*
|
||||
<PageUp> page-up *page_up* *page-up*
|
||||
<PageDown> page-down *page_down* *page-down*
|
||||
<kUp> keypad cursor-up *keypad-cursor-up*
|
||||
<kDown> keypad cursor-down *keypad-cursor-down*
|
||||
<kLeft> keypad cursor-left *keypad-cursor-left*
|
||||
<kRight> keypad cursor-right *keypad-cursor-right*
|
||||
<kHome> keypad home (upper left) *keypad-home*
|
||||
<kEnd> keypad end (lower left) *keypad-end*
|
||||
<kOrigin> keypad origin (middle) *keypad-origin*
|
||||
<kPageUp> keypad page-up (upper right) *keypad-page-up*
|
||||
<kPageDown> keypad page-down (lower right) *keypad-page-down*
|
||||
<kDel> keypad delete *keypad-delete*
|
||||
<kPlus> keypad + *keypad-plus*
|
||||
<kMinus> keypad - *keypad-minus*
|
||||
<kMultiply> keypad * *keypad-multiply*
|
||||
@ -392,6 +398,9 @@ recognized as the non-keypad code. For example, when <kHome> sends the same
|
||||
code as <Home>, when pressing <kHome> Vim will think <Home> was pressed.
|
||||
Mapping <kHome> will not work then.
|
||||
|
||||
Note: If numlock is on, the |TUI| receives plain ASCII values, so
|
||||
mappings to <k0> - <k9> and <kPoint> will not work.
|
||||
|
||||
*<>*
|
||||
Examples are often given in the <> notation. Sometimes this is just to make
|
||||
clear what you need to type, but often it can be typed literally, e.g., with
|
||||
|
@ -1425,49 +1425,52 @@ int vgetc(void)
|
||||
/* a keypad or special function key was not mapped, use it like
|
||||
* its ASCII equivalent */
|
||||
switch (c) {
|
||||
case K_KPLUS: c = '+'; break;
|
||||
case K_KMINUS: c = '-'; break;
|
||||
case K_KDIVIDE: c = '/'; break;
|
||||
case K_KMULTIPLY: c = '*'; break;
|
||||
case K_KENTER: c = CAR; break;
|
||||
case K_KPOINT:
|
||||
c = '.'; break;
|
||||
case K_K0: c = '0'; break;
|
||||
case K_K1: c = '1'; break;
|
||||
case K_K2: c = '2'; break;
|
||||
case K_K3: c = '3'; break;
|
||||
case K_K4: c = '4'; break;
|
||||
case K_K5: c = '5'; break;
|
||||
case K_K6: c = '6'; break;
|
||||
case K_K7: c = '7'; break;
|
||||
case K_K8: c = '8'; break;
|
||||
case K_K9: c = '9'; break;
|
||||
case K_KPLUS: c = '+'; break;
|
||||
case K_KMINUS: c = '-'; break;
|
||||
case K_KDIVIDE: c = '/'; break;
|
||||
case K_KMULTIPLY: c = '*'; break;
|
||||
case K_KENTER: c = CAR; break;
|
||||
case K_KPOINT: c = '.'; break;
|
||||
case K_K0: c = '0'; break;
|
||||
case K_K1: c = '1'; break;
|
||||
case K_K2: c = '2'; break;
|
||||
case K_K3: c = '3'; break;
|
||||
case K_K4: c = '4'; break;
|
||||
case K_K5: c = '5'; break;
|
||||
case K_K6: c = '6'; break;
|
||||
case K_K7: c = '7'; break;
|
||||
case K_K8: c = '8'; break;
|
||||
case K_K9: c = '9'; break;
|
||||
|
||||
case K_XHOME:
|
||||
case K_ZHOME: if (mod_mask == MOD_MASK_SHIFT) {
|
||||
c = K_S_HOME;
|
||||
mod_mask = 0;
|
||||
} else if (mod_mask == MOD_MASK_CTRL) {
|
||||
c = K_C_HOME;
|
||||
mod_mask = 0;
|
||||
} else
|
||||
c = K_HOME;
|
||||
break;
|
||||
case K_XEND:
|
||||
case K_ZEND: if (mod_mask == MOD_MASK_SHIFT) {
|
||||
c = K_S_END;
|
||||
mod_mask = 0;
|
||||
} else if (mod_mask == MOD_MASK_CTRL) {
|
||||
c = K_C_END;
|
||||
mod_mask = 0;
|
||||
} else
|
||||
c = K_END;
|
||||
break;
|
||||
case K_XHOME:
|
||||
case K_ZHOME:
|
||||
if (mod_mask == MOD_MASK_SHIFT) {
|
||||
c = K_S_HOME;
|
||||
mod_mask = 0;
|
||||
} else if (mod_mask == MOD_MASK_CTRL) {
|
||||
c = K_C_HOME;
|
||||
mod_mask = 0;
|
||||
} else {
|
||||
c = K_HOME;
|
||||
}
|
||||
break;
|
||||
case K_XEND:
|
||||
case K_ZEND:
|
||||
if (mod_mask == MOD_MASK_SHIFT) {
|
||||
c = K_S_END;
|
||||
mod_mask = 0;
|
||||
} else if (mod_mask == MOD_MASK_CTRL) {
|
||||
c = K_C_END;
|
||||
mod_mask = 0;
|
||||
} else {
|
||||
c = K_END;
|
||||
}
|
||||
break;
|
||||
|
||||
case K_XUP: c = K_UP; break;
|
||||
case K_XDOWN: c = K_DOWN; break;
|
||||
case K_XLEFT: c = K_LEFT; break;
|
||||
case K_XRIGHT: c = K_RIGHT; break;
|
||||
case K_XUP: c = K_UP; break;
|
||||
case K_XDOWN: c = K_DOWN; break;
|
||||
case K_XLEFT: c = K_LEFT; break;
|
||||
case K_XRIGHT: c = K_RIGHT; break;
|
||||
}
|
||||
|
||||
/* For a multi-byte character get all the bytes and return the
|
||||
|
@ -163,6 +163,7 @@ static const struct key_name_entry {
|
||||
{ K_DEL, "Del" },
|
||||
{ K_DEL, "Delete" }, // Alternative name
|
||||
{ K_KDEL, "kDel" },
|
||||
{ K_KDEL, "KPPeriod" }, // libtermkey name
|
||||
{ K_UP, "Up" },
|
||||
{ K_DOWN, "Down" },
|
||||
{ K_LEFT, "Left" },
|
||||
@ -171,6 +172,14 @@ static const struct key_name_entry {
|
||||
{ K_XDOWN, "xDown" },
|
||||
{ K_XLEFT, "xLeft" },
|
||||
{ K_XRIGHT, "xRight" },
|
||||
{ K_KUP, "kUp" },
|
||||
{ K_KUP, "KP8" },
|
||||
{ K_KDOWN, "kDown" },
|
||||
{ K_KDOWN, "KP2" },
|
||||
{ K_KLEFT, "kLeft" },
|
||||
{ K_KLEFT, "KP4" },
|
||||
{ K_KRIGHT, "kRight" },
|
||||
{ K_KRIGHT, "KP6" },
|
||||
|
||||
{ K_F1, "F1" },
|
||||
{ K_F2, "F2" },
|
||||
@ -223,24 +232,36 @@ static const struct key_name_entry {
|
||||
{ K_INS, "Insert" },
|
||||
{ K_INS, "Ins" }, // Alternative name
|
||||
{ K_KINS, "kInsert" },
|
||||
{ K_KINS, "KP0" },
|
||||
{ K_HOME, "Home" },
|
||||
{ K_KHOME, "kHome" },
|
||||
{ K_KHOME, "KP7" },
|
||||
{ K_XHOME, "xHome" },
|
||||
{ K_ZHOME, "zHome" },
|
||||
{ K_END, "End" },
|
||||
{ K_KEND, "kEnd" },
|
||||
{ K_KEND, "KP1" },
|
||||
{ K_XEND, "xEnd" },
|
||||
{ K_ZEND, "zEnd" },
|
||||
{ K_PAGEUP, "PageUp" },
|
||||
{ K_PAGEDOWN, "PageDown" },
|
||||
{ K_KPAGEUP, "kPageUp" },
|
||||
{ K_KPAGEUP, "KP9" },
|
||||
{ K_KPAGEDOWN, "kPageDown" },
|
||||
{ K_KPAGEDOWN, "KP3" },
|
||||
{ K_KORIGIN, "kOrigin" },
|
||||
{ K_KORIGIN, "KP5" },
|
||||
|
||||
{ K_KPLUS, "kPlus" },
|
||||
{ K_KPLUS, "KPPlus" },
|
||||
{ K_KMINUS, "kMinus" },
|
||||
{ K_KMINUS, "KPMinus" },
|
||||
{ K_KDIVIDE, "kDivide" },
|
||||
{ K_KDIVIDE, "KPDiv" },
|
||||
{ K_KMULTIPLY, "kMultiply" },
|
||||
{ K_KMULTIPLY, "KPMult" },
|
||||
{ K_KENTER, "kEnter" },
|
||||
{ K_KENTER, "KPEnter" },
|
||||
{ K_KPOINT, "kPoint" },
|
||||
|
||||
{ K_K0, "k0" },
|
||||
|
@ -256,9 +256,13 @@ enum key_extra {
|
||||
#define K_ZERO TERMCAP2KEY(KS_ZERO, KE_FILLER)
|
||||
|
||||
#define K_UP TERMCAP2KEY('k', 'u')
|
||||
#define K_KUP TERMCAP2KEY('K', 'u') /* keypad up */
|
||||
#define K_DOWN TERMCAP2KEY('k', 'd')
|
||||
#define K_KDOWN TERMCAP2KEY('K', 'd') /* keypad down */
|
||||
#define K_LEFT TERMCAP2KEY('k', 'l')
|
||||
#define K_KLEFT TERMCAP2KEY('K', 'l') /* keypad left */
|
||||
#define K_RIGHT TERMCAP2KEY('k', 'r')
|
||||
#define K_KRIGHT TERMCAP2KEY('K', 'r') /* keypad right */
|
||||
#define K_S_UP TERMCAP2KEY(KS_EXTRA, KE_S_UP)
|
||||
#define K_S_DOWN TERMCAP2KEY(KS_EXTRA, KE_S_DOWN)
|
||||
#define K_S_LEFT TERMCAP2KEY('#', '4')
|
||||
@ -367,6 +371,7 @@ enum key_extra {
|
||||
#define K_PAGEDOWN TERMCAP2KEY('k', 'N')
|
||||
#define K_KPAGEUP TERMCAP2KEY('K', '3') /* keypad pageup (upper R.) */
|
||||
#define K_KPAGEDOWN TERMCAP2KEY('K', '5') /* keypad pagedown (lower R.) */
|
||||
#define K_KORIGIN TERMCAP2KEY('K', '2') /* keypad center */
|
||||
|
||||
#define K_KPLUS TERMCAP2KEY('K', '6') /* keypad plus */
|
||||
#define K_KMINUS TERMCAP2KEY('K', '7') /* keypad minus */
|
||||
|
@ -30,6 +30,22 @@ describe('mappings', function()
|
||||
add_mapping('<c-s-a-d-up>', '<c-s-a-d-up>')
|
||||
add_mapping('<c-d-a>', '<c-d-a>')
|
||||
add_mapping('<d-1>', '<d-1>')
|
||||
add_mapping('<khome>','<khome>')
|
||||
add_mapping('<kup>','<kup>')
|
||||
add_mapping('<kpageup>','<kpageup>')
|
||||
add_mapping('<kleft>','<kleft>')
|
||||
add_mapping('<korigin>','<korigin>')
|
||||
add_mapping('<kright>','<kright>')
|
||||
add_mapping('<kend>','<kend>')
|
||||
add_mapping('<kdown>','<kdown>')
|
||||
add_mapping('<kpagedown>','<kpagedown>')
|
||||
add_mapping('<kinsert>','<kinsert>')
|
||||
add_mapping('<kdel>','<kdel>')
|
||||
add_mapping('<kdivide>','<kdivide>')
|
||||
add_mapping('<kmultiply>','<kmultiply>')
|
||||
add_mapping('<kminus>','<kminus>')
|
||||
add_mapping('<kplus>','<kplus>')
|
||||
add_mapping('<kenter>','<kenter>')
|
||||
end)
|
||||
|
||||
it('ok', function()
|
||||
@ -48,6 +64,38 @@ describe('mappings', function()
|
||||
check_mapping('<c-d-a>', '<c-d-a>')
|
||||
check_mapping('<d-c-a>', '<c-d-a>')
|
||||
check_mapping('<d-1>', '<d-1>')
|
||||
check_mapping('<khome>','<khome>')
|
||||
check_mapping('<KP7>','<khome>')
|
||||
check_mapping('<kup>','<kup>')
|
||||
check_mapping('<KP8>','<kup>')
|
||||
check_mapping('<kpageup>','<kpageup>')
|
||||
check_mapping('<KP9>','<kpageup>')
|
||||
check_mapping('<kleft>','<kleft>')
|
||||
check_mapping('<KP4>','<kleft>')
|
||||
check_mapping('<korigin>','<korigin>')
|
||||
check_mapping('<KP5>','<korigin>')
|
||||
check_mapping('<kright>','<kright>')
|
||||
check_mapping('<KP6>','<kright>')
|
||||
check_mapping('<kend>','<kend>')
|
||||
check_mapping('<KP1>','<kend>')
|
||||
check_mapping('<kdown>','<kdown>')
|
||||
check_mapping('<KP2>','<kdown>')
|
||||
check_mapping('<kpagedown>','<kpagedown>')
|
||||
check_mapping('<KP3>','<kpagedown>')
|
||||
check_mapping('<kinsert>','<kinsert>')
|
||||
check_mapping('<KP0>','<kinsert>')
|
||||
check_mapping('<kdel>','<kdel>')
|
||||
check_mapping('<KPPeriod>','<kdel>')
|
||||
check_mapping('<kdivide>','<kdivide>')
|
||||
check_mapping('<KPDiv>','<kdivide>')
|
||||
check_mapping('<kmultiply>','<kmultiply>')
|
||||
check_mapping('<KPMult>','<kmultiply>')
|
||||
check_mapping('<kminus>','<kminus>')
|
||||
check_mapping('<KPMinus>','<kminus>')
|
||||
check_mapping('<kplus>','<kplus>')
|
||||
check_mapping('<KPPlus>','<kplus>')
|
||||
check_mapping('<kenter>','<kenter>')
|
||||
check_mapping('<KPEnter>','<kenter>')
|
||||
end)
|
||||
end)
|
||||
|
||||
|
@ -165,6 +165,7 @@ static const struct key_name_entry {
|
||||
{ K_DEL, "Del" },
|
||||
{ K_DEL, "Delete" }, // Alternative name
|
||||
{ K_KDEL, "kDel" },
|
||||
{ K_KDEL, "KPPeriod" }, // termkey KPPeriod value
|
||||
{ K_UP, "Up" },
|
||||
{ K_DOWN, "Down" },
|
||||
{ K_LEFT, "Left" },
|
||||
@ -173,6 +174,14 @@ static const struct key_name_entry {
|
||||
{ K_XDOWN, "xDown" },
|
||||
{ K_XLEFT, "xLeft" },
|
||||
{ K_XRIGHT, "xRight" },
|
||||
{ K_KUP, "kUp" },
|
||||
{ K_KUP, "KP8" },
|
||||
{ K_KDOWN, "kDown" },
|
||||
{ K_KDOWN, "KP2" },
|
||||
{ K_KLEFT, "kLeft" },
|
||||
{ K_KLEFT, "KP4" },
|
||||
{ K_KRIGHT, "kRight" },
|
||||
{ K_KRIGHT, "KP6" },
|
||||
|
||||
{ K_F1, "F1" },
|
||||
{ K_F2, "F2" },
|
||||
@ -225,8 +234,10 @@ static const struct key_name_entry {
|
||||
{ K_INS, "Insert" },
|
||||
{ K_INS, "Ins" }, // Alternative name
|
||||
{ K_KINS, "kInsert" },
|
||||
{ K_KINS, "KP0" },
|
||||
{ K_HOME, "Home" },
|
||||
{ K_KHOME, "kHome" },
|
||||
{ K_KHOME, "KP7" },
|
||||
{ K_XHOME, "xHome" },
|
||||
{ K_ZHOME, "zHome" },
|
||||
{ K_END, "End" },
|
||||
@ -236,13 +247,22 @@ static const struct key_name_entry {
|
||||
{ K_PAGEUP, "PageUp" },
|
||||
{ K_PAGEDOWN, "PageDown" },
|
||||
{ K_KPAGEUP, "kPageUp" },
|
||||
{ K_KPAGEUP, "KP9" },
|
||||
{ K_KPAGEDOWN, "kPageDown" },
|
||||
{ K_KPAGEDOWN, "KP3" },
|
||||
{ K_KORIGIN, "kOrigin" },
|
||||
{ K_KORIGIN, "KP5" },
|
||||
|
||||
{ K_KPLUS, "kPlus" },
|
||||
{ K_KPLUS, "KPPlus" },
|
||||
{ K_KMINUS, "kMinus" },
|
||||
{ K_KMINUS, "KPMinus" },
|
||||
{ K_KDIVIDE, "kDivide" },
|
||||
{ K_KDIVIDE, "KPDiv" },
|
||||
{ K_KMULTIPLY, "kMultiply" },
|
||||
{ K_KMULTIPLY, "KPMult" },
|
||||
{ K_KENTER, "kEnter" },
|
||||
{ K_KENTER, "KPEnter" },
|
||||
{ K_KPOINT, "kPoint" },
|
||||
|
||||
{ K_K0, "k0" },
|
||||
|
Loading…
Reference in New Issue
Block a user