ctlIME // Secure the inline composition buffer when PCB is on.
This commit is contained in:
parent
7d37a76e52
commit
950288c682
|
@ -81,11 +81,12 @@ class ctlInputMethod: IMKInputController {
|
||||||
keyHandler.composer.clear()
|
keyHandler.composer.clear()
|
||||||
handle(state: keyHandler.buildInputtingState)
|
handle(state: keyHandler.buildInputtingState)
|
||||||
}
|
}
|
||||||
if state.hasComposition {
|
let isSecureMode = mgrPrefs.clientsIMKTextInputIncapable.contains(clientBundleIdentifier)
|
||||||
|
if state.hasComposition, !isSecureMode {
|
||||||
/// 將傳回的新狀態交給調度函式。
|
/// 將傳回的新狀態交給調度函式。
|
||||||
handle(state: IMEState.ofCommitting(textToCommit: state.displayedText))
|
handle(state: IMEState.ofCommitting(textToCommit: state.displayedText))
|
||||||
}
|
}
|
||||||
handle(state: IMEState.ofEmpty())
|
handle(state: isSecureMode ? IMEState.ofAbortion() : IMEState.ofEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - IMKInputController 方法
|
// MARK: - IMKInputController 方法
|
||||||
|
|
|
@ -13,6 +13,15 @@ import Cocoa
|
||||||
// MARK: - Tooltip Display and Candidate Display Methods
|
// MARK: - Tooltip Display and Candidate Display Methods
|
||||||
|
|
||||||
extension ctlInputMethod {
|
extension ctlInputMethod {
|
||||||
|
// 有些 App 會濫用內文組字區的內容來預測使用者的輸入行為。
|
||||||
|
// 對此類 App 有疑慮者,可以將這類 App 登記到客體管理員當中。
|
||||||
|
// 這樣,不但強制使用(限制讀音 20 個的)浮動組字窗,而且內文組字區只會顯示一個空格。
|
||||||
|
var attributedStringSecured: (NSAttributedString, NSRange) {
|
||||||
|
mgrPrefs.clientsIMKTextInputIncapable.contains(clientBundleIdentifier)
|
||||||
|
? (state.data.attributedStringPlaceholder, NSRange(location: 0, length: 0))
|
||||||
|
: (state.attributedString, NSRange(state.data.u16MarkedRange))
|
||||||
|
}
|
||||||
|
|
||||||
func lineHeightRect(zeroCursor: Bool = false) -> NSRect {
|
func lineHeightRect(zeroCursor: Bool = false) -> NSRect {
|
||||||
var lineHeightRect = NSRect.seniorTheBeast
|
var lineHeightRect = NSRect.seniorTheBeast
|
||||||
guard let client = client() else {
|
guard let client = client() else {
|
||||||
|
|
|
@ -96,7 +96,7 @@ extension ctlInputMethod {
|
||||||
guard let client = client() else { return }
|
guard let client = client() else { return }
|
||||||
if state.type == .ofAssociates {
|
if state.type == .ofAssociates {
|
||||||
client.setMarkedText(
|
client.setMarkedText(
|
||||||
state.attributedString, selectionRange: NSRange(location: 0, length: 0),
|
state.data.attributedStringPlaceholder, selectionRange: NSRange(location: 0, length: 0),
|
||||||
replacementRange: NSRange(location: NSNotFound, length: NSNotFound)
|
replacementRange: NSRange(location: NSNotFound, length: NSNotFound)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
@ -107,7 +107,7 @@ extension ctlInputMethod {
|
||||||
/// 是 0 且取代範圍(replacementRange)為「NSNotFound」罷了。
|
/// 是 0 且取代範圍(replacementRange)為「NSNotFound」罷了。
|
||||||
/// 也就是說,內文組字區該在哪裡出現,得由客體軟體來作主。
|
/// 也就是說,內文組字區該在哪裡出現,得由客體軟體來作主。
|
||||||
client.setMarkedText(
|
client.setMarkedText(
|
||||||
state.attributedString, selectionRange: NSRange(state.data.u16MarkedRange),
|
attributedStringSecured.0, selectionRange: attributedStringSecured.1,
|
||||||
replacementRange: NSRange(location: NSNotFound, length: NSNotFound)
|
replacementRange: NSRange(location: NSNotFound, length: NSNotFound)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue