Make alt+backspace delete the previous word

i.e. alt+backspace now sends ^W (werase). THis matches the behavior of
terminal.app and gnome-terminal. Fixes #264
This commit is contained in:
Kovid Goyal 2018-01-05 21:08:42 +05:30
parent 88e9c21a3b
commit fdcfcfa1b9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 25 additions and 19 deletions

16
kitty/keys.h generated
View File

@ -920,7 +920,7 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) {
case 52: // TAB case 52: // TAB
return "\x02\x1b\x09"; return "\x02\x1b\x09";
case 53: // BACKSPACE case 53: // BACKSPACE
return "\x02\x1b\x7f"; return "\x01\x17";
case 54: // INSERT case 54: // INSERT
return "\x06\x1b\x5b\x32\x3b\x33\x7e"; return "\x06\x1b\x5b\x32\x3b\x33\x7e";
case 55: // DELETE case 55: // DELETE
@ -1071,7 +1071,7 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) {
case 52: // TAB case 52: // TAB
return "\x03\x1b\x5b\x5a"; return "\x03\x1b\x5b\x5a";
case 53: // BACKSPACE case 53: // BACKSPACE
return "\x02\x1b\x7f"; return "\x01\x17";
case 54: // INSERT case 54: // INSERT
return "\x06\x1b\x5b\x32\x3b\x34\x7e"; return "\x06\x1b\x5b\x32\x3b\x34\x7e";
case 55: // DELETE case 55: // DELETE
@ -2118,7 +2118,7 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) {
case 52: // TAB case 52: // TAB
return "\x02\x1b\x09"; return "\x02\x1b\x09";
case 53: // BACKSPACE case 53: // BACKSPACE
return "\x02\x1b\x7f"; return "\x01\x17";
case 54: // INSERT case 54: // INSERT
return "\x06\x1b\x5b\x32\x3b\x33\x7e"; return "\x06\x1b\x5b\x32\x3b\x33\x7e";
case 55: // DELETE case 55: // DELETE
@ -2269,7 +2269,7 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) {
case 52: // TAB case 52: // TAB
return "\x03\x1b\x5b\x5a"; return "\x03\x1b\x5b\x5a";
case 53: // BACKSPACE case 53: // BACKSPACE
return "\x02\x1b\x7f"; return "\x01\x17";
case 54: // INSERT case 54: // INSERT
return "\x06\x1b\x5b\x32\x3b\x34\x7e"; return "\x06\x1b\x5b\x32\x3b\x34\x7e";
case 55: // DELETE case 55: // DELETE
@ -3324,7 +3324,7 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) {
case 52: // TAB case 52: // TAB
return "\x02\x1b\x09"; return "\x02\x1b\x09";
case 53: // BACKSPACE case 53: // BACKSPACE
return "\x02\x1b\x7f"; return "\x01\x17";
case 54: // INSERT case 54: // INSERT
return "\x06\x1b\x5b\x32\x3b\x33\x7e"; return "\x06\x1b\x5b\x32\x3b\x33\x7e";
case 55: // DELETE case 55: // DELETE
@ -3475,7 +3475,7 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) {
case 52: // TAB case 52: // TAB
return "\x03\x1b\x5b\x5a"; return "\x03\x1b\x5b\x5a";
case 53: // BACKSPACE case 53: // BACKSPACE
return "\x02\x1b\x7f"; return "\x01\x17";
case 54: // INSERT case 54: // INSERT
return "\x06\x1b\x5b\x32\x3b\x34\x7e"; return "\x06\x1b\x5b\x32\x3b\x34\x7e";
case 55: // DELETE case 55: // DELETE
@ -4522,7 +4522,7 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) {
case 52: // TAB case 52: // TAB
return "\x02\x1b\x09"; return "\x02\x1b\x09";
case 53: // BACKSPACE case 53: // BACKSPACE
return "\x02\x1b\x7f"; return "\x01\x17";
case 54: // INSERT case 54: // INSERT
return "\x06\x1b\x5b\x32\x3b\x33\x7e"; return "\x06\x1b\x5b\x32\x3b\x33\x7e";
case 55: // DELETE case 55: // DELETE
@ -4673,7 +4673,7 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) {
case 52: // TAB case 52: // TAB
return "\x03\x1b\x5b\x5a"; return "\x03\x1b\x5b\x5a";
case 53: // BACKSPACE case 53: // BACKSPACE
return "\x02\x1b\x7f"; return "\x01\x17";
case 54: // INSERT case 54: // INSERT
return "\x06\x1b\x5b\x32\x3b\x34\x7e"; return "\x06\x1b\x5b\x32\x3b\x34\x7e";
case 55: // DELETE case 55: // DELETE

View File

@ -26,7 +26,13 @@ def modify_complex_key(name, amt):
control_codes = {} control_codes = {}
smkx_key_map = {} smkx_key_map = {}
alt_codes = {defines.GLFW_KEY_TAB: b'\033\t', defines.GLFW_KEY_ENTER: b'\033\r', defines.GLFW_KEY_ESCAPE: b'\033\033', defines.GLFW_KEY_BACKSPACE: b'\033\177'} alt_codes = {
defines.GLFW_KEY_TAB: b'\033\t',
defines.GLFW_KEY_ENTER: b'\033\r',
defines.GLFW_KEY_ESCAPE: b'\033\033',
# alt+bs matches iTerm and gnome-terminal
defines.GLFW_KEY_BACKSPACE: b'\x17'
}
shift_alt_codes = alt_codes.copy() shift_alt_codes = alt_codes.copy()
shift_alt_codes[defines.GLFW_KEY_TAB] = key_as_bytes('kcbt') shift_alt_codes[defines.GLFW_KEY_TAB] = key_as_bytes('kcbt')
alt_mods = (defines.GLFW_MOD_ALT, defines.GLFW_MOD_SHIFT | defines.GLFW_MOD_ALT) alt_mods = (defines.GLFW_MOD_ALT, defines.GLFW_MOD_SHIFT | defines.GLFW_MOD_ALT)