From c7026a65fdcc9ce5b3d6f28f55f95a4d630e36d0 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 14 Mar 2022 21:34:13 +0800 Subject: [PATCH 01/20] Proj // Size optimization for built executables. --- vChewing.xcodeproj/project.pbxproj | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/vChewing.xcodeproj/project.pbxproj b/vChewing.xcodeproj/project.pbxproj index 87c8fe1e..247ed828 100644 --- a/vChewing.xcodeproj/project.pbxproj +++ b/vChewing.xcodeproj/project.pbxproj @@ -1239,7 +1239,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; + GCC_OPTIMIZATION_LEVEL = z; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -1266,7 +1266,7 @@ SDKROOT = macosx; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_OPTIMIZATION_LEVEL = "-Osize"; SWIFT_VERSION = 5.0; }; name = Debug; @@ -1295,6 +1295,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_OPTIMIZATION_LEVEL = z; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GENERATE_INFOPLIST_FILE = YES; @@ -1316,7 +1317,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_OPTIMIZATION_LEVEL = "-Osize"; SWIFT_VERSION = 5.0; }; name = Release; @@ -1430,7 +1431,7 @@ GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_OPTIMIZATION_LEVEL = 0; + GCC_OPTIMIZATION_LEVEL = z; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Source/Headers/vChewing-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -1466,7 +1467,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; SWIFT_OBJC_BRIDGING_HEADER = "Source/Headers/vChewing-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_OPTIMIZATION_LEVEL = "-Osize"; SWIFT_VERSION = 5.0; WRAPPER_EXTENSION = app; }; @@ -1498,6 +1499,7 @@ DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = z; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Source/Headers/vChewing-Prefix.pch"; GCC_TREAT_WARNINGS_AS_ERRORS = YES; @@ -1527,6 +1529,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; SWIFT_OBJC_BRIDGING_HEADER = "Source/Headers/vChewing-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Osize"; SWIFT_VERSION = 5.0; WRAPPER_EXTENSION = app; }; @@ -1609,7 +1612,7 @@ GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_OPTIMIZATION_LEVEL = 0; + GCC_OPTIMIZATION_LEVEL = z; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Installer/Installer-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -1636,7 +1639,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; SWIFT_OBJC_BRIDGING_HEADER = "Installer/vChewingInstaller-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_OPTIMIZATION_LEVEL = "-Osize"; SWIFT_VERSION = 5.0; WRAPPER_EXTENSION = app; }; @@ -1662,6 +1665,7 @@ DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = z; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Installer/Installer-Prefix.pch"; GCC_TREAT_WARNINGS_AS_ERRORS = YES; @@ -1682,6 +1686,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; SWIFT_OBJC_BRIDGING_HEADER = "Installer/vChewingInstaller-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Osize"; SWIFT_VERSION = 5.0; WRAPPER_EXTENSION = app; }; From fd2078bfa96c710fcd8feb8ceb80be5adfc3f2c2 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sun, 13 Mar 2022 17:46:29 +0800 Subject: [PATCH 02/20] Pref // -kDefaultAssociatedPhrasesKeys (useless). --- Source/Modules/IMEModules/PreferencesModule.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Modules/IMEModules/PreferencesModule.swift b/Source/Modules/IMEModules/PreferencesModule.swift index 95684357..2cee75af 100644 --- a/Source/Modules/IMEModules/PreferencesModule.swift +++ b/Source/Modules/IMEModules/PreferencesModule.swift @@ -70,7 +70,6 @@ private let kMinComposingBufferSize = 4 private let kMaxComposingBufferSize = 30 private let kDefaultKeys = "123456789" -private let kDefaultAssociatedPhrasesKeys = "!@#$%^&*(" // MARK: Property wrappers From 62c9c66becaa90cb9536edded6435fc86f41fe83 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sun, 13 Mar 2022 15:04:05 +0800 Subject: [PATCH 03/20] KeyHandler // Typo fix in "calling candiate window" section. --- Source/Modules/ControllerModules/KeyHandler.mm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index 457353bb..0e6e8cb2 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -433,8 +433,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; return YES; } - // MARK: Space and Down, plus PageUp / PageDn / PageLeft / PageRight. - // keyCode 125 = Down, charCode 32 = Space + // MARK: Calling candidate window using Space or Down or PageUp / PageDn. if (_bpmfReadingBuffer->isEmpty() && [state isKindOfClass:[InputStateNotEmpty class]] && ([input isExtraChooseCandidateKey] || [input isExtraChooseCandidateKeyReverse] From ae5237e0ff4f39cb5ad0ba1d8af4ac9e011a815f Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sun, 13 Mar 2022 15:07:04 +0800 Subject: [PATCH 04/20] KeyHandler(Input) // Revised conditioning of letter inputs. - This is to fix an issue of mishandling letter input condition. --- Source/Modules/ControllerModules/KeyHandler.mm | 4 ++-- Source/Modules/ControllerModules/KeyHandlerInput.swift | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index 0e6e8cb2..bc72647d 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -585,7 +585,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; // Lukhnos 這裡的處理反而會使得 Apple 倚天注音動態鍵盤佈局「敲不了半形大寫英文」的缺點曝露無疑,所以注釋掉。 // 至於他試圖用這種處理來解決的上游 UPR293 的問題,其實針對詞庫檔案的排序做點手腳就可以解決。威注音本來也就是這麼做的。 - if (/*[state isKindOfClass:[InputStateNotEmpty class]] && */(char) charCode >= 'A' && (char) charCode <= 'Z') { + if (/*[state isKindOfClass:[InputStateNotEmpty class]] && */[input isUpperCaseASCIILetterKey]) { std::string letter = std::string("_letter_") + std::string(1, (char) charCode); if ([self _handlePunctuation:letter state:state usingVerticalMode:input.useVerticalMode stateCallback:stateCallback errorCallback:errorCallback]) { return YES; @@ -1253,7 +1253,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; BOOL shouldAutoSelectCandidate = _bpmfReadingBuffer->isValidKey((char) charCode) || _languageModel->hasUnigramsForKey(customPunctuation) || _languageModel->hasUnigramsForKey(punctuation); - if (!shouldAutoSelectCandidate && (char) charCode >= 'A' && (char) charCode <= 'Z') { + if (!shouldAutoSelectCandidate && [input isUpperCaseASCIILetterKey]) { std::string letter = std::string("_letter_") + std::string(1, (char) charCode); if (_languageModel->hasUnigramsForKey(letter)) { shouldAutoSelectCandidate = YES; diff --git a/Source/Modules/ControllerModules/KeyHandlerInput.swift b/Source/Modules/ControllerModules/KeyHandlerInput.swift index 7ab70873..f29097fa 100644 --- a/Source/Modules/ControllerModules/KeyHandlerInput.swift +++ b/Source/Modules/ControllerModules/KeyHandlerInput.swift @@ -233,6 +233,11 @@ class KeyHandlerInput: NSObject { KeyCode(rawValue: keyCode) == verticalModeOnlyChooseCandidateKey } + @objc var isUpperCaseASCIILetterKey: Bool { + // 這裡必須加上「flags == .shift」,否則會出現某些情況下輸入法「誤判當前鍵入的非 Shift 字符為大寫」的問題。 + self.charCode >= 65 && self.charCode <= 90 && flags == .shift + } + @objc var isSymbolMenuPhysicalKey: Bool { // 這裡必須用 KeyCode,這樣才不會受隨 macOS 版本更動的 Apple 動態注音鍵盤排列內容的影響。 // 只是必須得與 ![input isShift] 搭配使用才可以(也就是僅判定 Shift 沒被摁下的情形)。 From 0c0359df834851941d0d3055cc711d70fe4d15be Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sun, 13 Mar 2022 18:52:25 +0800 Subject: [PATCH 05/20] ctlPrefWindow // Cleanup useless comments. --- Source/WindowControllers/ctlPrefWindow.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/WindowControllers/ctlPrefWindow.swift b/Source/WindowControllers/ctlPrefWindow.swift index 9f3a1756..689839d4 100644 --- a/Source/WindowControllers/ctlPrefWindow.swift +++ b/Source/WindowControllers/ctlPrefWindow.swift @@ -156,9 +156,6 @@ extension RangeReplaceableCollection where Element: Hashable { } selectionKeyComboBox.stringValue = candidateSelectionKeys - - // MARK: - 設定漢字轉換選項是否禁用 - } // 這裡有必要加上這段處理,用來確保藉由偏好設定介面動過的 CNS 開關能夠立刻生效。 From adc289c088ec8f05176fedb0e4d7fe1ededafd43 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 14 Mar 2022 12:21:44 +0800 Subject: [PATCH 06/20] SymbolLM // +UserSymbolLM. --- .../InstantiatedModels/SymbolLM.h | 2 +- .../InstantiatedModels/UserSymbolLM.h | 44 +++++++++++++++++++ vChewing.xcodeproj/project.pbxproj | 2 + 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 Source/Modules/LangModelRelated/SubLanguageModels/InstantiatedModels/UserSymbolLM.h diff --git a/Source/Modules/LangModelRelated/SubLanguageModels/InstantiatedModels/SymbolLM.h b/Source/Modules/LangModelRelated/SubLanguageModels/InstantiatedModels/SymbolLM.h index e2402f91..48409bc4 100644 --- a/Source/Modules/LangModelRelated/SubLanguageModels/InstantiatedModels/SymbolLM.h +++ b/Source/Modules/LangModelRelated/SubLanguageModels/InstantiatedModels/SymbolLM.h @@ -35,7 +35,7 @@ public: return false; } virtual float overridedValue() override { - return -12.0; + return -13.0; } }; diff --git a/Source/Modules/LangModelRelated/SubLanguageModels/InstantiatedModels/UserSymbolLM.h b/Source/Modules/LangModelRelated/SubLanguageModels/InstantiatedModels/UserSymbolLM.h new file mode 100644 index 00000000..96ee02d5 --- /dev/null +++ b/Source/Modules/LangModelRelated/SubLanguageModels/InstantiatedModels/UserSymbolLM.h @@ -0,0 +1,44 @@ +// Copyright (c) 2011 and onwards The OpenVanilla Project (MIT License). +// All possible vChewing-specific modifications are (c) 2021 and onwards The vChewing Project (MIT-NTL License). +/* +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +2. No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, + except as required to fulfill notice requirements above. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef USERSYMBOLLM_H +#define USERSYMBOLLM_H + +#include +#include +#include +#include "LanguageModel.h" +#include "UserPhrasesLM.h" + +namespace vChewing { + +class UserSymbolLM: public UserPhrasesLM +{ +public: + virtual bool allowConsolidation() override { + return true; + } + virtual float overridedValue() override { + return -12.0; + } +}; + +} + +#endif diff --git a/vChewing.xcodeproj/project.pbxproj b/vChewing.xcodeproj/project.pbxproj index 247ed828..bfa8cc30 100644 --- a/vChewing.xcodeproj/project.pbxproj +++ b/vChewing.xcodeproj/project.pbxproj @@ -197,6 +197,7 @@ 5B62A34527AE7CD900A19448 /* NotifierController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotifierController.swift; sourceTree = ""; }; 5B707CE527D9F3A10099EF99 /* SwiftyOpenCC */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = SwiftyOpenCC; path = Packages/SwiftyOpenCC; sourceTree = ""; }; 5B707CE727D9F4590099EF99 /* OpenCCBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenCCBridge.swift; sourceTree = ""; }; + 5B7111C727DEF9FF00444310 /* UserSymbolLM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UserSymbolLM.h; sourceTree = ""; }; 5B73FB5427B2BD6900E9BF49 /* PhraseEditor-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "PhraseEditor-Info.plist"; path = "UserPhraseEditor/PhraseEditor-Info.plist"; sourceTree = SOURCE_ROOT; }; 5B73FB5F27B2BE1300E9BF49 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 5B7BC4AF27AFFBE800F66C24 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Source/WindowNIBs/Base.lproj/frmPrefWindow.xib; sourceTree = ""; }; @@ -349,6 +350,7 @@ isa = PBXGroup; children = ( 5B8F43ED27C9BC220069AC27 /* SymbolLM.h */, + 5B7111C727DEF9FF00444310 /* UserSymbolLM.h */, 5B62A32B27AE78B000A19448 /* CNSLM.h */, ); path = InstantiatedModels; From bb184e286b2f986cad9b904dbe50c2d6b7f6561e Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 14 Mar 2022 12:48:40 +0800 Subject: [PATCH 07/20] LMInstantiator // Add m_userSymbolModel, etc. plus comment fix. --- Source/Modules/LangModelRelated/LMInstantiator.h | 7 ++++++- .../Modules/LangModelRelated/LMInstantiator.mm | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Source/Modules/LangModelRelated/LMInstantiator.h b/Source/Modules/LangModelRelated/LMInstantiator.h index 0357a464..c8b0c504 100644 --- a/Source/Modules/LangModelRelated/LMInstantiator.h +++ b/Source/Modules/LangModelRelated/LMInstantiator.h @@ -27,6 +27,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #include "PhraseReplacementMap.h" #include "SymbolLM.h" #include "UserPhrasesLM.h" +#include "UserSymbolLM.h" #include #include @@ -89,8 +90,11 @@ public: /// @param userPhrasesPath The path of user phrases. /// @param excludedPhrasesPath The path of excluded phrases. void loadUserPhrases(const char* userPhrasesPath, const char* excludedPhrasesPath); + /// Asks to load the user symbol data at the given path. + /// @param userSymbolDataPath The path of user symbol data. + void loadUserSymbolData(const char* userPhrasesPath); /// Asks to load the user associated phrases at the given path. - /// @param userAssociatedPhrasesPath The path of the phrase replacement table. + /// @param userAssociatedPhrasesPath The path of the user associated phrases. void loadUserAssociatedPhrases(const char* userAssociatedPhrasesPath); /// Asks to load the phrase replacement table at the given path. /// @param phraseReplacementPath The path of the phrase replacement table. @@ -150,6 +154,7 @@ protected: CNSLM m_cnsModel; UserPhrasesLM m_userPhrases; UserPhrasesLM m_excludedPhrases; + UserSymbolLM m_userSymbolModel; PhraseReplacementMap m_phraseReplacement; AssociatedPhrases m_associatedPhrases; bool m_phraseReplacementEnabled; diff --git a/Source/Modules/LangModelRelated/LMInstantiator.mm b/Source/Modules/LangModelRelated/LMInstantiator.mm index 948f9aff..870468c8 100644 --- a/Source/Modules/LangModelRelated/LMInstantiator.mm +++ b/Source/Modules/LangModelRelated/LMInstantiator.mm @@ -32,6 +32,7 @@ LMInstantiator::~LMInstantiator() m_languageModel.close(); m_miscModel.close(); m_userPhrases.close(); + m_userSymbolModel.close(); m_cnsModel.close(); m_excludedPhrases.close(); m_phraseReplacement.close(); @@ -103,6 +104,14 @@ void LMInstantiator::loadUserPhrases(const char* userPhrasesDataPath, } } +void LMInstantiator::loadUserSymbolData(const char *userSymbolDataPath) +{ + if (userSymbolDataPath) { + m_userSymbolModel.close(); + m_userSymbolModel.open(userSymbolDataPath); + } +} + void LMInstantiator::loadUserAssociatedPhrases(const char *userAssociatedPhrasesPath) { if (userAssociatedPhrasesPath) { @@ -140,6 +149,7 @@ const std::vector LMInstantiator::unigramsForKey(const std std::vector miscUnigrams; std::vector symbolUnigrams; std::vector userUnigrams; + std::vector userSymbolUnigrams; std::vector cnsUnigrams; std::unordered_set excludedValues; @@ -175,6 +185,11 @@ const std::vector LMInstantiator::unigramsForKey(const std symbolUnigrams = filterAndTransformUnigrams(rawSymbolUnigrams, excludedValues, insertedValues); } + if (m_userSymbolModel.hasUnigramsForKey(key) && m_symbolEnabled) { + std::vector rawUserSymbolUnigrams = m_userSymbolModel.unigramsForKey(key); + userSymbolUnigrams = filterAndTransformUnigrams(rawUserSymbolUnigrams, excludedValues, insertedValues); + } + if (m_cnsModel.hasUnigramsForKey(key) && m_cnsEnabled) { std::vector rawCNSUnigrams = m_cnsModel.unigramsForKey(key); cnsUnigrams = filterAndTransformUnigrams(rawCNSUnigrams, excludedValues, insertedValues); @@ -183,6 +198,7 @@ const std::vector LMInstantiator::unigramsForKey(const std allUnigrams.insert(allUnigrams.begin(), userUnigrams.begin(), userUnigrams.end()); allUnigrams.insert(allUnigrams.end(), cnsUnigrams.begin(), cnsUnigrams.end()); allUnigrams.insert(allUnigrams.begin(), miscUnigrams.begin(), miscUnigrams.end()); + allUnigrams.insert(allUnigrams.end(), userSymbolUnigrams.begin(), userSymbolUnigrams.end()); allUnigrams.insert(allUnigrams.end(), symbolUnigrams.begin(), symbolUnigrams.end()); return allUnigrams; } From a0a97c4fa610084551dfbc69d4478b782afa34cc Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 14 Mar 2022 13:08:54 +0800 Subject: [PATCH 08/20] mgrLangModel // Implementing UserSymbolLM support. --- .../Modules/LangModelRelated/mgrLangModel.h | 1 + .../Modules/LangModelRelated/mgrLangModel.mm | 47 ++++++++----------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/Source/Modules/LangModelRelated/mgrLangModel.h b/Source/Modules/LangModelRelated/mgrLangModel.h index 34c3dc48..cfa533dd 100644 --- a/Source/Modules/LangModelRelated/mgrLangModel.h +++ b/Source/Modules/LangModelRelated/mgrLangModel.h @@ -40,6 +40,7 @@ NS_ASSUME_NONNULL_BEGIN + (NSString *)specifyBundleDataPath:(NSString *)filename; + (NSString *)userPhrasesDataPath:(InputMode)mode; ++ (NSString *)userSymbolDataPath:(InputMode)mode; + (NSString *)userAssociatedPhrasesDataPath:(InputMode)mode; + (NSString *)excludedPhrasesDataPath:(InputMode)mode; + (NSString *)phraseReplacementDataPath:(InputMode)mode; diff --git a/Source/Modules/LangModelRelated/mgrLangModel.mm b/Source/Modules/LangModelRelated/mgrLangModel.mm index 6e211979..7c29f6f9 100644 --- a/Source/Modules/LangModelRelated/mgrLangModel.mm +++ b/Source/Modules/LangModelRelated/mgrLangModel.mm @@ -34,6 +34,7 @@ static NSString *const kUserDataTemplateName = @"template-data"; static NSString *const kUserAssDataTemplateName = @"template-data"; static NSString *const kExcludedPhrasesvChewingTemplateName = @"template-exclude-phrases"; static NSString *const kPhraseReplacementTemplateName = @"template-phrases-replacement"; +static NSString *const kUserSymbolDataTemplateName = @"template-user-symbol-data"; static NSString *const kTemplateExtension = @".txt"; @implementation mgrLangModel @@ -117,6 +118,8 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing { gLangModelCHT.loadUserPhrases([[self userPhrasesDataPath:imeModeCHT] UTF8String], [[self excludedPhrasesDataPath:imeModeCHT] UTF8String]); gLangModelCHS.loadUserPhrases([[self userPhrasesDataPath:imeModeCHS] UTF8String], [[self excludedPhrasesDataPath:imeModeCHS] UTF8String]); + gLangModelCHT.loadUserSymbolData([[self userSymbolDataPath:imeModeCHT] UTF8String]); + gLangModelCHS.loadUserSymbolData([[self userSymbolDataPath:imeModeCHS] UTF8String]); } + (void)loadUserAssociatedPhrases @@ -205,33 +208,17 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing + (BOOL)checkIfUserLanguageModelFilesExist { - if (![self checkIfUserDataFolderExists]) { - return NO; - } - if (![self ensureFileExists:[self userPhrasesDataPath:imeModeCHS] populateWithTemplate:kUserDataTemplateName extension:kTemplateExtension]) { - return NO; - } - if (![self ensureFileExists:[self userPhrasesDataPath:imeModeCHT] populateWithTemplate:kUserDataTemplateName extension:kTemplateExtension]) { - return NO; - } - if (![self ensureFileExists:[self userAssociatedPhrasesDataPath:imeModeCHS] populateWithTemplate:kUserAssDataTemplateName extension:kTemplateExtension]) { - return NO; - } - if (![self ensureFileExists:[self userAssociatedPhrasesDataPath:imeModeCHT] populateWithTemplate:kUserAssDataTemplateName extension:kTemplateExtension]) { - return NO; - } - if (![self ensureFileExists:[self excludedPhrasesDataPath:imeModeCHS] populateWithTemplate:kExcludedPhrasesvChewingTemplateName extension:kTemplateExtension]) { - return NO; - } - if (![self ensureFileExists:[self excludedPhrasesDataPath:imeModeCHT] populateWithTemplate:kExcludedPhrasesvChewingTemplateName extension:kTemplateExtension]) { - return NO; - } - if (![self ensureFileExists:[self phraseReplacementDataPath:imeModeCHS] populateWithTemplate:kPhraseReplacementTemplateName extension:kTemplateExtension]) { - return NO; - } - if (![self ensureFileExists:[self phraseReplacementDataPath:imeModeCHT] populateWithTemplate:kPhraseReplacementTemplateName extension:kTemplateExtension]) { - return NO; - } + if (![self checkIfUserDataFolderExists]) return NO; + if (![self ensureFileExists:[self userPhrasesDataPath:imeModeCHS] populateWithTemplate:kUserDataTemplateName extension:kTemplateExtension]) return NO; + if (![self ensureFileExists:[self userPhrasesDataPath:imeModeCHT] populateWithTemplate:kUserDataTemplateName extension:kTemplateExtension]) return NO; + if (![self ensureFileExists:[self userAssociatedPhrasesDataPath:imeModeCHS] populateWithTemplate:kUserAssDataTemplateName extension:kTemplateExtension]) return NO; + if (![self ensureFileExists:[self userAssociatedPhrasesDataPath:imeModeCHT] populateWithTemplate:kUserAssDataTemplateName extension:kTemplateExtension]) return NO; + if (![self ensureFileExists:[self excludedPhrasesDataPath:imeModeCHS] populateWithTemplate:kExcludedPhrasesvChewingTemplateName extension:kTemplateExtension]) return NO; + if (![self ensureFileExists:[self excludedPhrasesDataPath:imeModeCHT] populateWithTemplate:kExcludedPhrasesvChewingTemplateName extension:kTemplateExtension]) return NO; + if (![self ensureFileExists:[self phraseReplacementDataPath:imeModeCHS] populateWithTemplate:kPhraseReplacementTemplateName extension:kTemplateExtension]) return NO; + if (![self ensureFileExists:[self phraseReplacementDataPath:imeModeCHT] populateWithTemplate:kPhraseReplacementTemplateName extension:kTemplateExtension]) return NO; + if (![self ensureFileExists:[self userSymbolDataPath:imeModeCHT] populateWithTemplate:kUserSymbolDataTemplateName extension:kTemplateExtension]) return NO; + if (![self ensureFileExists:[self userSymbolDataPath:imeModeCHS] populateWithTemplate:kUserSymbolDataTemplateName extension:kTemplateExtension]) return NO; return YES; } @@ -321,6 +308,12 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing return [[self dataFolderPath] stringByAppendingPathComponent:fileName]; } ++ (NSString *)userSymbolDataPath:(InputMode)mode; +{ + NSString *fileName = [mode isEqualToString:imeModeCHT] ? @"usersymbolphrases-cht.txt" : @"usersymbolphrases-chs.txt"; + return [[self dataFolderPath] stringByAppendingPathComponent:fileName]; +} + + (NSString *)userAssociatedPhrasesDataPath:(InputMode)mode; { NSString *fileName = [mode isEqualToString:imeModeCHT] ? @"associatedPhrases-cht.txt" : @"associatedPhrases-chs.txt"; From 83d30674e9096234037530dbd4da91e05d656ca7 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 14 Mar 2022 13:37:01 +0800 Subject: [PATCH 09/20] ctlIME // Add entry for editing UserSymbolLM data. --- Source/Modules/IMEModules/ctlInputMethod.swift | 7 ++++++- Source/Resources/Base.lproj/Localizable.strings | 2 +- Source/Resources/en.lproj/Localizable.strings | 3 ++- Source/Resources/ja.lproj/Localizable.strings | 3 ++- Source/Resources/zh-Hans.lproj/Localizable.strings | 3 ++- Source/Resources/zh-Hant.lproj/Localizable.strings | 3 ++- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Source/Modules/IMEModules/ctlInputMethod.swift b/Source/Modules/IMEModules/ctlInputMethod.swift index 5814d597..f38cd4f1 100644 --- a/Source/Modules/IMEModules/ctlInputMethod.swift +++ b/Source/Modules/IMEModules/ctlInputMethod.swift @@ -111,9 +111,10 @@ class ctlInputMethod: IMKInputController { menu.addItem(withTitle: NSLocalizedString("Edit User Phrases…", comment: ""), action: #selector(openUserPhrases(_:)), keyEquivalent: "") if optionKeyPressed { - menu.addItem(withTitle: NSLocalizedString("Edit Excluded Phrases", comment: ""), action: #selector(openExcludedPhrases(_:)), keyEquivalent: "") + menu.addItem(withTitle: NSLocalizedString("Edit Excluded Phrases…", comment: ""), action: #selector(openExcludedPhrases(_:)), keyEquivalent: "") menu.addItem(withTitle: NSLocalizedString("Edit Phrase Replacement Table…", comment: ""), action: #selector(openPhraseReplacement(_:)), keyEquivalent: "") menu.addItem(withTitle: NSLocalizedString("Edit Associated Phrases…", comment: ""), action: #selector(openAssociatedPhrases(_:)), keyEquivalent: "") + menu.addItem(withTitle: NSLocalizedString("Edit User Symbol & Emoji Data…", comment: ""), action: #selector(openUserSymbols(_:)), keyEquivalent: "") } if (optionKeyPressed || !Preferences.shouldAutoReloadUserDataFiles) { @@ -307,6 +308,10 @@ class ctlInputMethod: IMKInputController { open(userFileAt: mgrLangModel.excludedPhrasesDataPath(keyHandler.inputMode)) } + @objc func openUserSymbols(_ sender: Any?) { + open(userFileAt: mgrLangModel.userSymbolDataPath(keyHandler.inputMode)) + } + @objc func openPhraseReplacement(_ sender: Any?) { open(userFileAt: mgrLangModel.phraseReplacementDataPath(keyHandler.inputMode)) } diff --git a/Source/Resources/Base.lproj/Localizable.strings b/Source/Resources/Base.lproj/Localizable.strings index 778638a9..71eaffe8 100644 --- a/Source/Resources/Base.lproj/Localizable.strings +++ b/Source/Resources/Base.lproj/Localizable.strings @@ -19,7 +19,7 @@ "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 \"%@\"."; -"Edit Excluded Phrases" = "Edit Excluded Phrases…"; +"Edit Excluded Phrases…" = "Edit Excluded Phrases…"; "Half-Width Punctuation Mode" = "Half-Width Punctuation Mode"; "\"%@\" length must ≥ 2 for a user phrase." = "\"%@\" length must ≥ 2 for a user phrase."; "\"%@\" length should ≤ %d for a user phrase." = "\"%@\" length should ≤ %d for a user phrase."; diff --git a/Source/Resources/en.lproj/Localizable.strings b/Source/Resources/en.lproj/Localizable.strings index 778638a9..8ee2b1fd 100644 --- a/Source/Resources/en.lproj/Localizable.strings +++ b/Source/Resources/en.lproj/Localizable.strings @@ -19,7 +19,7 @@ "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 \"%@\"."; -"Edit Excluded Phrases" = "Edit Excluded Phrases…"; +"Edit Excluded Phrases…" = "Edit Excluded Phrases…"; "Half-Width Punctuation Mode" = "Half-Width Punctuation Mode"; "\"%@\" length must ≥ 2 for a user phrase." = "\"%@\" length must ≥ 2 for a user phrase."; "\"%@\" length should ≤ %d for a user phrase." = "\"%@\" length should ≤ %d for a user phrase."; @@ -51,6 +51,7 @@ "Apple Zhuyin Bopomofo" = "Apple Zhuyin Bopomofo (Standard)"; "Apple Zhuyin Eten" = "Apple Zhuyin Eten"; "Symbol & Emoji Input" = "Symbol & Emoji Input"; +"Edit User Symbol & Emoji Data…" = "Edit User Symbol & Emoji Data…"; // The followings are the category names used in the Symbol menu. "catCommonSymbols" = "CommonSymbols"; diff --git a/Source/Resources/ja.lproj/Localizable.strings b/Source/Resources/ja.lproj/Localizable.strings index 4dea78fb..55613cb5 100644 --- a/Source/Resources/ja.lproj/Localizable.strings +++ b/Source/Resources/ja.lproj/Localizable.strings @@ -19,7 +19,7 @@ "Reload User Phrases" = "ユーザー辞書を再び読込む"; "Unable to create the user phrase file." = "ユーザー辞書ファイルの作成は失敗しました。"; "Please check the permission at \"%@\"." = "「%@」に書き出す権限は不足らしい。"; -"Edit Excluded Phrases" = "辞書条目排除表を編集…"; +"Edit Excluded Phrases…" = "辞書条目排除表を編集…"; "Half-Width Punctuation Mode" = "半角句読モード"; "\"%@\" length must ≥ 2 for a user phrase." = "「%@」もう1つ文字のお選びを。"; "\"%@\" length should ≤ %d for a user phrase." = "「%@」文字数過剰で登録不可、%d 文字以内にして下さい。"; @@ -51,6 +51,7 @@ "Apple Zhuyin Bopomofo" = "Apple 注音ボポモフォ配列(大千標準)"; "Apple Zhuyin Eten" = "Apple 注音ボポモフォ配列(倚天伝統)"; "Symbol & Emoji Input" = "符号&絵文字入力"; +"Edit User Symbol & Emoji Data…" = "ユーザー符号&絵文字辞書を編集…"; // The followings are the category names used in the Symbol menu. "catCommonSymbols" = "常用"; diff --git a/Source/Resources/zh-Hans.lproj/Localizable.strings b/Source/Resources/zh-Hans.lproj/Localizable.strings index 01ce1d54..fbc66ba3 100644 --- a/Source/Resources/zh-Hans.lproj/Localizable.strings +++ b/Source/Resources/zh-Hans.lproj/Localizable.strings @@ -19,7 +19,7 @@ "Reload User Phrases" = "重载自订语汇"; "Unable to create the user phrase file." = "无法创建自订语汇档案。"; "Please check the permission at \"%@\"." = "请检查此处的存取权限:\"%@\"."; -"Edit Excluded Phrases" = "编辑要滤除的语汇…"; +"Edit Excluded Phrases…" = "编辑要滤除的语汇…"; "Half-Width Punctuation Mode" = "半角标点模式"; "\"%@\" length must ≥ 2 for a user phrase." = "「%@」字数不足以自订语汇。"; "\"%@\" length should ≤ %d for a user phrase." = "「%@」字数超过 %d、无法自订。"; @@ -51,6 +51,7 @@ "Apple Zhuyin Bopomofo" = "Apple 标准注音键盘布局"; "Apple Zhuyin Eten" = "Apple 倚天注音键盘布局"; "Symbol & Emoji Input" = "符号&绘文字输入"; +"Edit User Symbol & Emoji Data…" = "编辑自订符号&绘文字资料…"; // The followings are the category names used in the Symbol menu. "catCommonSymbols" = "常用"; diff --git a/Source/Resources/zh-Hant.lproj/Localizable.strings b/Source/Resources/zh-Hant.lproj/Localizable.strings index dd6aec31..a45ea0ce 100644 --- a/Source/Resources/zh-Hant.lproj/Localizable.strings +++ b/Source/Resources/zh-Hant.lproj/Localizable.strings @@ -19,7 +19,7 @@ "Reload User Phrases" = "重載自訂語彙"; "Unable to create the user phrase file." = "無法創建自訂語彙檔案。"; "Please check the permission at \"%@\"." = "請檢查此處的存取權限:\"%@\"."; -"Edit Excluded Phrases" = "編輯要濾除的語彙…"; +"Edit Excluded Phrases…" = "編輯要濾除的語彙…"; "Half-Width Punctuation Mode" = "半形標點模式"; "\"%@\" length must ≥ 2 for a user phrase." = "「%@」字數不足以自訂語彙。"; "\"%@\" length should ≤ %d for a user phrase." = "「%@」字數超過 %d、無法自訂。"; @@ -51,6 +51,7 @@ "Apple Zhuyin Bopomofo" = "Apple 標準注音鍵盤佈局"; "Apple Zhuyin Eten" = "Apple 倚天注音鍵盤佈局"; "Symbol & Emoji Input" = "符號&繪文字輸入"; +"Edit User Symbol & Emoji Data…" = "編輯自訂符號&繪文字資料…"; // The followings are the category names used in the Symbol menu. "catCommonSymbols" = "常用"; From cb562fb4b6ec0e6f2ea61dcacea0f92f0887e80d Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 14 Mar 2022 18:32:01 +0800 Subject: [PATCH 10/20] KeyHandler // Re-allow Ctrl+CMD+Enter BPMF commit. - This design is innocent. --- Source/Modules/ControllerModules/KeyHandler.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index bc72647d..864e0dc9 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -526,7 +526,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; // MARK: Enter if ([input isEnter]) { if ([input isControlHold]) { - if (![input isCommandHold]) { + if (ctlInputMethod.areWeUsingOurOwnPhraseEditor || [input isCommandHold]) { return [self _handleCtrlEnterWithState:state stateCallback:stateCallback errorCallback:errorCallback]; } } From 4c048f56f2017b5f2bc430b2d811ccd0c785591e Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 14 Mar 2022 22:51:11 +0800 Subject: [PATCH 11/20] IME // Re-Enable CMD+W for Non-Modal Windows. --- Source/WindowNIBs/Base.lproj/MainMenu.xib | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/WindowNIBs/Base.lproj/MainMenu.xib b/Source/WindowNIBs/Base.lproj/MainMenu.xib index ccea8b9c..2c5e937c 100644 --- a/Source/WindowNIBs/Base.lproj/MainMenu.xib +++ b/Source/WindowNIBs/Base.lproj/MainMenu.xib @@ -23,6 +23,17 @@ + From 8f9737c4e90d9fc8ab095ad4eb4805763fb21a94 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 15 Mar 2022 21:09:10 +0800 Subject: [PATCH 12/20] ctlPrefWindow // Format tweaks & remove useless expressions. --- Source/WindowControllers/ctlPrefWindow.swift | 38 ++++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/Source/WindowControllers/ctlPrefWindow.swift b/Source/WindowControllers/ctlPrefWindow.swift index 689839d4..89dc2eb7 100644 --- a/Source/WindowControllers/ctlPrefWindow.swift +++ b/Source/WindowControllers/ctlPrefWindow.swift @@ -211,27 +211,25 @@ extension RangeReplaceableCollection where Element: Hashable { @IBAction func changeSelectionKeyAction(_ sender: Any) { guard let keys = (sender as AnyObject).stringValue?.trimmingCharacters(in: .whitespacesAndNewlines).charDeDuplicate else { - return + return + } + do { + try Preferences.validate(candidateKeys: keys) + Preferences.candidateKeys = keys + selectionKeyComboBox.stringValue = Preferences.candidateKeys + } + catch Preferences.CandidateKeyError.empty { + selectionKeyComboBox.stringValue = Preferences.candidateKeys + } + catch { + if let window = window { + let alert = NSAlert(error: error) + alert.beginSheetModal(for: window) { response in + self.selectionKeyComboBox.stringValue = Preferences.candidateKeys } - do { - try Preferences.validate(candidateKeys: keys) - Preferences.candidateKeys = keys - } - catch Preferences.CandidateKeyError.empty { - selectionKeyComboBox.stringValue = Preferences.candidateKeys - } - catch { - if let window = window { - let alert = NSAlert(error: error) - alert.beginSheetModal(for: window) { response in - self.selectionKeyComboBox.stringValue = Preferences.candidateKeys - } - clsSFX.beep() - } - } - - selectionKeyComboBox.stringValue = keys - Preferences.candidateKeys = keys + clsSFX.beep() + } + } } } From 7da87b39ca4d5ba4572443ebebbcdbccce22e61d Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 15 Mar 2022 21:17:54 +0800 Subject: [PATCH 13/20] LMConsolidator // Move pragma check to the head of the consolidator. --- Source/Modules/FileHandlers/LMConsolidator.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Modules/FileHandlers/LMConsolidator.mm b/Source/Modules/FileHandlers/LMConsolidator.mm index cd4fd9b3..0c26866d 100644 --- a/Source/Modules/FileHandlers/LMConsolidator.mm +++ b/Source/Modules/FileHandlers/LMConsolidator.mm @@ -72,7 +72,8 @@ bool LMConsolidator::FixEOF(const char *path) // CONTENT CONSOLIDATOR. CREDIT: Shiki Suen. bool LMConsolidator::ConsolidateContent(const char *path, bool shouldCheckPragma) { - if (LMConsolidator::CheckPragma(path) && shouldCheckPragma){ + bool pragmaCheckResult = LMConsolidator::CheckPragma(path); + if (pragmaCheckResult && shouldCheckPragma){ return true; } @@ -107,7 +108,7 @@ bool LMConsolidator::ConsolidateContent(const char *path, bool shouldCheckPragma std::reverse(vecEntry.begin(), vecEntry.end()); // 再顛倒回來。 // 統整完畢。開始將統整過的內容寫入檔案。 ofstream zfdContentConsolidatorOutput(path); // 這裡是要從頭開始重寫檔案內容,所以不需要「 ios_base::app 」。 - if (!LMConsolidator::CheckPragma(path)){ + if (!pragmaCheckResult){ zfdContentConsolidatorOutput< Date: Wed, 16 Mar 2022 22:11:50 +0800 Subject: [PATCH 14/20] ctlPrefWindow // Use WindowDidLoad() instead. - deprecating AwakeFromNIB(). --- Source/WindowControllers/ctlPrefWindow.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/WindowControllers/ctlPrefWindow.swift b/Source/WindowControllers/ctlPrefWindow.swift index 89dc2eb7..3954266f 100644 --- a/Source/WindowControllers/ctlPrefWindow.swift +++ b/Source/WindowControllers/ctlPrefWindow.swift @@ -41,7 +41,9 @@ extension RangeReplaceableCollection where Element: Hashable { var currentLanguageSelectItem: NSMenuItem? = nil - override func awakeFromNib() { + override func windowDidLoad() { + super.windowDidLoad() + let languages = ["auto", "en", "zh-Hans", "zh-Hant", "ja"] var autoMUISelectItem: NSMenuItem? = nil var chosenLanguageItem: NSMenuItem? = nil From f36ce516b9df1c7498230df2d301ce616af64529 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 16 Mar 2022 23:35:16 +0800 Subject: [PATCH 15/20] PrefWindow // Enable Windows Aero Glass FX. --- Source/Modules/AppDelegate.swift | 1 + .../WindowNIBs/Base.lproj/frmPrefWindow.xib | 38 +++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Source/Modules/AppDelegate.swift b/Source/Modules/AppDelegate.swift index 4f9aca18..2f747e21 100644 --- a/Source/Modules/AppDelegate.swift +++ b/Source/Modules/AppDelegate.swift @@ -199,6 +199,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega ctlPrefWindowInstance?.window?.center() ctlPrefWindowInstance?.window?.orderFrontRegardless() // 逼著屬性視窗往最前方顯示 ctlPrefWindowInstance?.window?.level = .statusBar + ctlPrefWindowInstance?.window?.titlebarAppearsTransparent = true } // New About Window diff --git a/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib b/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib index e59f26c0..4fc4b409 100644 --- a/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib +++ b/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib @@ -1,8 +1,8 @@ - + - + @@ -20,15 +20,15 @@ - - - - - + + + + + - + @@ -328,11 +328,11 @@ - + - + @@ -575,11 +575,11 @@ - + - + @@ -635,11 +635,11 @@ - + - + @@ -662,13 +662,13 @@ - Regarding On-Screen Keyboard Viewer Support: + Regarding On-Screen Keyboard Viewer Support: Since v1.3.2, vChewing supports on-screen keyboard by supporting "Apple Zhuyin Bopomofo" and "Apple Zhuyin Eten" alphanumeric layout. Theoreotically, these two dynamic layouts work with all types of Apple physical keyboards, and you can report failure cases through macOS Feedback Assistant app if macOS built-in Zhuyin / Eten-Zhuyin Input Method fails from working with your non-US keyboard. HOWEVER, choosing such dynamic alphanumeric layouts REQUIRING THAT you have to choose the Bopomofo layout above to Standard (Microsoft / Dachen) since the Bopomofo / Eten layout support in this case is already finished by the macOS system. - Note that If you have chosen those "vChewing****" Alphanumerical layouts, then the Bopomofo layouts MUST MATCH the choices. + Note that If you have chosen those "vChewing****" Alphanumerical layouts, then the Bopomofo layouts MUST MATCH the choices. @@ -770,13 +770,13 @@ - - + + - + From 9cac7ecc47d8e79fb0a0b4868110e0e9c182945a Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Thu, 17 Mar 2022 11:14:51 +0800 Subject: [PATCH 16/20] NotifierUI // Enable Windows Aero Glass FX. --- Source/UI/NotifierUI/NotifierController.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/UI/NotifierUI/NotifierController.swift b/Source/UI/NotifierUI/NotifierController.swift index e8c8ff15..bc9b7087 100644 --- a/Source/UI/NotifierUI/NotifierController.swift +++ b/Source/UI/NotifierUI/NotifierController.swift @@ -100,10 +100,15 @@ public class NotifierController: NSWindowController, NotifierWindowDelegate { windowRect.origin.x = screenRect.maxX - windowRect.width - 10 windowRect.origin.y = screenRect.maxY - windowRect.height - 10 let styleMask: NSWindow.StyleMask = [.fullSizeContentView, .titled] - - - + + let transparentVisualEffect = NSVisualEffectView() + transparentVisualEffect.blendingMode = .behindWindow + transparentVisualEffect.state = .active + transparentVisualEffect.material = .dark + let panel = NotifierWindow(contentRect: windowRect, styleMask: styleMask, backing: .buffered, defer: false) + panel.contentView = transparentVisualEffect + panel.isMovableByWindowBackground = true panel.level = NSWindow.Level(Int(kCGPopUpMenuWindowLevel)) panel.hasShadow = true panel.backgroundColor = backgroundColor From 9f7a136aee951e938b4941b3dcad4946a123cebc Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 15 Mar 2022 12:23:38 +0800 Subject: [PATCH 17/20] Repo // Add a script to uninstall the IME (for devs). --- uninstall.sh | 36 ++++++++++++++++++++++++++++++ vChewing.xcodeproj/project.pbxproj | 4 ++++ 2 files changed, 40 insertions(+) create mode 100644 uninstall.sh diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 00000000..2c519950 --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +# Here's how to uninstall this input method: + +# Suppose that this IME is properly installed, you remove the following possible assets: + +rm -rf ~/Library/Input\ Methods/vChewing.app +rm -rf ~/Library/Keyboard\ Layouts/vChewingKeyLayout.bundle +rm ~/Library/Keyboard\ Layouts/vChewing\ MiTAC.keylayout +rm ~/Library/Keyboard\ Layouts/vChewing\ IBM.keylayout +rm ~/Library/Keyboard\ Layouts/vChewing\ FakeSeigyou.keylayout +rm ~/Library/Keyboard\ Layouts/vChewing\ ETen.keylayout +rm ~/Library/Keyboard\ Layouts/vChewing\ Dachen.keylayout + +# Also user phrase folder: +rm -rf ~/Library/Application\ Support/vChewing/ + +# Also the IME configuration file: +rm -rf ~/Library/Preferences/org.atelierInmu.inputmethod.vChewing.plist + +# If you have ever tried the initial alpha builds of vChewing, you also remove: +rm -rf ~/Library/Preferences/org.openvanilla.inputmethod.vChewing.plist + +# If it is not properly installed, you also check the following possible paths to remove: +sudo rm -rf /Library/Input\ Methods/vChewing.app +sudo rm -rf /Library/Keyboard\ Layouts/vChewingKeyLayout.bundle +sudo rm -rf /Library/Keyboard\ Layouts/vChewing\ MiTAC.keylayout +sudo rm -rf /Library/Keyboard\ Layouts/vChewing\ IBM.keylayout +sudo rm -rf /Library/Keyboard\ Layouts/vChewing\ FakeSeigyou.keylayout +sudo rm -rf /Library/Keyboard\ Layouts/vChewing\ ETen.keylayout +sudo rm -rf /Library/Keyboard\ Layouts/vChewing\ Dachen.keylayout + +# P.S.: The "vChewingKeyLayout.bundle" and keylayout files are deployed by the pkg installer. They are not hard-requirements for running vChewing, but providing extended on-screen keyboard for MiTAC, IBM, FakeSeigyou phonetic layouts. + +# EOF. + diff --git a/vChewing.xcodeproj/project.pbxproj b/vChewing.xcodeproj/project.pbxproj index bfa8cc30..b8f27959 100644 --- a/vChewing.xcodeproj/project.pbxproj +++ b/vChewing.xcodeproj/project.pbxproj @@ -45,6 +45,7 @@ 5BBBB77527AED70B0023B93A /* MenuIcon-SCVIM.png in Resources */ = {isa = PBXBuildFile; fileRef = 5BBBB77127AED70B0023B93A /* MenuIcon-SCVIM.png */; }; 5BBBB77627AED70B0023B93A /* MenuIcon-TCVIM.png in Resources */ = {isa = PBXBuildFile; fileRef = 5BBBB77227AED70B0023B93A /* MenuIcon-TCVIM.png */; }; 5BBBB77A27AEDC690023B93A /* clsSFX.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BBBB77927AEDC690023B93A /* clsSFX.swift */; }; + 5BC2652227E04B7E00700291 /* uninstall.sh in Resources */ = {isa = PBXBuildFile; fileRef = 5BC2652127E04B7B00700291 /* uninstall.sh */; }; 5BD05B8127B22F3C004C4F1D /* char-kanji-cns.txt in Resources */ = {isa = PBXBuildFile; fileRef = 5BD05B8027B22F3C004C4F1D /* char-kanji-cns.txt */; }; 5BD05BCA27B2A43D004C4F1D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6A2E40F5253A69DA00D1AE1D /* Images.xcassets */; }; 5BD05C5D27B2BBA9004C4F1D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5BD05C5B27B2BBA9004C4F1D /* Main.storyboard */; }; @@ -214,6 +215,7 @@ 5BBBB77727AEDB290023B93A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/MainMenu.strings; sourceTree = ""; }; 5BBBB77927AEDC690023B93A /* clsSFX.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = clsSFX.swift; sourceTree = ""; }; 5BBD627827B6C4D900271480 /* Update-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Update-Info.plist"; sourceTree = ""; }; + 5BC2652127E04B7B00700291 /* uninstall.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; lineEnding = 0; path = uninstall.sh; sourceTree = ""; }; 5BD05B8027B22F3C004C4F1D /* char-kanji-cns.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "char-kanji-cns.txt"; path = "Data/components/common/char-kanji-cns.txt"; sourceTree = ""; }; 5BD05BB827B2A429004C4F1D /* vChewingPhraseEditor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = vChewingPhraseEditor.app; sourceTree = BUILT_PRODUCTS_DIR; }; 5BD05BC627B2A42A004C4F1D /* vChewingPhraseEditor.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = vChewingPhraseEditor.entitlements; sourceTree = ""; }; @@ -337,6 +339,7 @@ 5B18BA7527C7BF6D0056EB19 /* MiscRootFiles */ = { isa = PBXGroup; children = ( + 5BC2652127E04B7B00700291 /* uninstall.sh */, 5B18BA6F27C7BD8B0056EB19 /* LICENSE-CHS.txt */, 5B18BA7427C7BD8C0056EB19 /* LICENSE-CHT.txt */, 5B18BA7327C7BD8C0056EB19 /* LICENSE-JPN.txt */, @@ -944,6 +947,7 @@ 5BBBB77627AED70B0023B93A /* MenuIcon-TCVIM.png in Resources */, 6A187E2616004C5900466B2E /* MainMenu.xib in Resources */, 5BBBB75F27AED54C0023B93A /* Beep.m4a in Resources */, + 5BC2652227E04B7E00700291 /* uninstall.sh in Resources */, 5BAD0CD527D701F6003D127F /* vChewingKeyLayout.bundle in Resources */, 5B2DB16F27AF6891006D874E /* data-chs.txt in Resources */, ); From 864a4e680cc17983f8132bc02bbd2aa867d6600f Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 14 Mar 2022 20:52:43 +0800 Subject: [PATCH 18/20] AboutWindow // Add wiki link. --- Source/WindowControllers/ctlAboutWindow.swift | 7 ++++++- Source/WindowNIBs/Base.lproj/frmAboutWindow.xib | 17 +++++++++++++++-- .../Resources/Base.lproj/frmAboutWindow.xib | 14 ++++++++++++-- UserPhraseEditor/ctlAboutWindow.swift | 7 ++++++- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/Source/WindowControllers/ctlAboutWindow.swift b/Source/WindowControllers/ctlAboutWindow.swift index 4fd33f79..c144e201 100644 --- a/Source/WindowControllers/ctlAboutWindow.swift +++ b/Source/WindowControllers/ctlAboutWindow.swift @@ -42,5 +42,10 @@ import Cocoa } appVersionLabel.stringValue = String(format: "%@ Build %@", versionString, installingVersion) } - + + @IBAction func btnWiki(_ sender: NSButton) { + if let url = URL(string: "https://gitee.com/vchewing/vChewing-macOS/wikis") { + NSWorkspace.shared.open(url) + } + } } diff --git a/Source/WindowNIBs/Base.lproj/frmAboutWindow.xib b/Source/WindowNIBs/Base.lproj/frmAboutWindow.xib index 1700100f..33c00d01 100644 --- a/Source/WindowNIBs/Base.lproj/frmAboutWindow.xib +++ b/Source/WindowNIBs/Base.lproj/frmAboutWindow.xib @@ -1,8 +1,8 @@ - + - + @@ -156,12 +156,23 @@ DQ + + @@ -182,12 +193,14 @@ DQ + + diff --git a/UserPhraseEditor/Resources/Base.lproj/frmAboutWindow.xib b/UserPhraseEditor/Resources/Base.lproj/frmAboutWindow.xib index e5952bda..bb45461e 100644 --- a/UserPhraseEditor/Resources/Base.lproj/frmAboutWindow.xib +++ b/UserPhraseEditor/Resources/Base.lproj/frmAboutWindow.xib @@ -1,8 +1,8 @@ - + - + @@ -155,8 +155,16 @@ DQ + + @@ -181,6 +189,7 @@ DQ + @@ -191,6 +200,7 @@ DQ + diff --git a/UserPhraseEditor/ctlAboutWindow.swift b/UserPhraseEditor/ctlAboutWindow.swift index 4fd33f79..c144e201 100644 --- a/UserPhraseEditor/ctlAboutWindow.swift +++ b/UserPhraseEditor/ctlAboutWindow.swift @@ -42,5 +42,10 @@ import Cocoa } appVersionLabel.stringValue = String(format: "%@ Build %@", versionString, installingVersion) } - + + @IBAction func btnWiki(_ sender: NSButton) { + if let url = URL(string: "https://gitee.com/vchewing/vChewing-macOS/wikis") { + NSWorkspace.shared.open(url) + } + } } From cc247d79fe501b827e540a44eaa683c7c57c9b5a Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 14 Mar 2022 21:35:13 +0800 Subject: [PATCH 19/20] Bump version to 1.3.9 Build 1930. --- Update-Info.plist | 4 ++-- vChewing.pkgproj | 30 +++++++++++++++--------------- vChewing.xcodeproj/project.pbxproj | 24 ++++++++++++------------ 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Update-Info.plist b/Update-Info.plist index b6f79ade..111d259b 100644 --- a/Update-Info.plist +++ b/Update-Info.plist @@ -7,8 +7,8 @@ UpdateInfoSite https://gitee.com/vChewing/vChewing-macOS/releases CFBundleVersion - 1929 + 1930 CFBundleShortVersionString - 1.3.8 + 1.3.9 diff --git a/vChewing.pkgproj b/vChewing.pkgproj index fc37647e..5065dbca 100644 --- a/vChewing.pkgproj +++ b/vChewing.pkgproj @@ -724,7 +724,7 @@ USE_HFS+_COMPRESSION VERSION - 1.3.8 + 1.3.9 TYPE 0 @@ -944,11 +944,11 @@ LANGUAGE - Simplified Chinese + Traditional Chinese VALUE PATH - LICENSE-CHS.txt + LICENSE-CHT.txt PATH_TYPE 1 @@ -966,11 +966,11 @@ LANGUAGE - Traditional Chinese + Simplified Chinese VALUE PATH - LICENSE-CHT.txt + LICENSE-CHS.txt PATH_TYPE 1 @@ -1001,9 +1001,9 @@ LANGUAGE - Traditional Chinese + Simplified Chinese VALUE - 威注音輸入法 + 威注音输入法 LANGUAGE @@ -1013,9 +1013,9 @@ LANGUAGE - Simplified Chinese + Traditional Chinese VALUE - 威注音输入法 + 威注音輸入法 @@ -1052,11 +1052,11 @@ LANGUAGE - Traditional Chinese + Simplified Chinese SECONDARY_VALUE - 至少 macOS 10.11.5 方可滿足威注音對系統內的萬國碼版本支援的需要。 + 至少 macOS 10.11.5 方可满足威注音对系统内的万国码版本支援的需要。 VALUE - 作業系統版本太舊 + 作业系统版本太旧 LANGUAGE @@ -1068,11 +1068,11 @@ LANGUAGE - Simplified Chinese + Traditional Chinese SECONDARY_VALUE - 至少 macOS 10.11.5 方可满足威注音对系统内的万国码版本支援的需要。 + 至少 macOS 10.11.5 方可滿足威注音對系統內的萬國碼版本支援的需要。 VALUE - 作业系统版本太旧 + 作業系統版本太舊 NAME diff --git a/vChewing.xcodeproj/project.pbxproj b/vChewing.xcodeproj/project.pbxproj index b8f27959..c68dc2bd 100644 --- a/vChewing.xcodeproj/project.pbxproj +++ b/vChewing.xcodeproj/project.pbxproj @@ -1241,7 +1241,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1929; + CURRENT_PROJECT_VERSION = 1930; DEBUG_INFORMATION_FORMAT = dwarf; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; @@ -1264,7 +1264,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.11.5; - MARKETING_VERSION = 1.3.8; + MARKETING_VERSION = 1.3.9; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = org.atelierInmu.vChewing.vChewingPhraseEditor; @@ -1297,7 +1297,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1929; + CURRENT_PROJECT_VERSION = 1930; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -1316,7 +1316,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.11.5; - MARKETING_VERSION = 1.3.8; + MARKETING_VERSION = 1.3.9; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = org.atelierInmu.vChewing.vChewingPhraseEditor; @@ -1431,7 +1431,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1929; + CURRENT_PROJECT_VERSION = 1930; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -1466,7 +1466,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.11.5; - MARKETING_VERSION = 1.3.8; + MARKETING_VERSION = 1.3.9; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = org.atelierInmu.inputmethod.vChewing; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1499,7 +1499,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1929; + CURRENT_PROJECT_VERSION = 1930; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = ""; @@ -1529,7 +1529,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.11.5; - MARKETING_VERSION = 1.3.8; + MARKETING_VERSION = 1.3.9; PRODUCT_BUNDLE_IDENTIFIER = org.atelierInmu.inputmethod.vChewing; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1613,7 +1613,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1929; + CURRENT_PROJECT_VERSION = 1930; DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; @@ -1638,7 +1638,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.11.5; - MARKETING_VERSION = 1.3.8; + MARKETING_VERSION = 1.3.9; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = "org.atelierInmu.vChewing.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1666,7 +1666,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1929; + CURRENT_PROJECT_VERSION = 1930; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -1686,7 +1686,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.11.5; - MARKETING_VERSION = 1.3.8; + MARKETING_VERSION = 1.3.9; PRODUCT_BUNDLE_IDENTIFIER = "org.atelierInmu.vChewing.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; From d0fa6748a43770fecd750313aa868476dd20d502 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 16 Mar 2022 21:23:18 +0800 Subject: [PATCH 20/20] Update Data - 20220317 --- Source/Data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Data b/Source/Data index e4143b8b..3fc29bcb 160000 --- a/Source/Data +++ b/Source/Data @@ -1 +1 @@ -Subproject commit e4143b8b79e3cf1acde79eba68c5c8e61349090e +Subproject commit 3fc29bcbc321f412e8a1656774fdae3009f01ac3