1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-25 06:06:21 +03:00

Add Control Code \0 handling

This commit is contained in:
Ezequiel Rosas 2017-08-15 23:06:06 -05:00
parent 38840c5c58
commit 66f36e2974

View File

@ -78,19 +78,30 @@ extension NeoVimView {
}
override public func performKeyEquivalent(with event: NSEvent) -> Bool {
let type = event.type
let flags = event.modifierFlags
if .keyDown != event.type { return false }
let flags = event.modifierFlags.intersection(.deviceIndependentFlagsMask)
/* <C-Tab> & <C-S-Tab> do not trigger keyDown events.
Catch the key event here and pass it to keyDown.
(By rogual in NeoVim dot app
https://github.com/rogual/neovim-dot-app/pull/248/files )
*/
if .keyDown == type && flags.contains(.control) && 48 == event.keyCode {
if flags.contains(.control) && 48 == event.keyCode {
self.keyDown(with: event)
return true
}
guard let chars = event.characters else {
return false;
}
// Control code \0 causes rpc parsing problems.
// So we escape as early as possible
if chars == "\0" {
self.agent.vimInput(self.wrapNamedKeys("Nul"))
return true
}
return false
}