From 37e408a1b5498863905e3582ba0788461e5a827f Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sun, 31 Jul 2022 00:47:02 +0800 Subject: [PATCH] InputState // Allow adding user phrases even if reading count mismatch. --- Source/Modules/ControllerModules/InputState.swift | 15 +++++---------- Source/Resources/Base.lproj/Localizable.strings | 2 +- Source/Resources/en.lproj/Localizable.strings | 2 +- Source/Resources/ja.lproj/Localizable.strings | 2 +- .../Resources/zh-Hans.lproj/Localizable.strings | 2 +- .../Resources/zh-Hant.lproj/Localizable.strings | 2 +- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Source/Modules/ControllerModules/InputState.swift b/Source/Modules/ControllerModules/InputState.swift index baf085b8..4059a042 100644 --- a/Source/Modules/ControllerModules/InputState.swift +++ b/Source/Modules/ControllerModules/InputState.swift @@ -264,9 +264,9 @@ enum InputState { private var deleteTargetExists = false var tooltip: String { if composingBuffer.count != readings.count { - ctlInputMethod.tooltipController.setColor(state: .redAlert) + ctlInputMethod.tooltipController.setColor(state: .denialOverflow) return NSLocalizedString( - "⚠︎ Unhandlable: Chars and Readings in buffer doesn't match.", comment: "" + "⚠︎ Beware: Chars and Readings in buffer doesn't match.", comment: "" ) } if mgrPrefs.phraseReplacementEnabled { @@ -376,14 +376,9 @@ enum InputState { } var validToWrite: Bool { - /// The input method allows users to input a string whose length differs - /// from the amount of Bopomofo readings. In this case, the range - /// in the composing buffer and the readings could not match, so - /// we disable the function to write user phrases in this case. - /// 這裡的 deleteTargetExists 是防止使用者排除「詞庫內尚未存在的詞」, - /// 免得使用者誤操作之後靠北「我怎麼敲不了這個詞?」之類的。 - ((composingBuffer.count != readings.count) - || (ctlInputMethod.areWeDeleting && !deleteTargetExists)) + /// 與小麥注音不同,威注音會自動解消「游標插斷字符」的異常狀態,所以允許在字音長度不相符的情況下加詞。 + /// 這裡的 deleteTargetExists 是防止使用者排除「詞庫內尚未存在的詞」。 + (ctlInputMethod.areWeDeleting && !deleteTargetExists) ? false : allowedMarkRange.contains(literalMarkedRange.count) } diff --git a/Source/Resources/Base.lproj/Localizable.strings b/Source/Resources/Base.lproj/Localizable.strings index a1ccc9f1..9b57b255 100644 --- a/Source/Resources/Base.lproj/Localizable.strings +++ b/Source/Resources/Base.lproj/Localizable.strings @@ -37,7 +37,7 @@ "Please specify at least 4 candidate keys." = "Please specify at least 4 candidate keys."; "Maximum 15 candidate keys allowed." = "Maximum 15 candidate keys allowed."; "⚠︎ Phrase replacement mode enabled, interfering user phrase entry." = "⚠︎ Phrase replacement mode enabled, interfering user phrase entry."; -"⚠︎ Unhandlable: Chars and Readings in buffer doesn't match." = "⚠︎ Unhandlable: Chars and Readings in buffer doesn't match."; +"⚠︎ Beware: Chars and Readings in buffer doesn't match." = "⚠︎ Beware: Chars and Readings in buffer doesn't match."; "Per-Char Select Mode" = "Per-Char Select Mode"; "CNS11643 Mode" = "CNS11643 Mode"; "JIS Shinjitai Output" = "JIS Shinjitai Output"; diff --git a/Source/Resources/en.lproj/Localizable.strings b/Source/Resources/en.lproj/Localizable.strings index a1ccc9f1..9b57b255 100644 --- a/Source/Resources/en.lproj/Localizable.strings +++ b/Source/Resources/en.lproj/Localizable.strings @@ -37,7 +37,7 @@ "Please specify at least 4 candidate keys." = "Please specify at least 4 candidate keys."; "Maximum 15 candidate keys allowed." = "Maximum 15 candidate keys allowed."; "⚠︎ Phrase replacement mode enabled, interfering user phrase entry." = "⚠︎ Phrase replacement mode enabled, interfering user phrase entry."; -"⚠︎ Unhandlable: Chars and Readings in buffer doesn't match." = "⚠︎ Unhandlable: Chars and Readings in buffer doesn't match."; +"⚠︎ Beware: Chars and Readings in buffer doesn't match." = "⚠︎ Beware: Chars and Readings in buffer doesn't match."; "Per-Char Select Mode" = "Per-Char Select Mode"; "CNS11643 Mode" = "CNS11643 Mode"; "JIS Shinjitai Output" = "JIS Shinjitai Output"; diff --git a/Source/Resources/ja.lproj/Localizable.strings b/Source/Resources/ja.lproj/Localizable.strings index 38e6b238..cfab4637 100644 --- a/Source/Resources/ja.lproj/Localizable.strings +++ b/Source/Resources/ja.lproj/Localizable.strings @@ -37,7 +37,7 @@ "Please specify at least 4 candidate keys." = "言選り用キー陣列に少なくとも4つのキーをご登録ください。"; "Maximum 15 candidate keys allowed." = "言選り用キー陣列には最多15つキー登録できます。"; "⚠︎ Phrase replacement mode enabled, interfering user phrase entry." = "⚠︎ 言葉置換機能稼働中、新添付言葉にも影響。"; -"⚠︎ Unhandlable: Chars and Readings in buffer doesn't match." = "⚠︎ 緩衝列の字数は読みの数と不同等のため、対処不可。"; +"⚠︎ Beware: Chars and Readings in buffer doesn't match." = "⚠︎ 注意:緩衝列の字数は読みの数と不同等。"; "Per-Char Select Mode" = "全候補入力モード"; "CNS11643 Mode" = "全字庫モード"; "JIS Shinjitai Output" = "JIS 新字体モード"; diff --git a/Source/Resources/zh-Hans.lproj/Localizable.strings b/Source/Resources/zh-Hans.lproj/Localizable.strings index 5f2d23fe..2b2136d2 100644 --- a/Source/Resources/zh-Hans.lproj/Localizable.strings +++ b/Source/Resources/zh-Hans.lproj/Localizable.strings @@ -37,7 +37,7 @@ "Please specify at least 4 candidate keys." = "请至少指定四个选字键。"; "Maximum 15 candidate keys allowed." = "选字键最多只能指定十五个。"; "⚠︎ Phrase replacement mode enabled, interfering user phrase entry." = "⚠︎ 语汇置换功能已启用,会波及语汇自订。"; -"⚠︎ Unhandlable: Chars and Readings in buffer doesn't match." = "⚠︎ 无法处理组字区字数与读音数不对应的情形。"; +"⚠︎ Beware: Chars and Readings in buffer doesn't match." = "⚠︎ 注意:组字区字数与读音数不对应。"; "Per-Char Select Mode" = "仿真逐字选字输入"; "CNS11643 Mode" = "全字库模式"; "JIS Shinjitai Output" = "JIS 新字体模式"; diff --git a/Source/Resources/zh-Hant.lproj/Localizable.strings b/Source/Resources/zh-Hant.lproj/Localizable.strings index a2f0fe9c..e6f05920 100644 --- a/Source/Resources/zh-Hant.lproj/Localizable.strings +++ b/Source/Resources/zh-Hant.lproj/Localizable.strings @@ -37,7 +37,7 @@ "Please specify at least 4 candidate keys." = "請至少指定四個選字鍵。"; "Maximum 15 candidate keys allowed." = "選字鍵最多只能指定十五個。"; "⚠︎ Phrase replacement mode enabled, interfering user phrase entry." = "⚠︎ 語彙置換功能已啟用,會波及語彙自訂。"; -"⚠︎ Unhandlable: Chars and Readings in buffer doesn't match." = "⚠︎ 無法處理組字區字數與讀音數不對應的情形。"; +"⚠︎ Beware: Chars and Readings in buffer doesn't match." = "⚠︎ 注意:組字區字數與讀音數不對應。"; "Per-Char Select Mode" = "模擬逐字選字輸入"; "CNS11643 Mode" = "全字庫模式"; "JIS Shinjitai Output" = "JIS 新字體模式";