From bbce00c6ef9ab6e790c6d81124911409add35811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ku=CC=88hl?= Date: Wed, 17 May 2017 14:16:01 +0200 Subject: [PATCH 1/2] Support shift modifier on special keys The NeoVimView.vimModifierFlags method only checks for the control, option, and command modifiers, which leads to the shift modifier getting lost. This change mitigates that by checking for the shift modifier and translating it to the `S-` key prefix. This change has the possible side effect of requiring additional `S-` prefixes, depending on the keyboard layout. For example, take a US keyboard with a -/_ key and press that key with control and shift depressed. Before this change, VimR would transmit ``, while after this change it transmits ``. --- SwiftNeoVim/NeoVimView.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SwiftNeoVim/NeoVimView.swift b/SwiftNeoVim/NeoVimView.swift index af969f6a..7bb44487 100644 --- a/SwiftNeoVim/NeoVimView.swift +++ b/SwiftNeoVim/NeoVimView.swift @@ -1036,6 +1036,7 @@ extension NeoVimView: NSTextInputClient { let control = modifierFlags.contains(.control) let option = modifierFlags.contains(.option) let command = modifierFlags.contains(.command) + let shift = modifierFlags.contains(.shift) if control { result += "C-" @@ -1049,6 +1050,10 @@ extension NeoVimView: NSTextInputClient { result += "D-" } + if shift { + result += "S-" + } + if result.characters.count > 0 { return result } From c8a8c3b93d3ea7c591f5dfe5a180d6f00bd63fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ku=CC=88hl?= Date: Wed, 17 May 2017 14:31:37 +0200 Subject: [PATCH 2/2] Add (Shift-)Tab as a special key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pressing Shift+Tab generates an NSEvent with characters `"\u{19}"` (and the shift modifier), which the backend doesn’t recognise as the Tab key. (Instead it gets mapped as , which makes sense given how ASCII control characters are interpreted.) This change fixes that by adding a corresponding entry to the KeyUtils.specialKeys dict. Of course sending still works because it is transmitted as ``. --- SwiftNeoVim/KeyUtils.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/SwiftNeoVim/KeyUtils.swift b/SwiftNeoVim/KeyUtils.swift index 0d948fcb..cf890b8b 100644 --- a/SwiftNeoVim/KeyUtils.swift +++ b/SwiftNeoVim/KeyUtils.swift @@ -56,6 +56,7 @@ class KeyUtils { NSF33FunctionKey: "F33", NSF34FunctionKey: "F34", NSF35FunctionKey: "F35", + 0x19: "Tab", ] static func isSpecial(key: String) -> Bool {