ctlIME // Block unprintable ASCII chars from being committed out.

This commit is contained in:
ShikiSuen 2022-05-21 00:22:50 +08:00
parent 45c877b3f9
commit b41068c0cb
1 changed files with 13 additions and 1 deletions

View File

@ -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)
)
}