Tekkon // Upgrade to v1.1.6 release, etc.

This commit is contained in:
ShikiSuen 2022-06-14 18:33:42 +08:00
parent 98b8e9209b
commit 4f205f35f0
3 changed files with 41 additions and 40 deletions

View File

@ -276,12 +276,12 @@ class KeyHandler {
_composer.ensureParser(arrange: .ofDachen) _composer.ensureParser(arrange: .ofDachen)
case MandarinParser.ofDachen26.rawValue: case MandarinParser.ofDachen26.rawValue:
_composer.ensureParser(arrange: .ofDachen26) _composer.ensureParser(arrange: .ofDachen26)
case MandarinParser.ofEten.rawValue: case MandarinParser.ofETen.rawValue:
_composer.ensureParser(arrange: .ofEten) _composer.ensureParser(arrange: .ofETen)
case MandarinParser.ofHsu.rawValue: case MandarinParser.ofHsu.rawValue:
_composer.ensureParser(arrange: .ofHsu) _composer.ensureParser(arrange: .ofHsu)
case MandarinParser.ofEten26.rawValue: case MandarinParser.ofETen26.rawValue:
_composer.ensureParser(arrange: .ofEten26) _composer.ensureParser(arrange: .ofETen26)
case MandarinParser.ofIBM.rawValue: case MandarinParser.ofIBM.rawValue:
_composer.ensureParser(arrange: .ofIBM) _composer.ensureParser(arrange: .ofIBM)
case MandarinParser.ofMiTAC.rawValue: case MandarinParser.ofMiTAC.rawValue:

View File

@ -41,8 +41,8 @@ public struct Tekkon {
public enum MandarinParser: Int { public enum MandarinParser: Int {
case ofDachen = 0 case ofDachen = 0
case ofDachen26 = 1 case ofDachen26 = 1
case ofEten = 2 case ofETen = 2
case ofEten26 = 3 case ofETen26 = 3
case ofHsu = 4 case ofHsu = 4
case ofIBM = 5 case ofIBM = 5
case ofMiTAC = 6 case ofMiTAC = 6
@ -60,11 +60,11 @@ public struct Tekkon {
return "Dachen" return "Dachen"
case .ofDachen26: case .ofDachen26:
return "Dachen26" return "Dachen26"
case .ofEten: case .ofETen:
return "ETen" return "ETen"
case .ofHsu: case .ofHsu:
return "Hsu" return "Hsu"
case .ofEten26: case .ofETen26:
return "ETen26" return "ETen26"
case .ofIBM: case .ofIBM:
return "IBM" return "IBM"
@ -140,6 +140,7 @@ public struct Tekkon {
/// ///
public mutating func clear() { public mutating func clear() {
valueStorage = "" valueStorage = ""
type = .null
} }
/// ///
@ -214,7 +215,7 @@ public struct Tekkon {
/// 調 /// 調
public var intonation: Phonabet = "" public var intonation: Phonabet = ""
/// ///
public var romajiBuffer: String = "" public var romajiBuffer: String = ""
/// Windows / macOS /// Windows / macOS
@ -279,7 +280,7 @@ public struct Tekkon {
} }
} }
/// ///
public var isPronouncable: Bool { public var isPronouncable: Bool {
!vowel.isEmpty || !semivowel.isEmpty || !consonant.isEmpty !vowel.isEmpty || !semivowel.isEmpty || !consonant.isEmpty
} }
@ -321,12 +322,12 @@ public struct Tekkon {
return Tekkon.mapQwertyDachen[input] != nil return Tekkon.mapQwertyDachen[input] != nil
case .ofDachen26: case .ofDachen26:
return Tekkon.mapDachenCP26StaticKeys[input] != nil return Tekkon.mapDachenCP26StaticKeys[input] != nil
case .ofEten: case .ofETen:
return Tekkon.mapQwertyEtenTraditional[input] != nil return Tekkon.mapQwertyETenTraditional[input] != nil
case .ofHsu: case .ofHsu:
return Tekkon.mapHsuStaticKeys[input] != nil return Tekkon.mapHsuStaticKeys[input] != nil
case .ofEten26: case .ofETen26:
return Tekkon.mapEten26StaticKeys[input] != nil return Tekkon.mapETen26StaticKeys[input] != nil
case .ofIBM: case .ofIBM:
return Tekkon.mapQwertyIBM[input] != nil return Tekkon.mapQwertyIBM[input] != nil
case .ofMiTAC: case .ofMiTAC:
@ -356,7 +357,7 @@ public struct Tekkon {
intonation = Phonabet(theTone) intonation = Phonabet(theTone)
} }
} else { } else {
// romajiBuffer // romajiBuffer
if romajiBuffer.count > 5 { if romajiBuffer.count > 5 {
romajiBuffer = String(romajiBuffer.dropFirst()) romajiBuffer = String(romajiBuffer.dropFirst())
} }
@ -364,7 +365,7 @@ public struct Tekkon {
receiveSequence(romajiBufferBackup, isRomaji: true) receiveSequence(romajiBufferBackup, isRomaji: true)
romajiBuffer = romajiBufferBackup romajiBuffer = romajiBufferBackup
} }
default: receiveKey(fromPhonabet: translate(key: String(input))) default: receiveKey(fromPhonabet: translate(key: input))
} }
} }
@ -506,12 +507,12 @@ public struct Tekkon {
return Tekkon.mapQwertyDachen[key] ?? "" return Tekkon.mapQwertyDachen[key] ?? ""
case .ofDachen26: case .ofDachen26:
return handleDachen26(key: key) return handleDachen26(key: key)
case .ofEten: case .ofETen:
return Tekkon.mapQwertyEtenTraditional[key] ?? "" return Tekkon.mapQwertyETenTraditional[key] ?? ""
case .ofHsu: case .ofHsu:
return handleHsu(key: key) return handleHsu(key: key)
case .ofEten26: case .ofETen26:
return handleEten26(key: key) return handleETen26(key: key)
case .ofIBM: case .ofIBM:
return Tekkon.mapQwertyIBM[key] ?? "" return Tekkon.mapQwertyIBM[key] ?? ""
case .ofMiTAC: case .ofMiTAC:
@ -531,9 +532,8 @@ public struct Tekkon {
/// ///
/// - Parameters: /// - Parameters:
/// - key: String /// - key: String
mutating func handleEten26(key: String = "") -> String { mutating func handleETen26(key: String = "") -> String {
var strReturn = "" var strReturn = Tekkon.mapETen26StaticKeys[key] ?? ""
strReturn = Tekkon.mapEten26StaticKeys[key] ?? ""
let incomingPhonabet = Phonabet(strReturn) let incomingPhonabet = Phonabet(strReturn)
switch key { switch key {
@ -616,12 +616,11 @@ public struct Tekkon {
/// - Parameters: /// - Parameters:
/// - key: String /// - key: String
mutating func handleHsu(key: String = "") -> String { mutating func handleHsu(key: String = "") -> String {
var strReturn = "" var strReturn = Tekkon.mapHsuStaticKeys[key] ?? ""
strReturn = Tekkon.mapHsuStaticKeys[key] ?? ""
let incomingPhonabet = Phonabet(strReturn) let incomingPhonabet = Phonabet(strReturn)
if key == " ", value == "" { if key == " ", value == "" {
consonant = "" consonant.clear()
vowel = "" vowel = ""
} }
@ -719,7 +718,7 @@ public struct Tekkon {
consonant.selfReplace("", "") consonant.selfReplace("", "")
} }
if consonant == "", semivowel.isEmpty, vowel.isEmpty { if consonant == "", semivowel.isEmpty, vowel.isEmpty {
consonant = "" consonant.clear()
vowel = "" vowel = ""
} }
} }
@ -740,8 +739,7 @@ public struct Tekkon {
/// - Parameters: /// - Parameters:
/// - key: String /// - key: String
mutating func handleDachen26(key: String = "") -> String { mutating func handleDachen26(key: String = "") -> String {
var strReturn = "" var strReturn = Tekkon.mapDachenCP26StaticKeys[key] ?? ""
strReturn = Tekkon.mapDachenCP26StaticKeys[key] ?? ""
switch key { switch key {
case "e": if isPronouncable { intonation = "ˊ" } else { consonant = "" } case "e": if isPronouncable { intonation = "ˊ" } else { consonant = "" }
@ -759,11 +757,11 @@ public struct Tekkon {
case "w": if consonant.isEmpty || consonant == "" { consonant = "" } else { consonant = "" } case "w": if consonant.isEmpty || consonant == "" { consonant = "" } else { consonant = "" }
case "m": case "m":
if semivowel == "", vowel != "" { if semivowel == "", vowel != "" {
semivowel = "" semivowel.clear()
vowel = "" vowel = ""
} else if semivowel != "", vowel == "" { } else if semivowel != "", vowel == "" {
semivowel = "" semivowel = ""
vowel = "" vowel.clear()
} else if !semivowel.isEmpty { } else if !semivowel.isEmpty {
vowel = "" vowel = ""
} else { } else {
@ -771,13 +769,13 @@ public struct Tekkon {
} }
case "u": case "u":
if semivowel == "", vowel != "" { if semivowel == "", vowel != "" {
semivowel = "" semivowel.clear()
vowel = "" vowel = ""
} else if semivowel != "", vowel == "" { } else if semivowel != "", vowel == "" {
semivowel = "" semivowel = ""
} else if semivowel == "", vowel == "" { } else if semivowel == "", vowel == "" {
semivowel = "" semivowel.clear()
vowel = "" vowel.clear()
} else if !semivowel.isEmpty { } else if !semivowel.isEmpty {
vowel = "" vowel = ""
} else { } else {
@ -834,6 +832,9 @@ public struct Tekkon {
return targetConverted return targetConverted
} }
/// 調 1
/// - Parameters:
/// - target: String
static func cnvHanyuPinyinToTextbookStyle(target: String) -> String { static func cnvHanyuPinyinToTextbookStyle(target: String) -> String {
var targetConverted = target var targetConverted = target
for pair in arrHanyuPinyinTextbookStyleConversionTable { for pair in arrHanyuPinyinTextbookStyleConversionTable {
@ -1296,14 +1297,14 @@ public struct Tekkon {
/// ///
/// 便 validity check /// 便 validity check
/// //// /// ////
static let mapEten26StaticKeys: [String: String] = [ static let mapETen26StaticKeys: [String: String] = [
"a": "", "b": "", "c": "", "d": "", "e": "", "f": "", "g": "", "h": "", "i": "", "j": "", "k": "", "a": "", "b": "", "c": "", "d": "", "e": "", "f": "", "g": "", "h": "", "i": "", "j": "", "k": "",
"l": "", "m": "", "n": "", "o": "", "p": "", "q": "", "r": "", "s": "", "t": "", "u": "", "v": "", "l": "", "m": "", "n": "", "o": "", "p": "", "q": "", "r": "", "s": "", "t": "", "u": "", "v": "",
"w": "", "x": "", "y": "", "z": "", " ": " ", "w": "", "x": "", "y": "", "z": "", " ": " ",
] ]
/// ///
static let mapQwertyEtenTraditional: [String: String] = [ static let mapQwertyETenTraditional: [String: String] = [
"'": "", ",": "", "-": "", ".": "", "/": "", "0": "", "1": "˙", "2": "ˊ", "3": "ˇ", "4": "ˋ", "7": "", "'": "", ",": "", "-": "", ".": "", "/": "", "0": "", "1": "˙", "2": "ˊ", "3": "ˇ", "4": "ˋ", "7": "",
"8": "", "9": "", ";": "", "=": "", "a": "", "b": "", "c": "", "d": "", "e": "", "f": "", "g": "", "8": "", "9": "", ";": "", "=": "", "a": "", "b": "", "c": "", "d": "", "e": "", "f": "", "g": "",
"h": "", "i": "", "j": "", "k": "", "l": "", "m": "", "n": "", "o": "", "p": "", "q": "", "r": "", "h": "", "i": "", "j": "", "k": "", "l": "", "m": "", "n": "", "o": "", "p": "", "q": "", "r": "",

View File

@ -176,9 +176,9 @@ struct ComposingBufferSize {
enum MandarinParser: Int { enum MandarinParser: Int {
case ofStandard = 0 case ofStandard = 0
case ofEten = 1 case ofETen = 1
case ofHsu = 2 case ofHsu = 2
case ofEten26 = 3 case ofETen26 = 3
case ofIBM = 4 case ofIBM = 4
case ofMiTAC = 5 case ofMiTAC = 5
case ofFakeSeigyou = 6 case ofFakeSeigyou = 6
@ -193,11 +193,11 @@ enum MandarinParser: Int {
switch self { switch self {
case .ofStandard: case .ofStandard:
return "Standard" return "Standard"
case .ofEten: case .ofETen:
return "ETen" return "ETen"
case .ofHsu: case .ofHsu:
return "Hsu" return "Hsu"
case .ofEten26: case .ofETen26:
return "ETen26" return "ETen26"
case .ofIBM: case .ofIBM:
return "IBM" return "IBM"