Class: Thor::Interactive::TUI::Theme

Inherits:
Object
  • Object
show all
Defined in:
lib/thor/interactive/tui/theme.rb

Overview

Theming system for the TUI shell. Predefined themes and custom color configuration.

Constant Summary collapse

THEMES =
{
  default: {
    output_fg: nil,
    output_border: :dark_gray,
    error_fg: :red,
    command_echo_fg: :dark_gray,
    system_fg: :cyan,
    input_fg: nil,
    input_border: :green,
    input_title_fg: :green,
    cursor_fg: :black,
    cursor_bg: :white,
    status_bar_fg: :white,
    status_bar_bg: :blue,
    completion_fg: :white,
    completion_bg: :dark_gray,
    completion_selected_fg: :black,
    completion_selected_bg: :cyan
  },
  dark: {
    output_fg: :gray,
    output_border: :dark_gray,
    error_fg: :light_red,
    command_echo_fg: :dark_gray,
    system_fg: :light_cyan,
    input_fg: :white,
    input_border: :light_green,
    input_title_fg: :light_green,
    cursor_fg: :black,
    cursor_bg: :light_yellow,
    status_bar_fg: :white,
    status_bar_bg: :dark_gray,
    completion_fg: :white,
    completion_bg: :dark_gray,
    completion_selected_fg: :black,
    completion_selected_bg: :light_cyan
  },
  light: {
    output_fg: :black,
    output_border: :gray,
    error_fg: :red,
    command_echo_fg: :gray,
    system_fg: :blue,
    input_fg: :black,
    input_border: :green,
    input_title_fg: :green,
    cursor_fg: :white,
    cursor_bg: :black,
    status_bar_fg: :white,
    status_bar_bg: :blue,
    completion_fg: :black,
    completion_bg: :gray,
    completion_selected_fg: :white,
    completion_selected_bg: :blue
  },
  minimal: {
    output_fg: nil,
    output_border: :dark_gray,
    error_fg: :red,
    command_echo_fg: :dark_gray,
    system_fg: :yellow,
    input_fg: nil,
    input_border: :dark_gray,
    input_title_fg: :white,
    cursor_fg: :black,
    cursor_bg: :white,
    status_bar_fg: :black,
    status_bar_bg: :white,
    completion_fg: :white,
    completion_bg: :dark_gray,
    completion_selected_fg: :black,
    completion_selected_bg: :white
  }
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(theme = :default) ⇒ Theme

Returns a new instance of Theme.



86
87
88
89
90
91
92
# File 'lib/thor/interactive/tui/theme.rb', line 86

def initialize(theme = :default)
  @colors = if theme.is_a?(Hash)
    THEMES[:default].merge(theme)
  else
    THEMES.fetch(theme, THEMES[:default]).dup
  end
end

Instance Attribute Details

#colorsObject (readonly)

Returns the value of attribute colors.



84
85
86
# File 'lib/thor/interactive/tui/theme.rb', line 84

def colors
  @colors
end

Instance Method Details

#[](key) ⇒ Object



94
95
96
# File 'lib/thor/interactive/tui/theme.rb', line 94

def [](key)
  @colors[key]
end

#command_echo_styleObject



112
113
114
# File 'lib/thor/interactive/tui/theme.rb', line 112

def command_echo_style
  RatatuiRuby::Style::Style.new(fg: @colors[:command_echo_fg])
end

#completion_bg_styleObject



144
145
146
# File 'lib/thor/interactive/tui/theme.rb', line 144

def completion_bg_style
  RatatuiRuby::Style::Style.new(bg: @colors[:completion_bg])
end

#completion_selected_styleObject



148
149
150
151
152
153
154
# File 'lib/thor/interactive/tui/theme.rb', line 148

def completion_selected_style
  RatatuiRuby::Style::Style.new(
    fg: @colors[:completion_selected_fg],
    bg: @colors[:completion_selected_bg],
    modifiers: [:bold]
  )
end

#completion_styleObject



140
141
142
# File 'lib/thor/interactive/tui/theme.rb', line 140

def completion_style
  RatatuiRuby::Style::Style.new(fg: @colors[:completion_fg])
end

#cursor_styleObject



128
129
130
# File 'lib/thor/interactive/tui/theme.rb', line 128

def cursor_style
  RatatuiRuby::Style::Style.new(fg: @colors[:cursor_fg], bg: @colors[:cursor_bg], modifiers: [:bold])
end

#error_styleObject



108
109
110
# File 'lib/thor/interactive/tui/theme.rb', line 108

def error_style
  RatatuiRuby::Style::Style.new(fg: @colors[:error_fg])
end

#input_border_styleObject



120
121
122
# File 'lib/thor/interactive/tui/theme.rb', line 120

def input_border_style
  RatatuiRuby::Style::Style.new(fg: @colors[:input_border])
end

#input_title_styleObject



124
125
126
# File 'lib/thor/interactive/tui/theme.rb', line 124

def input_title_style
  RatatuiRuby::Style::Style.new(fg: @colors[:input_title_fg], modifiers: [:bold])
end

#output_border_styleObject



132
133
134
# File 'lib/thor/interactive/tui/theme.rb', line 132

def output_border_style
  RatatuiRuby::Style::Style.new(fg: @colors[:output_border])
end

#output_styleObject



103
104
105
106
# File 'lib/thor/interactive/tui/theme.rb', line 103

def output_style
  fg = @colors[:output_fg]
  fg ? RatatuiRuby::Style::Style.new(fg: fg) : nil
end

#status_bar_styleObject



136
137
138
# File 'lib/thor/interactive/tui/theme.rb', line 136

def status_bar_style
  RatatuiRuby::Style::Style.new(fg: @colors[:status_bar_fg], bg: @colors[:status_bar_bg])
end

#style(key) ⇒ Object



98
99
100
101
# File 'lib/thor/interactive/tui/theme.rb', line 98

def style(key)
  color = @colors[key]
  color ? RatatuiRuby::Style::Style.new(fg: color) : nil
end

#system_styleObject



116
117
118
# File 'lib/thor/interactive/tui/theme.rb', line 116

def system_style
  RatatuiRuby::Style::Style.new(fg: @colors[:system_fg])
end