class

Phosphor::Theme

Inherits Reference < Object

Maps semantic names to Style values, so widgets ask for :accent or :error rather than hardcoding colors — the same widget renders correctly whether an app uses phosphor's built-in look or a custom one.

Widget#sync is the only place that calls app.themeMockWidget never touches it directly, keeping mocks publishable independent of any app's color choices.

See DESIGN.md § "Style and Theme" for the full rationale.

Constants

DEFAULTS = {:primary => Style.new.fg(AdaptiveColor.new(light: Color::Indexed.new(24), dark: Color::Indexed.new(75))), :accent => (Style.new.fg(AdaptiveColor.new(light: Color::Indexed.new(127), dark: Color::Indexed.new(213)))).bold, :muted => Style.new.fg(AdaptiveColor.new(light: Color::Indexed.new(240), dark: Color::Indexed.new(244))), :error => (Style.new.fg(AdaptiveColor.new(light: Color::Indexed.new(160), dark: Color::Indexed.new(196)))).bold, :success => Style.new.fg(AdaptiveColor.new(light: Color::Indexed.new(28), dark: Color::Indexed.new(83))), :selected => Style.new.reverse, :border => Style.new.fg(AdaptiveColor.new(light: Color::Indexed.new(250), dark: Color::Indexed.new(240))), :title => Style.new.bold, :background => Style.new.bg(Color::Default.new)} of Symbol => Style

The built-in theme. Every color uses AdaptiveColor so it looks correct on both dark terminals (the common case) and light terminals (VS Code's default, many macOS users) without any configuration.

Constructors

new(styles : Hash(Symbol, Style) = DEFAULTS)
Source

Instance methods

[](name : Symbol) : Style

Fetches the Style registered for name. Raises KeyError naming the missing key if name isn't set — use #[]? for a safe lookup instead.

Source
[]?(name : Symbol) : Style | Nil

Fetches the Style registered for name, or nil if it isn't set.

Source
merge(overrides : Hash(Symbol, Style)) : Theme

Returns a new Theme with overrides layered on top of this one — keys in overrides replace this theme's value for that key; every other key keeps its current value. Does not mutate self.

Source