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)
case MandarinParser.ofDachen26.rawValue:
_composer.ensureParser(arrange: .ofDachen26)
case MandarinParser.ofEten.rawValue:
_composer.ensureParser(arrange: .ofEten)
case MandarinParser.ofETen.rawValue:
_composer.ensureParser(arrange: .ofETen)
case MandarinParser.ofHsu.rawValue:
_composer.ensureParser(arrange: .ofHsu)
case MandarinParser.ofEten26.rawValue:
_composer.ensureParser(arrange: .ofEten26)
case MandarinParser.ofETen26.rawValue:
_composer.ensureParser(arrange: .ofETen26)
case MandarinParser.ofIBM.rawValue:
_composer.ensureParser(arrange: .ofIBM)
case MandarinParser.ofMiTAC.rawValue:

View File

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

View File

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