MCPcopy Create free account
hub / github.com/anomalyco/opencode / selectedForeground

Function selectedForeground

packages/tui/src/theme/index.ts:95–111  ·  view source on GitHub ↗
(theme: Theme, bg?: RGBA)

Source from the content-addressed store, hash-verified

93export type SyntaxStyleOverrides = Record<string, { italic?: boolean }>
94
95export function selectedForeground(theme: Theme, bg?: RGBA): RGBA {
96 // If theme explicitly defines selectedListItemText, use it
97 if (theme._hasSelectedListItemText) {
98 return theme.selectedListItemText
99 }
100
101 // For transparent backgrounds, calculate contrast based on the actual bg (or fallback to primary)
102 if (theme.background.a === 0) {
103 const targetColor = bg ?? theme.primary
104 const { r, g, b } = targetColor
105 const luminance = 0.299 * r + 0.587 * g + 0.114 * b
106 return luminance > 0.5 ? RGBA.fromInts(0, 0, 0) : RGBA.fromInts(255, 255, 255)
107 }
108
109 // Fall back to background color
110 return theme.background
111}
112
113type HexColor = `#${string}`
114type RefName = string

Callers 8

DialogRetryActionFunction · 0.90
AutocompleteFunction · 0.90
QuestionPromptFunction · 0.90
contentFunction · 0.90
UserMessageFunction · 0.90
FooterActionFunction · 0.90
OptionFunction · 0.90
getSyntaxRulesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected