From 25d20f4822df9536b2a3c6d0de145801d84b2819 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 8 Mar 2022 22:55:18 +0800 Subject: [PATCH 1/8] =?UTF-8?q?UPE=20//=20Add=20support=20of=20converting?= =?UTF-8?q?=20"=E3=84=98=E3=84=9F".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UserPhraseEditor/StringExtension.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/UserPhraseEditor/StringExtension.swift b/UserPhraseEditor/StringExtension.swift index fc3ca498..0db07ae6 100644 --- a/UserPhraseEditor/StringExtension.swift +++ b/UserPhraseEditor/StringExtension.swift @@ -222,6 +222,7 @@ extension String { varLineData.regReplace(pattern: "cai", replaceWith: "ㄘㄞ") varLineData.regReplace(pattern: "can", replaceWith: "ㄘㄢ") varLineData.regReplace(pattern: "cao", replaceWith: "ㄘㄠ") + varLineData.regReplace(pattern: "cei", replaceWith: "ㄘㄟ") varLineData.regReplace(pattern: "cen", replaceWith: "ㄘㄣ") varLineData.regReplace(pattern: "cha", replaceWith: "ㄔㄚ") varLineData.regReplace(pattern: "che", replaceWith: "ㄔㄜ") From 00070ea65b2ed0db12c4363a663922e2d654af88 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 9 Mar 2022 11:30:40 +0800 Subject: [PATCH 2/8] Voltaire // Differentiate Chinese fallback fonts per inputMode. - Thanks to Dr. Ken Lunde's suggestion. Note that this only works with macOS 12 Monterey and later macOS releases. --- Source/UI/CandidateUI/HorizontalCandidateController.swift | 8 ++++++++ Source/UI/CandidateUI/VerticalCandidateController.swift | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/Source/UI/CandidateUI/HorizontalCandidateController.swift b/Source/UI/CandidateUI/HorizontalCandidateController.swift index a8faeb52..bab60327 100644 --- a/Source/UI/CandidateUI/HorizontalCandidateController.swift +++ b/Source/UI/CandidateUI/HorizontalCandidateController.swift @@ -132,6 +132,14 @@ fileprivate class HorizontalCandidateView: NSView { } else { NSColor.controlBackgroundColor.setFill() } + switch ctlInputMethod.currentKeyHandler.inputMode { + case InputMode.imeModeCHS: + if #available(macOS 12.0, *) {activeCandidateAttr[.languageIdentifier] = "zh-Hans" as AnyObject} + case InputMode.imeModeCHT: + if #available(macOS 12.0, *) {activeCandidateAttr[.languageIdentifier] = "zh-Hant" as AnyObject} + default: + break + } NSBezierPath.fill(rctCandidateArea) (keyLabels[index] as NSString).draw(in: rctLabel, withAttributes: activeCandidateIndexAttr) (displayedCandidates[index] as NSString).draw(in: rctCandidatePhrase, withAttributes: activeCandidateAttr) diff --git a/Source/UI/CandidateUI/VerticalCandidateController.swift b/Source/UI/CandidateUI/VerticalCandidateController.swift index 64b67eae..da384088 100644 --- a/Source/UI/CandidateUI/VerticalCandidateController.swift +++ b/Source/UI/CandidateUI/VerticalCandidateController.swift @@ -138,6 +138,14 @@ fileprivate class VerticalCandidateView: NSView { } else { NSColor.controlBackgroundColor.setFill() } + switch ctlInputMethod.currentKeyHandler.inputMode { + case InputMode.imeModeCHS: + if #available(macOS 12.0, *) {activeCandidateAttr[.languageIdentifier] = "zh-Hans" as AnyObject} + case InputMode.imeModeCHT: + if #available(macOS 12.0, *) {activeCandidateAttr[.languageIdentifier] = "zh-Hant" as AnyObject} + default: + break + } NSBezierPath.fill(rctCandidateArea) (keyLabels[index] as NSString).draw(in: rctLabel, withAttributes: activeCandidateIndexAttr) (displayedCandidates[index] as NSString).draw(in: rctCandidatePhrase, withAttributes: activeCandidateAttr) From 20a0a7c9bbc6b229ae7f9fddeabce7ef8f262978 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 9 Mar 2022 12:07:34 +0800 Subject: [PATCH 3/8] ctlIME // Disable Sarasa Gothic dependency on macOS 12 and later. --- Source/Modules/IMEModules/ctlInputMethod.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Modules/IMEModules/ctlInputMethod.swift b/Source/Modules/IMEModules/ctlInputMethod.swift index 9b306bbf..ae1f6a90 100644 --- a/Source/Modules/IMEModules/ctlInputMethod.swift +++ b/Source/Modules/IMEModules/ctlInputMethod.swift @@ -563,7 +563,9 @@ extension ctlInputMethod { func candidateFont(name: String?, size: CGFloat) -> NSFont { let currentMUIFont = (keyHandler.inputMode == InputMode.imeModeCHS) ? "Sarasa Term Slab SC" : "Sarasa Term Slab TC" - let finalReturnFont = NSFont(name: currentMUIFont, size: size) ?? NSFont.systemFont(ofSize: size) + var finalReturnFont = NSFont(name: currentMUIFont, size: size) ?? NSFont.systemFont(ofSize: size) + // 對更紗黑體的依賴到 macOS 11 Big Sur 為止。macOS 12 Monterey 開始則依賴系統內建的函數使用蘋方來處理。 + if #available(macOS 12.0, *) {finalReturnFont = NSFont.systemFont(ofSize: size)} if let name = name { return NSFont(name: name, size: size) ?? finalReturnFont } From 390ef0dbe420545cbf71b38a2677fdea2871de11 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 9 Mar 2022 14:06:33 +0800 Subject: [PATCH 4/8] pkg // Make sure it always clean up old files first during installation. --- Installer/pkgPostInstall.sh | 3 - Installer/pkgPreInstall.sh | 9 +++ vChewing.pkgproj | 128 +++++++++++++++++++++++++++++++----- 3 files changed, 122 insertions(+), 18 deletions(-) delete mode 100644 Installer/pkgPostInstall.sh create mode 100644 Installer/pkgPreInstall.sh diff --git a/Installer/pkgPostInstall.sh b/Installer/pkgPostInstall.sh deleted file mode 100644 index 737f7c4a..00000000 --- a/Installer/pkgPostInstall.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -killall vChewing -rm -rf ~/Library/Input\ Methods/vChewing.app diff --git a/Installer/pkgPreInstall.sh b/Installer/pkgPreInstall.sh new file mode 100644 index 00000000..82d041b5 --- /dev/null +++ b/Installer/pkgPreInstall.sh @@ -0,0 +1,9 @@ +#!/bin/sh +killall vChewing +rm -rf ~/Library/Input\ Methods/vChewing.app +rm -rf ~/Library/Keyboard\ Layouts/vChewingKeyLayout.bundle +rm -rf ~/Library/Keyboard\ Layouts/vChewing\ Dachen.keylayout +rm -rf ~/Library/Keyboard\ Layouts/vChewing\ ETen.keylayout +rm -rf ~/Library/Keyboard\ Layouts/vChewing\ FakeSeigyou.keylayout +rm -rf ~/Library/Keyboard\ Layouts/vChewing\ IBM.keylayout +rm -rf ~/Library/Keyboard\ Layouts/vChewing\ MiTAC.keylayout diff --git a/vChewing.pkgproj b/vChewing.pkgproj index 8d355fef..9e79e755 100644 --- a/vChewing.pkgproj +++ b/vChewing.pkgproj @@ -52,6 +52,22 @@ UID 0 + + CHILDREN + + GID + 0 + PATH + Audio + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + CHILDREN @@ -68,6 +84,22 @@ UID 0 + + CHILDREN + + GID + 0 + PATH + ColorPickers + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + CHILDREN @@ -116,6 +148,22 @@ UID 0 + + CHILDREN + + GID + 80 + PATH + Fonts + PATH_TYPE + 0 + PERMISSIONS + 1021 + TYPE + 1 + UID + 0 + CHILDREN @@ -524,6 +572,56 @@ UID 0 + + CHILDREN + + + CHILDREN + + + CHILDREN + + GID + 0 + PATH + Extensions + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + GID + 0 + PATH + Library + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + GID + 0 + PATH + System + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + CHILDREN @@ -594,7 +692,7 @@ PREINSTALL_PATH PATH - Installer/pkgPostInstall.sh + Installer/pkgPreInstall.sh PATH_TYPE 1 @@ -846,11 +944,11 @@ LANGUAGE - Simplified Chinese + Traditional Chinese VALUE PATH - LICENSE-CHS.txt + LICENSE-CHT.txt PATH_TYPE 1 @@ -868,11 +966,11 @@ LANGUAGE - Traditional Chinese + Simplified Chinese VALUE PATH - LICENSE-CHT.txt + LICENSE-CHS.txt PATH_TYPE 1 @@ -903,9 +1001,9 @@ LANGUAGE - Traditional Chinese + Simplified Chinese VALUE - 威注音輸入法 + 威注音输入法 LANGUAGE @@ -915,9 +1013,9 @@ LANGUAGE - Simplified Chinese + Traditional Chinese VALUE - 威注音输入法 + 威注音輸入法 @@ -954,11 +1052,11 @@ LANGUAGE - Traditional Chinese + Simplified Chinese SECONDARY_VALUE - 至少 macOS 10.11.5 方可滿足威注音對系統內的萬國碼版本支援的需要。 + 至少 macOS 10.11.5 方可满足威注音对系统内的万国码版本支援的需要。 VALUE - 作業系統版本太舊 + 作业系统版本太旧 LANGUAGE @@ -970,11 +1068,11 @@ LANGUAGE - Simplified Chinese + Traditional Chinese SECONDARY_VALUE - 至少 macOS 10.11.5 方可满足威注音对系统内的万国码版本支援的需要。 + 至少 macOS 10.11.5 方可滿足威注音對系統內的萬國碼版本支援的需要。 VALUE - 作业系统版本太旧 + 作業系統版本太舊 NAME From 7e45f801d47b758d3889288a96fe55f8c8e4d288 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 9 Mar 2022 15:24:08 +0800 Subject: [PATCH 5/8] AppDelegate // Add a Bool to tell whether macOS is in Dark Mode. --- Source/Modules/AppDelegate.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Source/Modules/AppDelegate.swift b/Source/Modules/AppDelegate.swift index c0e51087..4f9aca18 100644 --- a/Source/Modules/AppDelegate.swift +++ b/Source/Modules/AppDelegate.swift @@ -299,4 +299,19 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega NSLog("vChewingErrorCallback: %@", strPrint) } } + @objc static func isDarkMode() -> Bool { + if #available(macOS 10.15, *) { + let appearanceDescription = NSApplication.shared.effectiveAppearance.debugDescription.lowercased() + if appearanceDescription.contains("dark") { + return true + } + } else if #available(macOS 10.14, *) { + if let appleInterfaceStyle = UserDefaults.standard.object(forKey: "AppleInterfaceStyle") as? String { + if appleInterfaceStyle.lowercased().contains("dark") { + return true + } + } + } + return false + } } From a9c03235bc5932fe30af18874f569129e2c94a13 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 9 Mar 2022 16:29:24 +0800 Subject: [PATCH 6/8] Voltaire // Differentiate highlight background colors between NSAppearances. --- Source/UI/CandidateUI/HorizontalCandidateController.swift | 5 +++-- Source/UI/CandidateUI/VerticalCandidateController.swift | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/UI/CandidateUI/HorizontalCandidateController.swift b/Source/UI/CandidateUI/HorizontalCandidateController.swift index bab60327..5a67a587 100644 --- a/Source/UI/CandidateUI/HorizontalCandidateController.swift +++ b/Source/UI/CandidateUI/HorizontalCandidateController.swift @@ -118,12 +118,13 @@ fileprivate class HorizontalCandidateView: NSView { var activeCandidateIndexAttr = keyLabelAttrDict var activeCandidateAttr = candidateAttrDict if index == highlightedIndex { + let colorBlendAmount: CGFloat = IME.isDarkMode() ? 0.25 : 0 // The background color of the highlightened candidate switch ctlInputMethod.currentKeyHandler.inputMode { case InputMode.imeModeCHS: - NSColor.systemRed.withAlphaComponent(0.75).setFill() + NSColor.systemRed.blended(withFraction: colorBlendAmount, of: NSColor.controlBackgroundColor)!.setFill() case InputMode.imeModeCHT: - NSColor.systemBlue.withAlphaComponent(0.75).setFill() + NSColor.systemBlue.blended(withFraction: colorBlendAmount, of: NSColor.controlBackgroundColor)!.setFill() default: NSColor.alternateSelectedControlColor.setFill() } diff --git a/Source/UI/CandidateUI/VerticalCandidateController.swift b/Source/UI/CandidateUI/VerticalCandidateController.swift index da384088..386aa2a7 100644 --- a/Source/UI/CandidateUI/VerticalCandidateController.swift +++ b/Source/UI/CandidateUI/VerticalCandidateController.swift @@ -124,12 +124,13 @@ fileprivate class VerticalCandidateView: NSView { var activeCandidateIndexAttr = keyLabelAttrDict var activeCandidateAttr = candidateAttrDict if index == highlightedIndex { + let colorBlendAmount: CGFloat = IME.isDarkMode() ? 0.25 : 0 // The background color of the highlightened candidate switch ctlInputMethod.currentKeyHandler.inputMode { case InputMode.imeModeCHS: - NSColor.systemRed.withAlphaComponent(0.75).setFill() + NSColor.systemRed.blended(withFraction: colorBlendAmount, of: NSColor.controlBackgroundColor)!.setFill() case InputMode.imeModeCHT: - NSColor.systemBlue.withAlphaComponent(0.75).setFill() + NSColor.systemBlue.blended(withFraction: colorBlendAmount, of: NSColor.controlBackgroundColor)!.setFill() default: NSColor.alternateSelectedControlColor.setFill() } From 91cec38dfed24ddd8e4d9f279b7753b17c313951 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 9 Mar 2022 18:18:55 +0800 Subject: [PATCH 7/8] AWFileHash // Deprecating MD5. --- Source/3rdParty/AWFileHash/AWFileHash.h | 2 -- Source/3rdParty/AWFileHash/AWFileHash.m | 12 +----------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/Source/3rdParty/AWFileHash/AWFileHash.h b/Source/3rdParty/AWFileHash/AWFileHash.h index 904aeebf..8fe9346b 100644 --- a/Source/3rdParty/AWFileHash/AWFileHash.h +++ b/Source/3rdParty/AWFileHash/AWFileHash.h @@ -20,12 +20,10 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH @interface AWFileHash : NSObject -+ (NSString *)md5HashOfData:(NSData *)data; + (NSString *)sha1HashOfData:(NSData *)data; + (NSString *)sha512HashOfData:(NSData *)data; + (NSString *)crc32HashOfData:(NSData *)data; -+ (NSString *)md5HashOfFileAtPath:(NSString *)filePath; + (NSString *)sha1HashOfFileAtPath:(NSString *)filePath; + (NSString *)sha512HashOfFileAtPath:(NSString *)filePath; + (NSString *)crc32HashOfFileAtPath:(NSString *)filePath; diff --git a/Source/3rdParty/AWFileHash/AWFileHash.m b/Source/3rdParty/AWFileHash/AWFileHash.m index ab3282ca..ed3a89f5 100644 --- a/Source/3rdParty/AWFileHash/AWFileHash.m +++ b/Source/3rdParty/AWFileHash/AWFileHash.m @@ -307,11 +307,7 @@ int CC_CRC32_Final(unsigned char *md, CC_CRC32_CTX *c) { #pragma mark - #pragma mark public class accessors -+ (NSString *)md5HashOfData:(NSData *)data { - FileHashComputationContext context; - FileHashComputationContextInitialize(context, MD5); - return [self hashOfNSData:data withComputationContext:&context]; -} + + (NSString *)sha1HashOfData:(NSData *)data { FileHashComputationContext context; @@ -331,12 +327,6 @@ int CC_CRC32_Final(unsigned char *md, CC_CRC32_CTX *c) { return [self hashOfNSData:data withComputationContext:&context]; } -+ (NSString *)md5HashOfFileAtPath:(NSString *)filePath { - FileHashComputationContext context; - FileHashComputationContextInitialize(context, MD5); - return [self hashOfFileAtPath:filePath withComputationContext:&context]; -} - + (NSString *)sha1HashOfFileAtPath:(NSString *)filePath { FileHashComputationContext context; FileHashComputationContextInitialize(context, SHA1); From 2b172ffb1a5f58bd23e15507289fb5587178679c Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 9 Mar 2022 18:32:34 +0800 Subject: [PATCH 8/8] Data Update - 20220309 --- Source/Data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Data b/Source/Data index ed8e8f37..e7785674 160000 --- a/Source/Data +++ b/Source/Data @@ -1 +1 @@ -Subproject commit ed8e8f37aeff477a242f4ad345d5b2cfa85e0cf0 +Subproject commit e7785674095589d8d35a54f9ad3920d26d39a448