ctlInputMethod // Make the IME works with Terminal.app from now on.
This commit is contained in:
parent
f2d15628fe
commit
bc946d3117
|
@ -186,11 +186,6 @@ class ctlInputMethod: IMKInputController {
|
||||||
let attributes: [AnyHashable: Any]? = (client as? IMKTextInput)?.attributes(forCharacterIndex: 0, lineHeightRectangle: &textFrame)
|
let attributes: [AnyHashable: Any]? = (client as? IMKTextInput)?.attributes(forCharacterIndex: 0, lineHeightRectangle: &textFrame)
|
||||||
let useVerticalMode = (attributes?["IMKTextOrientation"] as? NSNumber)?.intValue == 0 || false
|
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 input = KeyHandlerInput(event: event, isVerticalMode: useVerticalMode)
|
||||||
|
|
||||||
let result = keyHandler.handle(input: input, state: state) { newState in
|
let result = keyHandler.handle(input: input, state: state) { newState in
|
||||||
|
@ -332,15 +327,6 @@ extension ctlInputMethod {
|
||||||
if buffer.isEmpty {
|
if buffer.isEmpty {
|
||||||
return
|
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))
|
(client as? IMKTextInput)?.insertText(buffer, replacementRange: NSRange(location: NSNotFound, length: NSNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue