Class: Echoes::Profile
- Inherits:
-
Object
- Object
- Echoes::Profile
- Defined in:
- lib/echoes/profile.rb
Overview
A named color theme — foreground / background / cursor / selection plus the 16-entry ANSI palette that drives the 256-color table. Defined in ‘~/.config/echoes/echoes.conf` via the `profile` DSL:
profile "Solarized Dark" do
foreground "#93a1a1"
background "#002b36"
cursor_color "#93a1a1", 0.7
selection_color "#586e75"
color_palette %w[#073642 #dc322f #859900 #b58900 #268bd2
#d33682 #2aa198 #eee8d5 #002b36 #cb4b16
#586e75 #657b83 #839496 #6c71c4 #93a1a1 #fdf6e3]
end
Attributes left unset inherit from ‘Echoes.config` so a profile can be a partial override.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #background(*args) ⇒ Object
- #color_palette(val = nil) ⇒ Object
- #cursor_color(*args) ⇒ Object
- #foreground(*args) ⇒ Object
-
#initialize(name) ⇒ Profile
constructor
A new instance of Profile.
- #selection_color(*args) ⇒ Object
Constructor Details
#initialize(name) ⇒ Profile
Returns a new instance of Profile.
23 24 25 26 27 28 29 30 |
# File 'lib/echoes/profile.rb', line 23 def initialize(name) @name = name.to_s @foreground = nil @background = nil @cursor_color = nil @selection_color = nil @color_palette = nil end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/echoes/profile.rb', line 21 def name @name end |
Instance Method Details
#background(*args) ⇒ Object
36 37 38 |
# File 'lib/echoes/profile.rb', line 36 def background(*args) args.empty? ? (@background || Echoes.config.background) : @background = parse_color(args) end |
#color_palette(val = nil) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/echoes/profile.rb', line 48 def color_palette(val = nil) if val @color_palette = val.map { |c| c.is_a?(String) ? parse_color([c]) : c.map(&:to_f) } else @color_palette || Echoes.config.color_palette end end |
#cursor_color(*args) ⇒ Object
40 41 42 |
# File 'lib/echoes/profile.rb', line 40 def cursor_color(*args) args.empty? ? (@cursor_color || Echoes.config.cursor_color) : @cursor_color = parse_color(args) end |