From 82094d5d838e71d3222437406eb78b00135b5587 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 3 Oct 2022 09:57:57 +0800 Subject: [PATCH 1/7] SessionCtl_Menu // Update certain menu item namings. --- Source/Modules/SessionCtl_Menu.swift | 2 +- Source/Resources/Base.lproj/Localizable.strings | 2 +- Source/Resources/en.lproj/Localizable.strings | 2 +- Source/Resources/ja.lproj/Localizable.strings | 2 +- Source/Resources/zh-Hans.lproj/Localizable.strings | 2 +- Source/Resources/zh-Hant.lproj/Localizable.strings | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Modules/SessionCtl_Menu.swift b/Source/Modules/SessionCtl_Menu.swift index fb4279ee..c5b7b062 100644 --- a/Source/Modules/SessionCtl_Menu.swift +++ b/Source/Modules/SessionCtl_Menu.swift @@ -102,7 +102,7 @@ extension SessionCtl { action: #selector(openUserDataFolder(_:)), keyEquivalent: "" ) menu.addItem( - withTitle: NSLocalizedString("Edit User Phrases…", comment: ""), + withTitle: NSLocalizedString("Edit vChewing User Phrases…", comment: ""), action: #selector(openUserPhrases(_:)), keyEquivalent: "" ) menu.addItem( diff --git a/Source/Resources/Base.lproj/Localizable.strings b/Source/Resources/Base.lproj/Localizable.strings index 95929ca2..4847d80c 100644 --- a/Source/Resources/Base.lproj/Localizable.strings +++ b/Source/Resources/Base.lproj/Localizable.strings @@ -39,7 +39,7 @@ "NotificationSwitchON" = "✔ ON"; "NotificationSwitchOFF" = "✘ OFF"; "NotificationSwitchASCII" = "↺ Switched"; -"Edit User Phrases…" = "Edit User Phrases…"; +"Edit vChewing User Phrases…" = "Edit vChewing User Phrases…"; "Reload User Phrases" = "Reload User Phrases"; "Unable to create the user phrase file." = "Unable to create the user phrase file."; "Please check the permission at \"%@\"." = "Please check the permission at \"%@\"."; diff --git a/Source/Resources/en.lproj/Localizable.strings b/Source/Resources/en.lproj/Localizable.strings index 95929ca2..4847d80c 100644 --- a/Source/Resources/en.lproj/Localizable.strings +++ b/Source/Resources/en.lproj/Localizable.strings @@ -39,7 +39,7 @@ "NotificationSwitchON" = "✔ ON"; "NotificationSwitchOFF" = "✘ OFF"; "NotificationSwitchASCII" = "↺ Switched"; -"Edit User Phrases…" = "Edit User Phrases…"; +"Edit vChewing User Phrases…" = "Edit vChewing User Phrases…"; "Reload User Phrases" = "Reload User Phrases"; "Unable to create the user phrase file." = "Unable to create the user phrase file."; "Please check the permission at \"%@\"." = "Please check the permission at \"%@\"."; diff --git a/Source/Resources/ja.lproj/Localizable.strings b/Source/Resources/ja.lproj/Localizable.strings index 10d56374..62111f50 100644 --- a/Source/Resources/ja.lproj/Localizable.strings +++ b/Source/Resources/ja.lproj/Localizable.strings @@ -39,7 +39,7 @@ "NotificationSwitchON" = "✔ 機能起動"; "NotificationSwitchOFF" = "✘ 機能停止"; "NotificationSwitchASCII" = "↺ 切替完了"; -"Edit User Phrases…" = "ユーザー辞書を編集…"; +"Edit vChewing User Phrases…" = "威注音ユーザー辞書を編集…"; "Reload User Phrases" = "ユーザー辞書を再び読込む"; "Unable to create the user phrase file." = "ユーザー辞書ファイルの作成は失敗しました。"; "Please check the permission at \"%@\"." = "「%@」に書き出す権限は不足らしい。"; diff --git a/Source/Resources/zh-Hans.lproj/Localizable.strings b/Source/Resources/zh-Hans.lproj/Localizable.strings index 6b3fff45..7eaccfbb 100644 --- a/Source/Resources/zh-Hans.lproj/Localizable.strings +++ b/Source/Resources/zh-Hans.lproj/Localizable.strings @@ -39,7 +39,7 @@ "NotificationSwitchON" = "✔ 已启用"; "NotificationSwitchOFF" = "✘ 已停用"; "NotificationSwitchASCII" = "↺ 切换完毕"; -"Edit User Phrases…" = "编辑自订语汇…"; +"Edit vChewing User Phrases…" = "编辑威注音自订语汇…"; "Reload User Phrases" = "重载自订语汇"; "Unable to create the user phrase file." = "无法创建自订语汇档案。"; "Please check the permission at \"%@\"." = "请检查此处的存取权限:\"%@\"."; diff --git a/Source/Resources/zh-Hant.lproj/Localizable.strings b/Source/Resources/zh-Hant.lproj/Localizable.strings index 07a09382..90ddc233 100644 --- a/Source/Resources/zh-Hant.lproj/Localizable.strings +++ b/Source/Resources/zh-Hant.lproj/Localizable.strings @@ -39,7 +39,7 @@ "NotificationSwitchON" = "✔ 已啟用"; "NotificationSwitchOFF" = "✘ 已停用"; "NotificationSwitchASCII" = "↺ 切換完畢"; -"Edit User Phrases…" = "編輯自訂語彙…"; +"Edit vChewing User Phrases…" = "編輯威注音自訂語彙…"; "Reload User Phrases" = "重載自訂語彙"; "Unable to create the user phrase file." = "無法創建自訂語彙檔案。"; "Please check the permission at \"%@\"." = "請檢查此處的存取權限:\"%@\"."; From 55c870c3dc52f638b83188a8c7598fed67d8dfcf Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 3 Oct 2022 10:00:21 +0800 Subject: [PATCH 2/7] Repo // Updating bleachSpecifiedSuggestions() to add batch processing. --- .../LangModelAssembly/SubLMs/lmUserOverride.swift | 9 ++++++--- Source/Modules/LMMgr.swift | 6 +++--- Source/Modules/SessionCtl_Delegates.swift | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Packages/vChewing_LangModelAssembly/Sources/LangModelAssembly/SubLMs/lmUserOverride.swift b/Packages/vChewing_LangModelAssembly/Sources/LangModelAssembly/SubLMs/lmUserOverride.swift index 28fefc51..414f36b2 100644 --- a/Packages/vChewing_LangModelAssembly/Sources/LangModelAssembly/SubLMs/lmUserOverride.swift +++ b/Packages/vChewing_LangModelAssembly/Sources/LangModelAssembly/SubLMs/lmUserOverride.swift @@ -154,10 +154,13 @@ extension vChewingLM.LMUserOverride { // MARK: - Hash and Dehash the entire UOM data, etc. extension vChewingLM.LMUserOverride { - public func bleachSpecifiedSuggestions(target: String, saveCallback: @escaping () -> Void) { + public func bleachSpecifiedSuggestions(targets: [String], saveCallback: @escaping () -> Void) { + if targets.isEmpty { return } for neta in mutLRUMap { - if neta.value.observation.overrides.keys.contains(target) { - mutLRUMap.removeValue(forKey: neta.key) + for target in targets { + if neta.value.observation.overrides.keys.contains(target) { + mutLRUMap.removeValue(forKey: neta.key) + } } } resetMRUList() diff --git a/Source/Modules/LMMgr.swift b/Source/Modules/LMMgr.swift index fb244910..dbb37851 100644 --- a/Source/Modules/LMMgr.swift +++ b/Source/Modules/LMMgr.swift @@ -610,12 +610,12 @@ public enum LMMgr { group.notify(queue: DispatchQueue.main) {} } - public static func bleachSpecifiedSuggestions(target: String, mode: Shared.InputMode) { + public static func bleachSpecifiedSuggestions(targets: [String], mode: Shared.InputMode) { switch mode { case .imeModeCHS: - Self.uomCHT.bleachSpecifiedSuggestions(target: target, saveCallback: { Self.uomCHT.saveData() }) + Self.uomCHT.bleachSpecifiedSuggestions(targets: targets, saveCallback: { Self.uomCHT.saveData() }) case .imeModeCHT: - Self.uomCHS.bleachSpecifiedSuggestions(target: target, saveCallback: { Self.uomCHS.saveData() }) + Self.uomCHS.bleachSpecifiedSuggestions(targets: targets, saveCallback: { Self.uomCHS.saveData() }) case .imeModeNULL: break } diff --git a/Source/Modules/SessionCtl_Delegates.swift b/Source/Modules/SessionCtl_Delegates.swift index 722994f3..88e7e104 100644 --- a/Source/Modules/SessionCtl_Delegates.swift +++ b/Source/Modules/SessionCtl_Delegates.swift @@ -43,8 +43,8 @@ extension SessionCtl: KeyHandlerDelegate { let rawPair = state.data.userPhraseKVPair let valueCurrent = rawPair.1 let valueReversed = ChineseConverter.crossConvert(rawPair.1) - LMMgr.bleachSpecifiedSuggestions(target: valueCurrent, mode: IMEApp.currentInputMode) - LMMgr.bleachSpecifiedSuggestions(target: valueReversed, mode: IMEApp.currentInputMode.reversed) + LMMgr.bleachSpecifiedSuggestions(targets: [valueCurrent], mode: IMEApp.currentInputMode) + LMMgr.bleachSpecifiedSuggestions(targets: [valueReversed], mode: IMEApp.currentInputMode.reversed) // 清詞完畢 return true } From 955d0d7acfdb3ed98b7dbb8c6b87ab74244c36a7 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 3 Oct 2022 12:34:43 +0800 Subject: [PATCH 3/7] KeyHandler // Comment update. --- Source/Modules/KeyHandler_HandleCandidate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/KeyHandler_HandleCandidate.swift b/Source/Modules/KeyHandler_HandleCandidate.swift index 6f928b24..597f5550 100644 --- a/Source/Modules/KeyHandler_HandleCandidate.swift +++ b/Source/Modules/KeyHandler_HandleCandidate.swift @@ -222,7 +222,7 @@ extension KeyHandler { } } - // MARK: 聯想詞處理 (Associated Phrases) + // MARK: 聯想詞處理 (Associated Phrases) 以及標準選字處理 if state.type == .ofAssociates { if !input.isShiftHold { return false } From 76af154d16665d19c4bc478b61fde6f31623c473 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 3 Oct 2022 12:45:09 +0800 Subject: [PATCH 4/7] SessionCtl // Use alphanumerical keyboard for candidate window. --- Source/Modules/SessionCtl_Core.swift | 3 ++- Source/Modules/UIModules/PrefUI/suiPrefPaneKeyboard.swift | 2 +- Source/Resources/Base.lproj/Localizable.strings | 2 +- Source/Resources/en.lproj/Localizable.strings | 2 +- Source/Resources/ja.lproj/Localizable.strings | 2 +- Source/Resources/zh-Hans.lproj/Localizable.strings | 2 +- Source/Resources/zh-Hant.lproj/Localizable.strings | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/Modules/SessionCtl_Core.swift b/Source/Modules/SessionCtl_Core.swift index 48af84e2..df81064e 100644 --- a/Source/Modules/SessionCtl_Core.swift +++ b/Source/Modules/SessionCtl_Core.swift @@ -68,6 +68,7 @@ class SessionCtl: IMKInputController { var state: IMEStateProtocol = IMEState.ofEmpty() { didSet { vCLog("Current State: \(state.type.rawValue)") + setKeyLayout() } } @@ -134,7 +135,7 @@ extension SessionCtl { /// 指定鍵盤佈局。 func setKeyLayout() { guard let client = client() else { return } - if isASCIIMode, IMKHelper.isDynamicBasicKeyboardLayoutEnabled { + if (isASCIIMode && IMKHelper.isDynamicBasicKeyboardLayoutEnabled) || state.isCandidateContainer { client.overrideKeyboard(withKeyboardNamed: PrefMgr.shared.alphanumericalKeyboardLayout) return } diff --git a/Source/Modules/UIModules/PrefUI/suiPrefPaneKeyboard.swift b/Source/Modules/UIModules/PrefUI/suiPrefPaneKeyboard.swift index f0009d3d..58aaa9f4 100644 --- a/Source/Modules/UIModules/PrefUI/suiPrefPaneKeyboard.swift +++ b/Source/Modules/UIModules/PrefUI/suiPrefPaneKeyboard.swift @@ -225,7 +225,7 @@ struct suiPrefPaneKeyboard: View { HStack { Text( NSLocalizedString( - "Choose the macOS-level alphanumerical keyboard layout. This setting is for the alphanumerical mode only.", + "Choose the macOS-level alphanumerical keyboard layout. This setting is for candidate window and the alphanumerical mode only.", comment: "" ) ) diff --git a/Source/Resources/Base.lproj/Localizable.strings b/Source/Resources/Base.lproj/Localizable.strings index 4847d80c..3ff8e229 100644 --- a/Source/Resources/Base.lproj/Localizable.strings +++ b/Source/Resources/Base.lproj/Localizable.strings @@ -144,7 +144,7 @@ "Choose the behavior of (Shift+)Tab key in the candidate window." = "Choose the behavior of (Shift+)Tab key in the candidate window."; "Choose the behavior of Shift+Letter key with letter inputs." = "Choose the behavior of Shift+Letter key with letter inputs."; "Choose the cursor position where you want to list possible candidates." = "Choose the cursor position where you want to list possible candidates."; -"Choose the macOS-level alphanumerical keyboard layout. This setting is for the alphanumerical mode only." = "Choose the macOS-level alphanumerical keyboard layout. This setting is for the alphanumerical mode only."; +"Choose the macOS-level alphanumerical keyboard layout. This setting is for candidate window and the alphanumerical mode only." = "Choose the macOS-level alphanumerical keyboard layout. This setting is for candidate window and the alphanumerical mode only."; "Choose the macOS-level basic keyboard layout. Non-QWERTY alphanumerical keyboard layouts are for Pinyin parser only." = "Choose the macOS-level basic keyboard layout. Non-QWERTY alphanumerical keyboard layouts are for Pinyin parser only."; "Choose the phonetic layout for Mandarin parser." = "Choose the phonetic layout for Mandarin parser."; "Choose your desired user data folder path. Will be omitted if invalid." = "Choose your desired user data folder path. Will be omitted if invalid."; diff --git a/Source/Resources/en.lproj/Localizable.strings b/Source/Resources/en.lproj/Localizable.strings index 4847d80c..3ff8e229 100644 --- a/Source/Resources/en.lproj/Localizable.strings +++ b/Source/Resources/en.lproj/Localizable.strings @@ -144,7 +144,7 @@ "Choose the behavior of (Shift+)Tab key in the candidate window." = "Choose the behavior of (Shift+)Tab key in the candidate window."; "Choose the behavior of Shift+Letter key with letter inputs." = "Choose the behavior of Shift+Letter key with letter inputs."; "Choose the cursor position where you want to list possible candidates." = "Choose the cursor position where you want to list possible candidates."; -"Choose the macOS-level alphanumerical keyboard layout. This setting is for the alphanumerical mode only." = "Choose the macOS-level alphanumerical keyboard layout. This setting is for the alphanumerical mode only."; +"Choose the macOS-level alphanumerical keyboard layout. This setting is for candidate window and the alphanumerical mode only." = "Choose the macOS-level alphanumerical keyboard layout. This setting is for candidate window and the alphanumerical mode only."; "Choose the macOS-level basic keyboard layout. Non-QWERTY alphanumerical keyboard layouts are for Pinyin parser only." = "Choose the macOS-level basic keyboard layout. Non-QWERTY alphanumerical keyboard layouts are for Pinyin parser only."; "Choose the phonetic layout for Mandarin parser." = "Choose the phonetic layout for Mandarin parser."; "Choose your desired user data folder path. Will be omitted if invalid." = "Choose your desired user data folder path. Will be omitted if invalid."; diff --git a/Source/Resources/ja.lproj/Localizable.strings b/Source/Resources/ja.lproj/Localizable.strings index 62111f50..d5db373f 100644 --- a/Source/Resources/ja.lproj/Localizable.strings +++ b/Source/Resources/ja.lproj/Localizable.strings @@ -144,7 +144,7 @@ "Choose the behavior of (Shift+)Tab key in the candidate window." = "入力候補陳列での (Shift+)Tab キーの輪番切替対象をご指定ください。"; "Choose the behavior of Shift+Letter key with letter inputs." = "Shift+文字キーの行為をご指定ください。"; "Choose the cursor position where you want to list possible candidates." = "カーソルはどこで入力候補を呼び出すかとご指定ださい。"; -"Choose the macOS-level alphanumerical keyboard layout. This setting is for the alphanumerical mode only." = "macOS 英数キーボード配置をご指定ください。英数入力モードだけに使われる配置である。"; +"Choose the macOS-level alphanumerical keyboard layout. This setting is for candidate window and the alphanumerical mode only." = "macOS 英数キーボード配置をご指定ください。文字候補の選択と英数入力モードだけに使われる配置である。"; "Choose the macOS-level basic keyboard layout. Non-QWERTY alphanumerical keyboard layouts are for Pinyin parser only." = "macOS 基礎キーボード配置をご指定ください。QWERTY 以外の英数キーボードは弁音以外の配列に不適用。"; "Choose the phonetic layout for Mandarin parser." = "共通語分析器の注音配列をご指定ください。"; "Choose your desired user data folder path. Will be omitted if invalid." = "欲しがるユーザー辞書保存先をご指定ください。無効なる保存先設定は省かれる。"; diff --git a/Source/Resources/zh-Hans.lproj/Localizable.strings b/Source/Resources/zh-Hans.lproj/Localizable.strings index 7eaccfbb..4b028adc 100644 --- a/Source/Resources/zh-Hans.lproj/Localizable.strings +++ b/Source/Resources/zh-Hans.lproj/Localizable.strings @@ -144,7 +144,7 @@ "Choose the behavior of (Shift+)Tab key in the candidate window." = "指定 (Shift+)Tab 在选字窗内的轮替操作对象。"; "Choose the behavior of Shift+Letter key with letter inputs." = "指定 Shift+字母键 的行为。"; "Choose the cursor position where you want to list possible candidates." = "请选择用以触发选字的游标相对位置。"; -"Choose the macOS-level alphanumerical keyboard layout. This setting is for the alphanumerical mode only." = "请选择 macOS 英数键盘布局。该布局仅用于英数输入模式。"; +"Choose the macOS-level alphanumerical keyboard layout. This setting is for candidate window and the alphanumerical mode only." = "请选择 macOS 英数键盘布局。该布局仅用于选字窗和英数输入模式。"; "Choose the macOS-level basic keyboard layout. Non-QWERTY alphanumerical keyboard layouts are for Pinyin parser only." = "请选择 macOS 基础键盘布局。QWERTY 以外的英数布局是为了拼音排列使用者而准备的。"; "Choose the phonetic layout for Mandarin parser." = "请指定普通话/国音分析器所使用的注音排列。"; "Choose your desired user data folder path. Will be omitted if invalid." = "请在此指定您想指定的使用者语汇档案目录。无效值会被忽略。"; diff --git a/Source/Resources/zh-Hant.lproj/Localizable.strings b/Source/Resources/zh-Hant.lproj/Localizable.strings index 90ddc233..8223fdc6 100644 --- a/Source/Resources/zh-Hant.lproj/Localizable.strings +++ b/Source/Resources/zh-Hant.lproj/Localizable.strings @@ -144,7 +144,7 @@ "Choose the behavior of (Shift+)Tab key in the candidate window." = "指定 (Shift+)Tab 在選字窗內的輪替操作對象。"; "Choose the behavior of Shift+Letter key with letter inputs." = "指定 Shift+字母鍵 的行為。"; "Choose the cursor position where you want to list possible candidates." = "請選擇用以觸發選字的游標相對位置。"; -"Choose the macOS-level alphanumerical keyboard layout. This setting is for the alphanumerical mode only." = "請選擇 macOS 英數鍵盤佈局。該佈局僅用於英數輸入模式。"; +"Choose the macOS-level alphanumerical keyboard layout. This setting is for candidate window and the alphanumerical mode only." = "請選擇 macOS 英數鍵盤佈局。該佈局僅用於選字窗和英數輸入模式。"; "Choose the macOS-level basic keyboard layout. Non-QWERTY alphanumerical keyboard layouts are for Pinyin parser only." = "請選擇 macOS 基礎鍵盤佈局。QWERTY 以外的英數佈局是為了拼音排列使用者而準備的。"; "Choose the phonetic layout for Mandarin parser." = "請指定普通話/國音分析器所使用的注音排列。"; "Choose your desired user data folder path. Will be omitted if invalid." = "請在此指定您想指定的使用者語彙檔案目錄。無效值會被忽略。"; From 30f2140353dbbac6d0e282a1d633fb5d86700fad Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 3 Oct 2022 13:03:57 +0800 Subject: [PATCH 5/7] PrefMgr // Fix a default setting for macOS 10.14 and earlier. --- Source/Modules/PrefMgr_Extension.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/PrefMgr_Extension.swift b/Source/Modules/PrefMgr_Extension.swift index 05ed04cb..9a1f293b 100644 --- a/Source/Modules/PrefMgr_Extension.swift +++ b/Source/Modules/PrefMgr_Extension.swift @@ -13,11 +13,11 @@ import Shared extension PrefMgr { public func fixOddPreferences() { // macOS 10.15 開始才能使用 SwiftUI 構建的田所選字窗。 - if #unavailable(macOS 10.15) { useIMKCandidateWindow = true } if #unavailable(macOS 10.15) { + useIMKCandidateWindow = true handleDefaultCandidateFontsByLangIdentifier = false shiftKeyAccommodationBehavior = 0 - disableShiftTogglingAlphanumericalMode = false + disableShiftTogglingAlphanumericalMode = true togglingAlphanumericalModeWithLShift = false } // 自動糾正選字鍵 (利用其 didSet 特性) From bad45ea9cbdc1edd541916794a0b187dea43b6dc Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 3 Oct 2022 13:38:04 +0800 Subject: [PATCH 6/7] TDKCandidates // Reimplement certain features provided previously. --- .../CandidateWindow/CandidatePool.swift | 2 - .../INMUCandidateSuite/CtlCandidateTDK.swift | 72 +++++++++++++++---- .../CtlCandidateTDKBackports.swift | 72 +++++++++++++++---- 3 files changed, 114 insertions(+), 32 deletions(-) diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool.swift index a63d4a20..c912f6e7 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool.swift @@ -184,7 +184,6 @@ public class CandidatePool { var indexSpecified = indexSpecified highlightedIndex = indexSpecified if !(0.. Bool { + if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == thePoolHorizontal.candidateRows.count - 1) + || (currentLayout == .vertical + && thePoolVertical.currentColumnNumber == thePoolVertical.candidateColumns.count - 1) + { + return highlightNextCandidate() + } switch currentLayout { case .horizontal: for _ in 0.. Bool { + if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == thePoolHorizontal.candidateRows.count - 1) + || (currentLayout == .vertical + && thePoolVertical.currentColumnNumber == thePoolVertical.candidateColumns.count - 1) + { + return highlightNextCandidate() + } + switch currentLayout { + case .horizontal: + thePoolHorizontal.selectNewNeighborRow(direction: .down) + case .vertical: + thePoolVertical.selectNewNeighborColumn(direction: .right) + @unknown default: + return false + } + updateDisplay() + return true + } + @discardableResult override public func showPreviousPage() -> Bool { + if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == 0) + || (currentLayout == .vertical && thePoolVertical.currentColumnNumber == 0) + { + return highlightPreviousCandidate() + } switch currentLayout { case .horizontal: for _ in 0.. Bool { - switch currentLayout { - case .horizontal: - thePoolHorizontal.selectNewNeighborRow(direction: .down) - case .vertical: - thePoolVertical.selectNewNeighborColumn(direction: .right) - @unknown default: - return false - } - updateDisplay() - return true - } - @discardableResult override public func showPreviousLine() -> Bool { + if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == 0) + || (currentLayout == .vertical && thePoolVertical.currentColumnNumber == 0) + { + return highlightPreviousCandidate() + } switch currentLayout { case .horizontal: thePoolHorizontal.selectNewNeighborRow(direction: .up) @@ -151,8 +173,18 @@ public class CtlCandidateTDK: CtlCandidate { @discardableResult override public func highlightNextCandidate() -> Bool { switch currentLayout { case .horizontal: + if thePoolHorizontal.highlightedIndex == thePoolHorizontal.candidateDataAll.count - 1 { + thePoolHorizontal.highlightHorizontal(at: 0) + delegate?.buzz() + break + } thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.highlightedIndex + 1) case .vertical: + if thePoolVertical.highlightedIndex == thePoolVertical.candidateDataAll.count - 1 { + thePoolVertical.highlightVertical(at: 0) + delegate?.buzz() + break + } thePoolVertical.highlightVertical(at: thePoolVertical.highlightedIndex + 1) @unknown default: return false @@ -164,8 +196,18 @@ public class CtlCandidateTDK: CtlCandidate { @discardableResult override public func highlightPreviousCandidate() -> Bool { switch currentLayout { case .horizontal: + if thePoolHorizontal.highlightedIndex == 0 { + thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.candidateDataAll.count - 1) + delegate?.buzz() + break + } thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.highlightedIndex - 1) case .vertical: + if thePoolVertical.highlightedIndex == 0 { + thePoolVertical.highlightVertical(at: thePoolVertical.candidateDataAll.count - 1) + delegate?.buzz() + break + } thePoolVertical.highlightVertical(at: thePoolVertical.highlightedIndex - 1) @unknown default: return false @@ -179,11 +221,11 @@ public class CtlCandidateTDK: CtlCandidate { case .horizontal: let currentRow = thePoolHorizontal.candidateRows[thePoolHorizontal.currentRowNumber] let actualID = max(0, min(id, currentRow.count - 1)) - return thePoolHorizontal.candidateRows[thePoolHorizontal.currentRowNumber][actualID].index + return currentRow[actualID].index case .vertical: let currentColumn = thePoolVertical.candidateColumns[thePoolVertical.currentColumnNumber] let actualID = max(0, min(id, currentColumn.count - 1)) - return thePoolVertical.candidateColumns[thePoolVertical.currentColumnNumber][actualID].index + return currentColumn[actualID].index @unknown default: return 0 } diff --git a/Packages/vChewing_TDKCandidateBackports/Sources/TDKCandidateBackports/INMUCandidateSuiteBackports/CtlCandidateTDKBackports.swift b/Packages/vChewing_TDKCandidateBackports/Sources/TDKCandidateBackports/INMUCandidateSuiteBackports/CtlCandidateTDKBackports.swift index c37b0537..bef6d1ef 100644 --- a/Packages/vChewing_TDKCandidateBackports/Sources/TDKCandidateBackports/INMUCandidateSuiteBackports/CtlCandidateTDKBackports.swift +++ b/Packages/vChewing_TDKCandidateBackports/Sources/TDKCandidateBackports/INMUCandidateSuiteBackports/CtlCandidateTDKBackports.swift @@ -91,6 +91,12 @@ public class CtlCandidateTDKBackports: CtlCandidate { } @discardableResult override public func showNextPage() -> Bool { + if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == thePoolHorizontal.candidateRows.count - 1) + || (currentLayout == .vertical + && thePoolVertical.currentColumnNumber == thePoolVertical.candidateColumns.count - 1) + { + return highlightNextCandidate() + } switch currentLayout { case .horizontal: for _ in 0.. Bool { + if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == thePoolHorizontal.candidateRows.count - 1) + || (currentLayout == .vertical + && thePoolVertical.currentColumnNumber == thePoolVertical.candidateColumns.count - 1) + { + return highlightNextCandidate() + } + switch currentLayout { + case .horizontal: + thePoolHorizontal.selectNewNeighborRow(direction: .down) + case .vertical: + thePoolVertical.selectNewNeighborColumn(direction: .right) + @unknown default: + return false + } + updateDisplay() + return true + } + @discardableResult override public func showPreviousPage() -> Bool { + if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == 0) + || (currentLayout == .vertical && thePoolVertical.currentColumnNumber == 0) + { + return highlightPreviousCandidate() + } switch currentLayout { case .horizontal: for _ in 0.. Bool { - switch currentLayout { - case .horizontal: - thePoolHorizontal.selectNewNeighborRow(direction: .down) - case .vertical: - thePoolVertical.selectNewNeighborColumn(direction: .right) - @unknown default: - return false - } - updateDisplay() - return true - } - @discardableResult override public func showPreviousLine() -> Bool { + if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == 0) + || (currentLayout == .vertical && thePoolVertical.currentColumnNumber == 0) + { + return highlightPreviousCandidate() + } switch currentLayout { case .horizontal: thePoolHorizontal.selectNewNeighborRow(direction: .up) @@ -153,8 +175,18 @@ public class CtlCandidateTDKBackports: CtlCandidate { @discardableResult override public func highlightNextCandidate() -> Bool { switch currentLayout { case .horizontal: + if thePoolHorizontal.highlightedIndex == thePoolHorizontal.candidateDataAll.count - 1 { + thePoolHorizontal.highlightHorizontal(at: 0) + delegate?.buzz() + break + } thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.highlightedIndex + 1) case .vertical: + if thePoolVertical.highlightedIndex == thePoolVertical.candidateDataAll.count - 1 { + thePoolVertical.highlightVertical(at: 0) + delegate?.buzz() + break + } thePoolVertical.highlightVertical(at: thePoolVertical.highlightedIndex + 1) @unknown default: return false @@ -166,8 +198,18 @@ public class CtlCandidateTDKBackports: CtlCandidate { @discardableResult override public func highlightPreviousCandidate() -> Bool { switch currentLayout { case .horizontal: + if thePoolHorizontal.highlightedIndex == 0 { + thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.candidateDataAll.count - 1) + delegate?.buzz() + break + } thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.highlightedIndex - 1) case .vertical: + if thePoolVertical.highlightedIndex == 0 { + thePoolVertical.highlightVertical(at: thePoolVertical.candidateDataAll.count - 1) + delegate?.buzz() + break + } thePoolVertical.highlightVertical(at: thePoolVertical.highlightedIndex - 1) @unknown default: return false @@ -181,11 +223,11 @@ public class CtlCandidateTDKBackports: CtlCandidate { case .horizontal: let currentRow = thePoolHorizontal.candidateRows[thePoolHorizontal.currentRowNumber] let actualID = max(0, min(id, currentRow.count - 1)) - return thePoolHorizontal.candidateRows[thePoolHorizontal.currentRowNumber][actualID].index + return currentRow[actualID].index case .vertical: let currentColumn = thePoolVertical.candidateColumns[thePoolVertical.currentColumnNumber] let actualID = max(0, min(id, currentColumn.count - 1)) - return thePoolVertical.candidateColumns[thePoolVertical.currentColumnNumber][actualID].index + return currentColumn[actualID].index @unknown default: return 0 } From cd43ab4e66dc36397bb83f05e12bd5b96db4ab70 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 3 Oct 2022 13:21:05 +0800 Subject: [PATCH 7/7] Bump version to 2.8.5 SP2 Build 2852. --- Update-Info.plist | 2 +- vChewing.xcodeproj/project.pbxproj | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Update-Info.plist b/Update-Info.plist index 67a84027..abbb0762 100644 --- a/Update-Info.plist +++ b/Update-Info.plist @@ -5,7 +5,7 @@ CFBundleShortVersionString 2.8.5 CFBundleVersion - 2851 + 2852 UpdateInfoEndpoint https://gitee.com/vchewing/vChewing-macOS/raw/main/Update-Info.plist UpdateInfoSite diff --git a/vChewing.xcodeproj/project.pbxproj b/vChewing.xcodeproj/project.pbxproj index 48af4742..90c49e48 100644 --- a/vChewing.xcodeproj/project.pbxproj +++ b/vChewing.xcodeproj/project.pbxproj @@ -1272,7 +1272,7 @@ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2851; + CURRENT_PROJECT_VERSION = 2852; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -1312,7 +1312,7 @@ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2851; + CURRENT_PROJECT_VERSION = 2852; ENABLE_NS_ASSERTIONS = NO; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; @@ -1351,7 +1351,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2851; + CURRENT_PROJECT_VERSION = 2852; DEAD_CODE_STRIPPING = YES; ENABLE_HARDENED_RUNTIME = YES; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -1404,7 +1404,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2851; + CURRENT_PROJECT_VERSION = 2852; DEAD_CODE_STRIPPING = YES; ENABLE_HARDENED_RUNTIME = YES; ENABLE_NS_ASSERTIONS = NO; @@ -1539,7 +1539,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2851; + CURRENT_PROJECT_VERSION = 2852; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = ""; @@ -1600,7 +1600,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2851; + CURRENT_PROJECT_VERSION = 2852; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = ""; @@ -1648,7 +1648,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2851; + CURRENT_PROJECT_VERSION = 2852; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; @@ -1694,7 +1694,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2851; + CURRENT_PROJECT_VERSION = 2852; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES;