InputHandler // Move some case-switch results to InputMode enum.
This commit is contained in:
parent
275288ea61
commit
c5899152e6
|
@ -422,16 +422,9 @@ private extension InputHandler {
|
||||||
delegate.switchState(updatedState)
|
delegate.switchState(updatedState)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
let encoding: CFStringEncodings? = {
|
|
||||||
switch IMEApp.currentInputMode {
|
|
||||||
case .imeModeCHS: return .GB_18030_2000
|
|
||||||
case .imeModeCHT: return .big5_HKSCS_1999
|
|
||||||
default: return nil
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
guard
|
guard
|
||||||
var char = "\(strCodePointBuffer)\(input.text)"
|
var char = "\(strCodePointBuffer)\(input.text)"
|
||||||
.parsedAsHexLiteral(encoding: encoding)?.first?.description
|
.parsedAsHexLiteral(encoding: IMEApp.currentInputMode.nonUTFEncoding)?.first?.description
|
||||||
else {
|
else {
|
||||||
delegate.callError("D220B880:輸入的字碼沒有對應的字元。")
|
delegate.callError("D220B880:輸入的字碼沒有對應的字元。")
|
||||||
var updatedState = IMEState.ofAbortion()
|
var updatedState = IMEState.ofAbortion()
|
||||||
|
|
|
@ -30,12 +30,8 @@ public extension InputHandler {
|
||||||
case .codePoint:
|
case .codePoint:
|
||||||
let commonTerm = NSMutableString()
|
let commonTerm = NSMutableString()
|
||||||
commonTerm.insert("Code Point Input.".localized, at: 0)
|
commonTerm.insert("Code Point Input.".localized, at: 0)
|
||||||
if !vertical {
|
if !vertical, let initials = IMEApp.currentInputMode.nonUTFEncodingInitials {
|
||||||
switch IMEApp.currentInputMode {
|
commonTerm.insert("[\(initials)] ", at: 0)
|
||||||
case .imeModeCHS: commonTerm.insert("[GB] ", at: 0)
|
|
||||||
case .imeModeCHT: commonTerm.insert("[Big5] ", at: 0)
|
|
||||||
default: break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return commonTerm.description
|
return commonTerm.description
|
||||||
case .haninKeyboardSymbol:
|
case .haninKeyboardSymbol:
|
||||||
|
|
|
@ -252,6 +252,22 @@ public enum Shared {
|
||||||
return "Please select…"
|
return "Please select…"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var nonUTFEncoding: CFStringEncodings? {
|
||||||
|
switch self {
|
||||||
|
case .imeModeCHS: return .GB_18030_2000
|
||||||
|
case .imeModeCHT: return .big5_HKSCS_1999
|
||||||
|
default: return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public var nonUTFEncodingInitials: String? {
|
||||||
|
switch self {
|
||||||
|
case .imeModeCHS: return "GB"
|
||||||
|
case .imeModeCHT: return "Big5"
|
||||||
|
default: return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue