IME // Tweaking isPrintable().
This commit is contained in:
parent
42cc923425
commit
632739e39f
|
@ -116,7 +116,7 @@ extension KeyHandler {
|
||||||
var cleanedComposition = ""
|
var cleanedComposition = ""
|
||||||
for theChar in composedText {
|
for theChar in composedText {
|
||||||
if let charCode = theChar.utf16.first {
|
if let charCode = theChar.utf16.first {
|
||||||
if !(theChar.isASCII && !(charCode.isPrintable())) {
|
if !(theChar.isASCII && !(charCode.isPrintable)) {
|
||||||
cleanedComposition += String(theChar)
|
cleanedComposition += String(theChar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,7 @@ class ctlInputMethod: IMKInputController {
|
||||||
|
|
||||||
// 無法列印的訊號輸入,一概不作處理。
|
// 無法列印的訊號輸入,一概不作處理。
|
||||||
// 這個過程不能放在 KeyHandler 內,否則不會起作用。
|
// 這個過程不能放在 KeyHandler 內,否則不會起作用。
|
||||||
if !input.charCode.isPrintable() {
|
if !input.charCode.isPrintable {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -413,7 +413,7 @@ extension String {
|
||||||
|
|
||||||
// Ref: https://forums.swift.org/t/57085/5
|
// Ref: https://forums.swift.org/t/57085/5
|
||||||
extension UniChar {
|
extension UniChar {
|
||||||
public func isPrintable() -> Bool {
|
public var isPrintable: Bool {
|
||||||
guard Unicode.Scalar(UInt32(self)) != nil else {
|
guard Unicode.Scalar(UInt32(self)) != nil else {
|
||||||
struct NotAWholeScalar: Error {}
|
struct NotAWholeScalar: Error {}
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue