SessionCtl // Add .clientAccentColor().

This commit is contained in:
ShikiSuen 2023-11-27 19:20:27 +08:00
parent 61dc2b991f
commit 8c70327d90
2 changed files with 23 additions and 0 deletions

View File

@ -81,6 +81,28 @@ extension SessionCtl: InputHandlerDelegate {
extension SessionCtl: CtlCandidateDelegate {
public var isCandidateState: Bool { state.isCandidateContainer }
public var clientAccentColor: NSColor? {
var nullResponse = !PrefMgr.shared.respectClientAccentColor
nullResponse = nullResponse || PrefMgr.shared.shiftJISShinjitaiOutputEnabled
nullResponse = nullResponse || PrefMgr.shared.chineseConversionEnabled
guard !nullResponse else { return nil }
let fallbackValue = NSColor.accentColor
if #unavailable(macOS 10.14) {
return fallbackValue
}
// client()
let urls = NSRunningApplication.runningApplications(
withBundleIdentifier: client()?.bundleIdentifier() ?? ""
).compactMap(\.bundleURL)
let bundles = urls.compactMap { Bundle(url: $0) }
for bundle in bundles {
let bundleAccentColor = bundle.getAccentColor()
guard bundleAccentColor != .accentColor else { continue }
return bundleAccentColor
}
return fallbackValue
}
public var shouldAutoExpandCandidates: Bool {
guard !PrefMgr.shared.alwaysExpandCandidateWindow else { return true }
guard state.type == .ofSymbolTable else { return state.type == .ofAssociates }

View File

@ -22,6 +22,7 @@ public protocol CtlCandidateDelegate {
var shouldAutoExpandCandidates: Bool { get }
var isCandidateContextMenuEnabled: Bool { get }
var showReverseLookupResult: Bool { get }
var clientAccentColor: NSColor? { get }
}
public protocol CtlCandidateProtocol {