From 48d434f087104c885f3d1d16c791e7ac03336085 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sun, 15 May 2022 15:21:41 +0800 Subject: [PATCH] KeyHandler // Add DachenCP26 and Hanyu-Pinyin support, etc. - Also use getComposition() in lieu of realComposition(). --- Source/Modules/ControllerModules/KeyHandler_Core.swift | 4 ++++ Source/Modules/ControllerModules/KeyHandler_HandleInput.swift | 2 +- Source/Modules/ControllerModules/KeyHandler_States.swift | 2 +- Source/Modules/IMEModules/mgrPrefs.swift | 3 +++ Source/Resources/Base.lproj/Localizable.strings | 1 + Source/Resources/en.lproj/Localizable.strings | 1 + Source/Resources/ja.lproj/Localizable.strings | 1 + Source/Resources/zh-Hans.lproj/Localizable.strings | 1 + Source/Resources/zh-Hant.lproj/Localizable.strings | 1 + Source/UI/PrefUI/suiPrefPaneKeyboard.swift | 1 + Source/WindowNIBs/Base.lproj/frmPrefWindow.xib | 1 + Source/WindowNIBs/en.lproj/frmPrefWindow.strings | 3 +++ Source/WindowNIBs/ja.lproj/frmPrefWindow.strings | 3 +++ Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings | 3 +++ Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings | 3 +++ 15 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler_Core.swift b/Source/Modules/ControllerModules/KeyHandler_Core.swift index 2a15095b..b408cba4 100644 --- a/Source/Modules/ControllerModules/KeyHandler_Core.swift +++ b/Source/Modules/ControllerModules/KeyHandler_Core.swift @@ -328,6 +328,8 @@ class KeyHandler: NSObject { switch mgrPrefs.mandarinParser { case MandarinParser.ofStandard.rawValue: _composer.ensureParser(arrange: .ofDachen) + case MandarinParser.ofDachen26.rawValue: + _composer.ensureParser(arrange: .ofDachen26) case MandarinParser.ofEten.rawValue: _composer.ensureParser(arrange: .ofEten) case MandarinParser.ofHsu.rawValue: @@ -340,6 +342,8 @@ class KeyHandler: NSObject { _composer.ensureParser(arrange: .ofMiTAC) case MandarinParser.ofFakeSeigyou.rawValue: _composer.ensureParser(arrange: .ofFakeSeigyou) + case MandarinParser.ofHanyuPinyin.rawValue: + _composer.ensureParser(arrange: .ofHanyuPinyin) default: _composer.ensureParser(arrange: .ofDachen) mgrPrefs.mandarinParser = MandarinParser.ofStandard.rawValue diff --git a/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift b/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift index d75239db..ebcfdc6d 100644 --- a/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift +++ b/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift @@ -166,7 +166,7 @@ extension KeyHandler { // However, Swift does not support "|=". composeReading = composeReading || (!_composer.isEmpty && (input.isSpace || input.isEnter)) if composeReading { - let reading = _composer.realComposition + let reading = _composer.getComposition() // See whether we have a unigram for this... if !ifLangModelHasUnigrams(forKey: reading) { diff --git a/Source/Modules/ControllerModules/KeyHandler_States.swift b/Source/Modules/ControllerModules/KeyHandler_States.swift index 1261b9d3..6a361d80 100644 --- a/Source/Modules/ControllerModules/KeyHandler_States.swift +++ b/Source/Modules/ControllerModules/KeyHandler_States.swift @@ -89,7 +89,7 @@ extension KeyHandler { } let head = rawHead - let reading = _composer.getComposition(isHanyuPinyin: mgrPrefs.showHanyuPinyinInCompositionBuffer) + let reading = _composer.getInlineCompositionForIMK(isHanyuPinyin: mgrPrefs.showHanyuPinyinInCompositionBuffer) let tail = rawEnd let composedText = head + reading + tail let cursorIndex = composedStringCursorIndex + reading.count diff --git a/Source/Modules/IMEModules/mgrPrefs.swift b/Source/Modules/IMEModules/mgrPrefs.swift index 8a99c805..72a927a0 100644 --- a/Source/Modules/IMEModules/mgrPrefs.swift +++ b/Source/Modules/IMEModules/mgrPrefs.swift @@ -174,6 +174,7 @@ struct ComposingBufferSize { case ofIBM = 4 case ofMiTAC = 5 case ofFakeSeigyou = 6 + case ofDachen26 = 7 case ofHanyuPinyin = 10 var name: String { @@ -192,6 +193,8 @@ struct ComposingBufferSize { return "MiTAC" case .ofFakeSeigyou: return "FakeSeigyou" + case .ofDachen26: + return "Dachen26" case .ofHanyuPinyin: return "HanyuPinyin" } diff --git a/Source/Resources/Base.lproj/Localizable.strings b/Source/Resources/Base.lproj/Localizable.strings index 743c812f..6e057c4d 100644 --- a/Source/Resources/Base.lproj/Localizable.strings +++ b/Source/Resources/Base.lproj/Localizable.strings @@ -104,6 +104,7 @@ "Choose your preferred layout of the candidate window." = "Choose your preferred layout of the candidate window."; "Cursor Selection:" = "Cursor Selection:"; "Dachen (Microsoft Standard / Wang / 01, etc.)" = "Dachen (Microsoft Standard / Wang / 01, etc.)"; +"Dachen 26 (libChewing)" = "Dachen 26 (libChewing)"; "Debug Mode" = "Debug Mode"; "Dictionary" = "Dictionary"; "Emulating select-candidate-per-character mode" = "Emulating select-candidate-per-character mode"; diff --git a/Source/Resources/en.lproj/Localizable.strings b/Source/Resources/en.lproj/Localizable.strings index 743c812f..6e057c4d 100644 --- a/Source/Resources/en.lproj/Localizable.strings +++ b/Source/Resources/en.lproj/Localizable.strings @@ -104,6 +104,7 @@ "Choose your preferred layout of the candidate window." = "Choose your preferred layout of the candidate window."; "Cursor Selection:" = "Cursor Selection:"; "Dachen (Microsoft Standard / Wang / 01, etc.)" = "Dachen (Microsoft Standard / Wang / 01, etc.)"; +"Dachen 26 (libChewing)" = "Dachen 26 (libChewing)"; "Debug Mode" = "Debug Mode"; "Dictionary" = "Dictionary"; "Emulating select-candidate-per-character mode" = "Emulating select-candidate-per-character mode"; diff --git a/Source/Resources/ja.lproj/Localizable.strings b/Source/Resources/ja.lproj/Localizable.strings index 65baca8c..30838c5e 100644 --- a/Source/Resources/ja.lproj/Localizable.strings +++ b/Source/Resources/ja.lproj/Localizable.strings @@ -104,6 +104,7 @@ "Choose your preferred layout of the candidate window." = "入力候補陳列の仕様をご指定ください。"; "Cursor Selection:" = "カーソル候補呼出:"; "Dachen (Microsoft Standard / Wang / 01, etc.)" = "大千配列 (Microsoft 標準・王安・零壹など)"; +"Dachen 26 (libChewing)" = "酷音大千二十六キー"; "Debug Mode" = "欠陥辿着モード"; "Dictionary" = "辞書設定"; "Emulating select-candidate-per-character mode" = "漢字1つづつ全候補選択入力モード"; diff --git a/Source/Resources/zh-Hans.lproj/Localizable.strings b/Source/Resources/zh-Hans.lproj/Localizable.strings index 8e53b332..4892b95f 100644 --- a/Source/Resources/zh-Hans.lproj/Localizable.strings +++ b/Source/Resources/zh-Hans.lproj/Localizable.strings @@ -104,6 +104,7 @@ "Choose your preferred layout of the candidate window." = "选择您所偏好的候选字窗布局。"; "Cursor Selection:" = "选字游标:"; "Dachen (Microsoft Standard / Wang / 01, etc.)" = "大千排列 (微软标准/王安/零壹/仲鼎/国乔)"; +"Dachen 26 (libChewing)" = "酷音大千二十六键"; "Debug Mode" = "侦错模式"; "Dictionary" = "辞典"; "Emulating select-candidate-per-character mode" = "模拟 90 年代前期注音逐字选字输入风格"; diff --git a/Source/Resources/zh-Hant.lproj/Localizable.strings b/Source/Resources/zh-Hant.lproj/Localizable.strings index bd7d11a4..f6c8a79e 100644 --- a/Source/Resources/zh-Hant.lproj/Localizable.strings +++ b/Source/Resources/zh-Hant.lproj/Localizable.strings @@ -104,6 +104,7 @@ "Choose your preferred layout of the candidate window." = "選擇您所偏好的候選字窗佈局。"; "Cursor Selection:" = "選字游標:"; "Dachen (Microsoft Standard / Wang / 01, etc.)" = "大千排列 (微軟標準/王安/零壹/仲鼎/國喬)"; +"Dachen 26 (libChewing)" = "酷音大千二十六鍵"; "Debug Mode" = "偵錯模式"; "Dictionary" = "辭典"; "Emulating select-candidate-per-character mode" = "模擬 90 年代前期注音逐字選字輸入風格"; diff --git a/Source/UI/PrefUI/suiPrefPaneKeyboard.swift b/Source/UI/PrefUI/suiPrefPaneKeyboard.swift index 35809ec6..a5226eb4 100644 --- a/Source/UI/PrefUI/suiPrefPaneKeyboard.swift +++ b/Source/UI/PrefUI/suiPrefPaneKeyboard.swift @@ -47,6 +47,7 @@ struct suiPrefPaneKeyboard: View { Preferences.Section(label: { Text(LocalizedStringKey("Phonetic Parser:")) }) { Picker("", selection: $selMandarinParser) { Text(LocalizedStringKey("Dachen (Microsoft Standard / Wang / 01, etc.)")).tag(0) + Text(LocalizedStringKey("Dachen 26 (libChewing)")).tag(7) Text(LocalizedStringKey("Eten Traditional")).tag(1) Text(LocalizedStringKey("Eten 26")).tag(3) Text(LocalizedStringKey("IBM")).tag(4) diff --git a/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib b/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib index dd35eeab..0d4d9ee2 100644 --- a/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib +++ b/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib @@ -782,6 +782,7 @@ + diff --git a/Source/WindowNIBs/en.lproj/frmPrefWindow.strings b/Source/WindowNIBs/en.lproj/frmPrefWindow.strings index 1175822a..35d08a8c 100644 --- a/Source/WindowNIBs/en.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/en.lproj/frmPrefWindow.strings @@ -232,3 +232,6 @@ /* Class = "NSButtonCell"; title = "Output Hanyu-Pinyin in lieu of Zhuyin when Ctrl(+Alt)+CMD+Enter"; ObjectID = "iWy-Nw-QKB"; */ "iWy-Nw-QKB.title" = "Output Hanyu-Pinyin in lieu of Zhuyin when Ctrl(+Alt)+CMD+Enter"; + +/* Class = "NSMenuItem"; title = "Dachen 26 (libChewing)"; ObjectID = "xjP-r7-GaK"; */ +"xjP-r7-GaK.title" = "Dachen 26 (libChewing)"; diff --git a/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings b/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings index 2a891d5d..32664b25 100644 --- a/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings @@ -232,3 +232,6 @@ /* Class = "NSButtonCell"; title = "Output Hanyu-Pinyin in lieu of Zhuyin when Ctrl(+Alt)+CMD+Enter"; ObjectID = "iWy-Nw-QKB"; */ "iWy-Nw-QKB.title" = "Ctrl(+Alt)+CMD+Enter で出すのを漢語弁音と変換"; + +/* Class = "NSMenuItem"; title = "Dachen 26 (libChewing)"; ObjectID = "xjP-r7-GaK"; */ +"xjP-r7-GaK.title" = "酷音大千二十六キー"; diff --git a/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings b/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings index d660e0f4..f8a93fff 100644 --- a/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings @@ -232,3 +232,6 @@ /* Class = "NSButtonCell"; title = "Output Hanyu-Pinyin in lieu of Zhuyin when Ctrl(+Alt)+CMD+Enter"; ObjectID = "iWy-Nw-QKB"; */ "iWy-Nw-QKB.title" = "Ctrl(+Alt)+CMD+Enter 输出汉语拼音而非注音"; + +/* Class = "NSMenuItem"; title = "Dachen 26 (libChewing)"; ObjectID = "xjP-r7-GaK"; */ +"xjP-r7-GaK.title" = "酷音大千二十六键"; diff --git a/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings b/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings index efc928c4..2627a7c5 100644 --- a/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings @@ -232,3 +232,6 @@ /* Class = "NSButtonCell"; title = "Output Hanyu-Pinyin in lieu of Zhuyin when Ctrl(+Alt)+CMD+Enter"; ObjectID = "iWy-Nw-QKB"; */ "iWy-Nw-QKB.title" = "Ctrl(+Alt)+CMD+Enter 輸出漢語拼音而非注音"; + +/* Class = "NSMenuItem"; title = "Dachen 26 (libChewing)"; ObjectID = "xjP-r7-GaK"; */ +"xjP-r7-GaK.title" = "酷音大千二十六鍵";