KeyHandler // Add DachenCP26 and Hanyu-Pinyin support, etc.

- Also use getComposition() in lieu of realComposition().
This commit is contained in:
ShikiSuen 2022-05-15 15:21:41 +08:00
parent 6e6cce7f4f
commit 48d434f087
15 changed files with 28 additions and 2 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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

View File

@ -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"
}

View File

@ -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";

View File

@ -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";

View File

@ -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つづつ全候補選択入力モード";

View File

@ -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 年代前期注音逐字选字输入风格";

View File

@ -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 年代前期注音逐字選字輸入風格";

View File

@ -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)

View File

@ -782,6 +782,7 @@
<menu key="menu" title="OtherViews" id="5">
<items>
<menuItem title="Standard" state="on" id="6"/>
<menuItem title="Dachen 26" tag="7" id="xjP-r7-GaK"/>
<menuItem title="ETen" tag="1" id="7"/>
<menuItem title="ETen26" tag="3" id="9"/>
<menuItem title="IBM" tag="4" id="137"/>

View File

@ -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)";

View File

@ -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" = "酷音大千二十六キー";

View File

@ -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" = "酷音大千二十六键";

View File

@ -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" = "酷音大千二十六鍵";