mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-29 03:53:38 +03:00
Refactor NeoVimView.keydown
This commit is contained in:
parent
a09be854f9
commit
c6c822f539
@ -27,22 +27,19 @@ extension NeoVimView {
|
|||||||
? event.charactersIgnoringModifiers!.lowercased()
|
? event.charactersIgnoringModifiers!.lowercased()
|
||||||
: event.charactersIgnoringModifiers!
|
: event.charactersIgnoringModifiers!
|
||||||
|
|
||||||
if KeyUtils.isSpecial(key: charsIgnoringModifiers) {
|
let flags = self.vimModifierFlags(modifierFlags) ?? ""
|
||||||
if let vimModifiers = self.vimModifierFlags(modifierFlags) {
|
let isNamedKey = KeyUtils.isSpecial(key: charsIgnoringModifiers)
|
||||||
self.agent.vimInput(
|
let isPlain = flags.isEmpty && !isNamedKey
|
||||||
self.wrapNamedKeys(vimModifiers + KeyUtils.namedKeyFrom(key: charsIgnoringModifiers))
|
let isWrapNeeded = !isPlain
|
||||||
)
|
|
||||||
} else {
|
|
||||||
self.agent.vimInput(self.wrapNamedKeys(KeyUtils.namedKeyFrom(key: charsIgnoringModifiers)))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if let vimModifiers = self.vimModifierFlags(modifierFlags) {
|
|
||||||
self.agent.vimInput(self.wrapNamedKeys(vimModifiers + charsIgnoringModifiers))
|
|
||||||
} else {
|
|
||||||
self.agent.vimInput(self.vimPlainString(chars))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
let namedChars = isNamedKey
|
||||||
|
? KeyUtils.namedKeyFrom(key: charsIgnoringModifiers)
|
||||||
|
: charsIgnoringModifiers
|
||||||
|
let finalInput = isWrapNeeded
|
||||||
|
? self.wrapNamedKeys(flags + namedChars)
|
||||||
|
: self.vimPlainString(chars)
|
||||||
|
|
||||||
|
self.agent.vimInput(finalInput)
|
||||||
self.keyDownDone = true
|
self.keyDownDone = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user