Class: Vic::Highlight
- Inherits:
-
Object
- Object
- Vic::Highlight
- Defined in:
- lib/vic/highlight.rb
Instance Attribute Summary collapse
-
#cterm ⇒ Object
Returns the value of attribute cterm.
-
#ctermbg ⇒ Object
Returns the value of attribute ctermbg.
-
#ctermfg ⇒ Object
Returns the value of attribute ctermfg.
-
#font ⇒ Object
Returns the value of attribute font.
-
#group ⇒ Object
Returns the value of attribute group.
-
#gui ⇒ Object
Returns the value of attribute gui.
-
#guibg ⇒ Object
Returns the value of attribute guibg.
-
#guifg ⇒ Object
Returns the value of attribute guifg.
-
#guisp ⇒ Object
Returns the value of attribute guisp.
-
#start ⇒ Object
Returns the value of attribute start.
-
#stop ⇒ Object
Returns the value of attribute stop.
-
#term ⇒ Object
Returns the value of attribute term.
Class Method Summary collapse
-
.attributes ⇒ Array
Return the list of highlight attributes.
Instance Method Summary collapse
-
#bg=(color) ⇒ Vic::Highlight
Set both ctermbg and guibg simultaneously.
-
#fg=(color) ⇒ Vic::Highlight
Set both ctermfg and guifg simultaneously.
-
#force! ⇒ TrueClass
Set the force setting to true.
-
#force=(bool) ⇒ TrueClass, FalseClass
Set the force.
-
#force? ⇒ TrueClass, FalseClass
Return the force setting.
-
#initialize(group, attributes = {}) ⇒ Highlight
constructor
A new instance of Highlight.
-
#style=(styles) ⇒ Vic::Highlight
Set both cterm and gui simultaneously.
-
#update_attributes!(attributes = {}) ⇒ Vic::Highlight
Updates the highlights attributes.
Constructor Details
#initialize(group, attributes = {}) ⇒ Highlight
Returns a new instance of Highlight.
6 7 8 9 |
# File 'lib/vic/highlight.rb', line 6 def initialize(group, attributes={}) @group = group update_attributes!(attributes) end |
Instance Attribute Details
#cterm ⇒ Object
Returns the value of attribute cterm.
125 126 127 |
# File 'lib/vic/highlight.rb', line 125 def cterm @cterm end |
#ctermbg ⇒ Object
Returns the value of attribute ctermbg.
125 126 127 |
# File 'lib/vic/highlight.rb', line 125 def ctermbg @ctermbg end |
#ctermfg ⇒ Object
Returns the value of attribute ctermfg.
125 126 127 |
# File 'lib/vic/highlight.rb', line 125 def ctermfg @ctermfg end |
#font ⇒ Object
Returns the value of attribute font.
167 168 169 |
# File 'lib/vic/highlight.rb', line 167 def font @font end |
#group ⇒ Object
Returns the value of attribute group.
4 5 6 |
# File 'lib/vic/highlight.rb', line 4 def group @group end |
#gui ⇒ Object
Returns the value of attribute gui.
166 167 168 |
# File 'lib/vic/highlight.rb', line 166 def gui @gui end |
#guibg ⇒ Object
Returns the value of attribute guibg.
166 167 168 |
# File 'lib/vic/highlight.rb', line 166 def guibg @guibg end |
#guifg ⇒ Object
Returns the value of attribute guifg.
166 167 168 |
# File 'lib/vic/highlight.rb', line 166 def guifg @guifg end |
#guisp ⇒ Object
Returns the value of attribute guisp.
167 168 169 |
# File 'lib/vic/highlight.rb', line 167 def guisp @guisp end |
#start ⇒ Object
Returns the value of attribute start.
123 124 125 |
# File 'lib/vic/highlight.rb', line 123 def start @start end |
#stop ⇒ Object
Returns the value of attribute stop.
123 124 125 |
# File 'lib/vic/highlight.rb', line 123 def stop @stop end |
#term ⇒ Object
Returns the value of attribute term.
123 124 125 |
# File 'lib/vic/highlight.rb', line 123 def term @term end |
Class Method Details
.attributes ⇒ Array
Return the list of highlight attributes
42 43 44 |
# File 'lib/vic/highlight.rb', line 42 def self.attributes [:term, :start, :stop, :cterm, :ctermbg, :ctermfg, :gui, :guibg, :guifg, :guisp, :font] end |
Instance Method Details
#bg=(color) ⇒ Vic::Highlight
Set both ctermbg and guibg simultaneously
88 89 90 91 92 |
# File 'lib/vic/highlight.rb', line 88 def bg=(color) color = Color.new(color) @ctermbg, @guibg = color.to_cterm, color.to_gui self end |
#fg=(color) ⇒ Vic::Highlight
Set both ctermfg and guifg simultaneously
103 104 105 106 107 |
# File 'lib/vic/highlight.rb', line 103 def fg=(color) color = Color.new(color) @ctermfg, @guifg = color.to_cterm, color.to_gui self end |
#force! ⇒ TrueClass
Set the force setting to true
75 76 77 |
# File 'lib/vic/highlight.rb', line 75 def force! @force = true end |
#force=(bool) ⇒ TrueClass, FalseClass
Set the force
55 56 57 |
# File 'lib/vic/highlight.rb', line 55 def force=(bool) @force = !!bool end |
#force? ⇒ TrueClass, FalseClass
Return the force setting
65 66 67 |
# File 'lib/vic/highlight.rb', line 65 def force? @force end |
#style=(styles) ⇒ Vic::Highlight
Set both cterm and gui simultaneously
118 119 120 121 |
# File 'lib/vic/highlight.rb', line 118 def style=(styles) @cterm, @gui = [select_styles(styles)] * 2 self end |
#update_attributes!(attributes = {}) ⇒ Vic::Highlight
Updates the highlights attributes
26 27 28 29 30 31 32 33 34 |
# File 'lib/vic/highlight.rb', line 26 def update_attributes!(attributes={}) attributes.each_pair do |key, val| self.respond_to?(:"#{ key }=") && send(:"#{ key }=", val) end # Returning self seems like the right thing to do when a method changes # more than one property of an object. self end |