Define shifted variants for a few common keys

This commit is contained in:
Kovid Goyal 2016-11-24 12:57:37 +05:30
parent bbea86020a
commit 27170a481f
4 changed files with 43 additions and 10 deletions

View File

@ -27,6 +27,14 @@ key_map[defines.GLFW_KEY_ENTER] = b'\r'
key_map[defines.GLFW_KEY_BACKSPACE] = b'\x08'
key_map[defines.GLFW_KEY_TAB] = b'\t'
SHIFTED_KEYS = {
defines.GLFW_KEY_TAB: key_as_bytes('kcbt'),
defines.GLFW_KEY_HOME: key_as_bytes('kHOM'),
defines.GLFW_KEY_END: key_as_bytes('kEND'),
defines.GLFW_KEY_LEFT: key_as_bytes('kLFT'),
defines.GLFW_KEY_RIGHT: key_as_bytes('kRIT'),
}
control_codes = {k: 1 + i for i, k in enumerate(range(defines.GLFW_KEY_A, defines.GLFW_KEY_RIGHT_BRACKET))}
alt_codes = {k: (0x1b, k) for i, k in enumerate(range(defines.GLFW_KEY_A, defines.GLFW_KEY_RIGHT_BRACKET))}
@ -43,8 +51,7 @@ def interpret_key_event(key, scancode, mods):
x = key_map.get(key)
if x is not None:
if mods == defines.GLFW_MOD_SHIFT:
if key == defines.GLFW_KEY_TAB:
x = b'\x1b[Z'
x = SHIFTED_KEYS.get(key, x)
data.extend(x)
return bytes(data)

View File

@ -222,6 +222,18 @@ string_capabilities = {
# Select alternate charset
'smacs': r'\E(0',
'rmacs': r'\E(B',
# Shifted keys
'kRIT': r'\E[1;2C',
'kLFT': r'\E[1;2D',
'kEND': r'\E[1;2F',
'kHOM': r'\E[1;2H',
# Special keys
'khlp': r'',
'kund': r'',
'ka1': r'',
'ka3': r'',
'kc1': r'',
'kc3': r'',
}
termcap_aliases.update({
@ -317,7 +329,16 @@ termcap_aliases.update({
'ZR': 'ritm',
'as': 'smacs',
'ae': 'rmacs',
'#2': 'kHOM',
'#4': 'kLFT',
'*7': 'kEND',
'%i': 'kRIT',
'%1': 'khlp',
'&8': 'kund',
'K1': 'ka1',
'K3': 'ka3',
'K4': 'kc1',
'K5': 'kc3',
})
queryable_capabilities = numeric_capabilities.copy()

View File

@ -1,17 +1,17 @@
xterm-kitty|KovIdTTY,
xenl,
msgr,
mir,
npc,
am,
xenl,
km,
ccc,
mir,
mc5i,
lines#24,
pairs#32767,
it#8,
cols#80,
am,
colors#256,
it#8,
pairs#32767,
lines#24,
cols#80,
acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
bel=^G,
bold=\E[1m,
@ -50,6 +50,10 @@ xterm-kitty|KovIdTTY,
il1=\E[L,
ind=^J,
indn=\E[%p1%dS,
kEND=\E[1;2F,
kHOM=\E[1;2H,
kLFT=\E[1;2D,
kRIT=\E[1;2C,
kbs=\177,
kcbt=\E[Z,
kcub1=\EOD,
@ -70,6 +74,7 @@ xterm-kitty|KovIdTTY,
kf7=\E[18~,
kf8=\E[19~,
kf9=\E[20~,
khlp=,
khome=\EOH,
kich1=\E[2~,
kmous=\E[M,

Binary file not shown.