ctlIME // Block unprintable ASCII chars from being committed out.
This commit is contained in:
parent
45c877b3f9
commit
b41068c0cb
|
@ -260,8 +260,20 @@ extension ctlInputMethod {
|
|||
if buffer.isEmpty {
|
||||
return
|
||||
}
|
||||
|
||||
var bufferOutput = ""
|
||||
|
||||
// 防止輸入法輸出不可列印的字元。
|
||||
for theChar in buffer {
|
||||
if let charCode = theChar.utf16.first {
|
||||
if !(theChar.isASCII && !(charCode.isPrintable())) {
|
||||
bufferOutput += String(theChar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(client as? IMKTextInput)?.insertText(
|
||||
buffer, replacementRange: NSRange(location: NSNotFound, length: NSNotFound)
|
||||
bufferOutput, replacementRange: NSRange(location: NSNotFound, length: NSNotFound)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue