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)
|
||||
return true
|
||||
}
|
||||
let encoding: CFStringEncodings? = {
|
||||
switch IMEApp.currentInputMode {
|
||||
case .imeModeCHS: return .GB_18030_2000
|
||||
case .imeModeCHT: return .big5_HKSCS_1999
|
||||
default: return nil
|
||||
}
|
||||
}()
|
||||
guard
|
||||
var char = "\(strCodePointBuffer)\(input.text)"
|
||||
.parsedAsHexLiteral(encoding: encoding)?.first?.description
|
||||
.parsedAsHexLiteral(encoding: IMEApp.currentInputMode.nonUTFEncoding)?.first?.description
|
||||
else {
|
||||
delegate.callError("D220B880:輸入的字碼沒有對應的字元。")
|
||||
var updatedState = IMEState.ofAbortion()
|
||||
|
|
|
@ -30,12 +30,8 @@ public extension InputHandler {
|
|||
case .codePoint:
|
||||
let commonTerm = NSMutableString()
|
||||
commonTerm.insert("Code Point Input.".localized, at: 0)
|
||||
if !vertical {
|
||||
switch IMEApp.currentInputMode {
|
||||
case .imeModeCHS: commonTerm.insert("[GB] ", at: 0)
|
||||
case .imeModeCHT: commonTerm.insert("[Big5] ", at: 0)
|
||||
default: break
|
||||
}
|
||||
if !vertical, let initials = IMEApp.currentInputMode.nonUTFEncodingInitials {
|
||||
commonTerm.insert("[\(initials)] ", at: 0)
|
||||
}
|
||||
return commonTerm.description
|
||||
case .haninKeyboardSymbol:
|
||||
|
|
|
@ -252,6 +252,22 @@ public enum Shared {
|
|||
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