Class: Ektoplayer::Theme
- Inherits:
-
Object
- Object
- Ektoplayer::Theme
- Defined in:
- lib/ektoplayer/theme.rb
Instance Attribute Summary collapse
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
- #[](theme_def) ⇒ Object
- #color(name, *defs, theme: 8) ⇒ Object
- #color_256(*args) ⇒ Object
- #color_mono(*args) ⇒ Object
- #get(theme_def) ⇒ Object
-
#initialize ⇒ Theme
constructor
A new instance of Theme.
- #use_colors(colors) ⇒ Object
Constructor Details
#initialize ⇒ Theme
Returns a new instance of Theme.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ektoplayer/theme.rb', line 7 def initialize @theme, @current = {}, 0 @theme[0] = { :default => [-1, -1 ].freeze, :'url' => [:default, :default, :underline].freeze, :'tabbar.selected' => [:default, :default, :bold ].freeze } @theme[8] = { :default => [-1, -1 ].freeze, :'url' => [:magenta, :default, :underline].freeze, :'info.head' => [:blue, :default, :bold ].freeze, :'info.tag' => [:blue ].freeze, :'info.value' => [:magenta ].freeze, :'info.description' => [:blue ].freeze, :'info.download.file' => [:blue ].freeze, :'info.download.percent' => [:magenta ].freeze, :'info.download.error' => [:red ].freeze, :'progressbar.progress' => [:blue ].freeze, :'progressbar.rest' => [:black ].freeze, :'tabbar.selected' => [:blue ].freeze, :'tabbar.unselected' => [:white ].freeze, :'list.item_even' => [:blue ].freeze, :'list.item_odd' => [:blue ].freeze, :'list.item_selection' => [:magenta ].freeze, :'playinginfo.position' => [:magenta ].freeze, :'playinginfo.state' => [:cyan ].freeze, :'help.widget_name' => [:blue, :default, :bold ].freeze, :'help.key_name' => [:blue ].freeze, :'help.command_name' => [:magenta ].freeze, :'help.command_desc' => [:yellow ].freeze } @theme[256] = { :'default' => [:white, 233 ].freeze, :'url' => [97, :default, :underline ].freeze, :'info.head' => [32, :default, :bold ].freeze, :'info.tag' => [74 ].freeze, :'info.value' => [67 ].freeze, :'info.description' => [67 ].freeze, :'info.download.file' => [75 ].freeze, :'info.download.percent' => [68 ].freeze, :'info.download.error' => [:red ].freeze, :'progressbar.progress' => [23 ].freeze, :'progressbar.rest' => [:black ].freeze, :'tabbar.selected' => [75 ].freeze, :'tabbar.unselected' => [250 ].freeze, :'list.item_even' => [26 ].freeze, :'list.item_odd' => [25 ].freeze, :'list.item_selection' => [97 ].freeze, :'playinginfo.position' => [97 ].freeze, :'playinginfo.state' => [37 ].freeze, :'help.widget_name' => [33 ].freeze, :'help.key_name' => [75 ].freeze, :'help.command_name' => [68 ].freeze, :'help.command_desc' => [29 ].freeze } @theme.freeze end |
Instance Attribute Details
#current ⇒ Object (readonly)
Returns the value of attribute current.
5 6 7 |
# File 'lib/ektoplayer/theme.rb', line 5 def current @current end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
5 6 7 |
# File 'lib/ektoplayer/theme.rb', line 5 def theme @theme end |
Instance Method Details
#[](theme_def) ⇒ Object
87 |
# File 'lib/ektoplayer/theme.rb', line 87 def [](theme_def) UI::Colors.get(theme_def) end |
#color(name, *defs, theme: 8) ⇒ Object
78 79 80 81 |
# File 'lib/ektoplayer/theme.rb', line 78 def color(name, *defs, theme: 8) defs.map! { |d| Integer(d) rescue d.to_sym } @theme[theme][name.to_sym] = defs.freeze end |
#color_256(*args) ⇒ Object
84 |
# File 'lib/ektoplayer/theme.rb', line 84 def color_256(*args) color(*args, theme: 256) end |
#color_mono(*args) ⇒ Object
83 |
# File 'lib/ektoplayer/theme.rb', line 83 def color_mono(*args) color(*args, theme: 0) end |
#get(theme_def) ⇒ Object
86 |
# File 'lib/ektoplayer/theme.rb', line 86 def get(theme_def) UI::Colors.get(theme_def) end |
#use_colors(colors) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ektoplayer/theme.rb', line 89 def use_colors(colors) fail 'unknown theme' unless @theme[colors] @current = colors UI::Colors.reset UI::Colors.default_fg(@theme[@current][:default][0]) UI::Colors.default_bg(@theme[@current][:default][1]) @theme.values.map(&:keys).flatten.each do |name| next if name == :default defs ||= @theme[256][name] if @current == 256 defs ||= @theme[8][name] if @current >= 8 defs ||= @theme[0][name] UI::Colors.set(name, *defs) end end |