From 923471c8bb79eaa708dcb922d521c35b9e2cfff9 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 26 Feb 2024 21:00:20 +0800 Subject: [PATCH] UserDef // +kCandidateServiceMenuContents. --- .../Sources/Shared/PrefMgr_Core.swift | 26 +++++++++++++++++++ .../Shared/Protocols/PrefMgrProtocol.swift | 1 + .../Sources/Shared/UserDef/UserDef.swift | 3 +++ 3 files changed, 30 insertions(+) diff --git a/Packages/vChewing_Shared/Sources/Shared/PrefMgr_Core.swift b/Packages/vChewing_Shared/Sources/Shared/PrefMgr_Core.swift index 1c32a259..71cbbdd2 100644 --- a/Packages/vChewing_Shared/Sources/Shared/PrefMgr_Core.swift +++ b/Packages/vChewing_Shared/Sources/Shared/PrefMgr_Core.swift @@ -25,6 +25,29 @@ import SwiftExtension "com.valvesoftware.steam": true, "jp.naver.line.mac": true, ] + public static let kDefaultCandidateServiceMenuItem: [String] = [ + #"Unicode Metadata: %s"# + "\t" + #"@SEL:copyUnicodeMetadata:"#, + #"macOS Dict: %s"# + "\t" + #"@URL:dict://%s"#, + #"Bing: %s"# + "\t" + #"@WEB:https://www.bing.com/search?q=%s"#, + #"DuckDuckGo: %s"# + "\t" + #"@WEB:https://duckduckgo.com/?t=h_&q=%s"#, + #"Ecosia: %s"# + "\t" + #"@WEB:https://www.ecosia.org/search?method=index&q=%s"#, + #"Google: %s"# + "\t" + #"@WEB:https://www.google.com/search?q=%s"#, + #"MoeDict: %s"# + "\t" + #"@WEB:https://www.moedict.tw/%s"#, + #"Wikitonary: %s"# + "\t" + #"@WEB:https://zh.wiktionary.org/wiki/Special:Search?search=%s"#, + #"Unihan: %s"# + "\t" + #"@WEB:https://www.unicode.org/cgi-bin/GetUnihanData.pl?codepoint=%s"#, + #"Zi-Hi: %s"# + "\t" + #"@WEB:https://zi-hi.com/sp/uni/%s"#, + #"HTML Ruby Zhuyin: %s"# + "\t" + #"@SEL:copyRubyHTMLZhuyinTextbookStyle:"#, + #"HTML Ruby Pinyin: %s"# + "\t" + #"@SEL:copyRubyHTMLHanyuPinyinTextbookStyle:"#, + #"Zhuyin Annotation: %s"# + "\t" + #"@SEL:copyInlineZhuyinAnnotationTextbookStyle:"#, + #"Pinyin Annotation: %s"# + "\t" + #"@SEL:copyInlineHanyuPinyinAnnotationTextbookStyle:"#, + #"Braille 1947: %s"# + "\t" + #"@SEL:copyBraille1947:"#, + #"Braille 2018: %s"# + "\t" + #"@SEL:copyBraille2018:"#, + #"Baidu: %s"# + "\t" + #"@WEB:https://www.baidu.com/s?wd=%s"#, + #"BiliBili: %s"# + "\t" + #"@WEB:https://search.bilibili.com/all?keyword=%s"#, + #"Genshin BiliWiki: %s"# + "\t" + #"@WEB:https://wiki.biligame.com/ys/%s"#, + #"HSR BiliWiki: %s"# + "\t" + #"@WEB:https://wiki.biligame.com/sr/%s"#, + ] + public var didAskForSyncingLMPrefs: (() -> Void)? public var didAskForRefreshingSpeechSputnik: (() -> Void)? public var didAskForSyncingShiftKeyDetectorPrefs: (() -> Void)? @@ -37,6 +60,9 @@ import SwiftExtension @AppProperty(key: UserDef.kFailureFlagForUOMObservation.rawValue, defaultValue: false) public dynamic var failureFlagForUOMObservation: Bool + @AppProperty(key: UserDef.kCandidateServiceMenuContents.rawValue, defaultValue: kDefaultCandidateServiceMenuItem) + public dynamic var candidateServiceMenuContents: [String] + @AppProperty(key: UserDef.kRespectClientAccentColor.rawValue, defaultValue: true) public dynamic var respectClientAccentColor: Bool diff --git a/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift b/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift index 92e76387..307b4f54 100644 --- a/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift +++ b/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift @@ -11,6 +11,7 @@ import Foundation public protocol PrefMgrProtocol { var isDebugModeEnabled: Bool { get set } var failureFlagForUOMObservation: Bool { get set } + var candidateServiceMenuContents: [String] { get set } var respectClientAccentColor: Bool { get set } var securityHardenedCompositionBuffer: Bool { get set } var checkAbusersOfSecureEventInputAPI: Bool { get set } diff --git a/Packages/vChewing_Shared/Sources/Shared/UserDef/UserDef.swift b/Packages/vChewing_Shared/Sources/Shared/UserDef/UserDef.swift index 826638d8..a15cff9b 100644 --- a/Packages/vChewing_Shared/Sources/Shared/UserDef/UserDef.swift +++ b/Packages/vChewing_Shared/Sources/Shared/UserDef/UserDef.swift @@ -33,6 +33,7 @@ public enum UserDef: String, CaseIterable, Identifiable { case kIsDebugModeEnabled = "_DebugMode" case kFailureFlagForUOMObservation = "_FailureFlag_UOMObservation" + case kCandidateServiceMenuContents = "CandidateServiceMenuContents" case kRespectClientAccentColor = "RespectClientAccentColor" case kSecurityHardenedCompositionBuffer = "SecurityHardenedCompositionBuffer" case kCheckAbusersOfSecureEventInputAPI = "CheckAbusersOfSecureEventInputAPI" @@ -158,6 +159,7 @@ public extension UserDef { switch self { case .kIsDebugModeEnabled: return .bool case .kFailureFlagForUOMObservation: return .bool + case .kCandidateServiceMenuContents: return .dictionary case .kRespectClientAccentColor: return .bool case .kSecurityHardenedCompositionBuffer: return .bool case .kCheckAbusersOfSecureEventInputAPI: return .bool @@ -254,6 +256,7 @@ public extension UserDef { var metaData: MetaData? { switch self { case .kIsDebugModeEnabled: return .init(userDef: self, shortTitle: "Debug Mode") + case .kCandidateServiceMenuContents: return nil case .kFailureFlagForUOMObservation: return nil case .kRespectClientAccentColor: return .init( userDef: self, shortTitle: "i18n:userdef.kRespectClientAccentColor.shortTitle",