ctlInputMethod // Make the IME works with Terminal.app from now on.
This commit is contained in:
parent
7aa44aeca4
commit
3a3310cc8e
|
@ -186,11 +186,6 @@ class ctlInputMethod: IMKInputController {
|
|||
let attributes: [AnyHashable: Any]? = (client as? IMKTextInput)?.attributes(forCharacterIndex: 0, lineHeightRectangle: &textFrame)
|
||||
let useVerticalMode = (attributes?["IMKTextOrientation"] as? NSNumber)?.intValue == 0 || false
|
||||
|
||||
if (client as? IMKTextInput)?.bundleIdentifier() == "com.apple.Terminal" &&
|
||||
NSStringFromClass(client.self as! AnyClass) == "IPMDServerClientWrapper" {
|
||||
currentDeferredClient = client
|
||||
}
|
||||
|
||||
let input = KeyHandlerInput(event: event, isVerticalMode: useVerticalMode)
|
||||
|
||||
let result = keyHandler.handle(input: input, state: state) { newState in
|
||||
|
@ -332,15 +327,6 @@ extension ctlInputMethod {
|
|||
if buffer.isEmpty {
|
||||
return
|
||||
}
|
||||
// if it's Terminal, we don't commit at the first call (the client of which will not be IPMDServerClientWrapper)
|
||||
// then we defer the update in the next runloop round -- so that the composing buffer is not
|
||||
// meaninglessly flushed, an annoying bug in Terminal.app since Mac OS X 10.5
|
||||
if (client as? IMKTextInput)?.bundleIdentifier() == "com.apple.Terminal" && NSStringFromClass(client.self as! AnyClass) != "IPMDServerClientWrapper" {
|
||||
let innerCurrentDeferredClient = currentDeferredClient
|
||||
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()) {
|
||||
(innerCurrentDeferredClient as? IMKTextInput)?.insertText(buffer, replacementRange: NSRange(location: NSNotFound, length: NSNotFound))
|
||||
}
|
||||
}
|
||||
(client as? IMKTextInput)?.insertText(buffer, replacementRange: NSRange(location: NSNotFound, length: NSNotFound))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue