class Clacky::UI2::Themes::BaseTheme
Subclasses MUST define SYMBOLS and COLORS constants
BaseTheme defines the abstract interface for all themes
def colors
-
(Hash)- Color definitions
def colors self.class::COLORS end
def dark_background?
-
(Boolean)- true if dark background, false if light background
def dark_background? # Use pre-detected value if available, otherwise default to dark @is_dark_background.nil? ? true : @is_dark_background end
def format_symbol(key)
-
(String)- Colored symbol
Parameters:
-
key(Symbol) -- Symbol key (e.g., :user, :assistant)
def format_symbol(key) @pastel.public_send(symbol_color(key), symbol(key)) end
def format_text(text, key)
-
(String)- Colored text
Parameters:
-
key(Symbol) -- Color key (e.g., :user, :assistant) -
text(String) -- Text to format
def format_text(text, key) @pastel.public_send(text_color(key), text) end
def initialize
def initialize @pastel = Pastel.new @is_dark_background = nil # Will be set by ThemeManager validate_theme_definition! end
def name
-
(String)- Theme name
def name raise NotImplementedError, "Subclass must implement #name method" end
def set_background_mode(is_dark)
-
is_dark(Boolean) -- true if dark background, false if light
def set_background_mode(is_dark) @is_dark_background = is_dark end
def symbol(key)
-
(String)- Symbol string
Parameters:
-
key(Symbol) -- Symbol key
def symbol(key) symbols[key] || "[??]" end
def symbol_color(key)
-
(Symbol)- Pastel color method name
Parameters:
-
key(Symbol) -- Color key
def symbol_color(key) colors.dig(key, 0) || :white end
def symbols
-
(Hash)- Symbol definitions
def symbols self.class::SYMBOLS end
def text_color(key)
-
(Symbol)- Pastel color method name
Parameters:
-
key(Symbol) -- Color key
def text_color(key) color_def = colors[key] return :white unless color_def # Use index 1 for dark background, index 2 for light background dark_background? ? color_def[1] : color_def[2] end
def validate_theme_definition!
def validate_theme_definition! unless self.class.const_defined?(:SYMBOLS) raise NotImplementedError, "Theme #{self.class.name} must define SYMBOLS constant" end unless self.class.const_defined?(:COLORS) raise NotImplementedError, "Theme #{self.class.name} must define COLORS constant" end end