SessionCtl // Add .clientAccentColor().
This commit is contained in:
parent
61dc2b991f
commit
8c70327d90
|
@ -81,6 +81,28 @@ extension SessionCtl: InputHandlerDelegate {
|
||||||
extension SessionCtl: CtlCandidateDelegate {
|
extension SessionCtl: CtlCandidateDelegate {
|
||||||
public var isCandidateState: Bool { state.isCandidateContainer }
|
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 {
|
public var shouldAutoExpandCandidates: Bool {
|
||||||
guard !PrefMgr.shared.alwaysExpandCandidateWindow else { return true }
|
guard !PrefMgr.shared.alwaysExpandCandidateWindow else { return true }
|
||||||
guard state.type == .ofSymbolTable else { return state.type == .ofAssociates }
|
guard state.type == .ofSymbolTable else { return state.type == .ofAssociates }
|
||||||
|
|
|
@ -22,6 +22,7 @@ public protocol CtlCandidateDelegate {
|
||||||
var shouldAutoExpandCandidates: Bool { get }
|
var shouldAutoExpandCandidates: Bool { get }
|
||||||
var isCandidateContextMenuEnabled: Bool { get }
|
var isCandidateContextMenuEnabled: Bool { get }
|
||||||
var showReverseLookupResult: Bool { get }
|
var showReverseLookupResult: Bool { get }
|
||||||
|
var clientAccentColor: NSColor? { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
public protocol CtlCandidateProtocol {
|
public protocol CtlCandidateProtocol {
|
||||||
|
|
Loading…
Reference in New Issue