Class: Vic::Highlight

Inherits:
Object
  • Object
show all
Defined in:
lib/vic/highlight.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#ctermObject

Returns the value of attribute cterm.



125
126
127
# File 'lib/vic/highlight.rb', line 125

def cterm
  @cterm
end

#ctermbgObject

Returns the value of attribute ctermbg.



125
126
127
# File 'lib/vic/highlight.rb', line 125

def ctermbg
  @ctermbg
end

#ctermfgObject

Returns the value of attribute ctermfg.



125
126
127
# File 'lib/vic/highlight.rb', line 125

def ctermfg
  @ctermfg
end

#fontObject

Returns the value of attribute font.



167
168
169
# File 'lib/vic/highlight.rb', line 167

def font
  @font
end

#groupObject

Returns the value of attribute group.



4
5
6
# File 'lib/vic/highlight.rb', line 4

def group
  @group
end

#guiObject

Returns the value of attribute gui.



166
167
168
# File 'lib/vic/highlight.rb', line 166

def gui
  @gui
end

#guibgObject

Returns the value of attribute guibg.



166
167
168
# File 'lib/vic/highlight.rb', line 166

def guibg
  @guibg
end

#guifgObject

Returns the value of attribute guifg.



166
167
168
# File 'lib/vic/highlight.rb', line 166

def guifg
  @guifg
end

#guispObject

Returns the value of attribute guisp.



167
168
169
# File 'lib/vic/highlight.rb', line 167

def guisp
  @guisp
end

#startObject

Returns the value of attribute start.



123
124
125
# File 'lib/vic/highlight.rb', line 123

def start
  @start
end

#stopObject

Returns the value of attribute stop.



123
124
125
# File 'lib/vic/highlight.rb', line 123

def stop
  @stop
end

#termObject

Returns the value of attribute term.



123
124
125
# File 'lib/vic/highlight.rb', line 123

def term
  @term
end

Class Method Details

.attributesArray

Return the list of highlight attributes

Returns:

  • (Array)

    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

Parameters:

  • color (String)

    the color to use

Returns:



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

Parameters:

  • color (String)

    the color to use

Returns:



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

Returns:

  • (TrueClass)

    the force setting



75
76
77
# File 'lib/vic/highlight.rb', line 75

def force!
  @force = true
end

#force=(bool) ⇒ TrueClass, FalseClass

Set the force

Parameters:

  • bool (TrueClass, FalseClass)

    a value of true or false

Returns:

  • (TrueClass, FalseClass)

    the force setting



55
56
57
# File 'lib/vic/highlight.rb', line 55

def force=(bool)
  @force = !!bool
end

#force?TrueClass, FalseClass

Return the force setting

Returns:

  • (TrueClass, FalseClass)

    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

Parameters:

  • styles (Array)

    the styles to use

Returns:



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

Examples:

h = Vic::Highlight.new('Normal', { guibg: '333' })
h.guibg # => "#333333"
h.update_attributes!({ guibg: '000' })
h.guibg # => "#000000"

Parameters:

  • attributes (Hash) (defaults to: {})

    the attributes to update

Returns:



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