Class: Mvr::ColorTypes

Inherits:
Object
  • Object
show all
Extended by:
PluginType
Defined in:
lib/mvr/plugin.rb

Constant Summary collapse

DEFAULT_COLOR_OPTS =
{
    normal:   {
        fg: :none,
        bg: :none,
    },
    same:     {
        fg: :black,
        bg: :white,
    },
    conflict: {
        fg: :white,
        bg: :red,
    },
}

Class Method Summary collapse

Class Method Details

.def_colorObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/mvr/plugin.rb', line 43

def self.def_color
  register_type(:color_override) { |list|
    options = Plugins.get_var :options
    opts    = DEFAULT_COLOR_OPTS
    list.sort_by { |v| -v[:options][:priority] }.each { |item|
      rval = item[:block].call(options)
      unless rval.nil? || !rval
        opts = rval
        break
      end
    }
    opts.each { |opt| Format.color_profile opt[0], fgcolor: opt[1][:fg], bgcolor: opt[1][:bg] }
  }
end