Sha256: 40a33707cd722c6e07e2024ff2f5ace3dd350fe3adad9cb5189f66361fd44bc5

Contents?: true

Size: 633 Bytes

Versions: 8

Compression:

Stored size: 633 Bytes

Contents

require 'curses'

module GitCrecord
  module UI
    module Color
      MAP = {
        normal: 1,
        green: 2,
        red: 3,
        hl: 4
      }.freeze

      def self.init
        Curses.start_color
        Curses.use_default_colors
        Curses.init_pair(MAP[:normal], -1, -1)
        Curses.init_pair(MAP[:green], Curses::COLOR_GREEN, -1)
        Curses.init_pair(MAP[:red], Curses::COLOR_RED, -1)
        Curses.init_pair(MAP[:hl], Curses::COLOR_WHITE, Curses::COLOR_GREEN)
      end

      MAP.each_pair do |name, number|
        define_singleton_method(name){ Curses.color_pair(number) }
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
git-crecord-1.0.7 lib/git_crecord/ui/color.rb
git-crecord-1.0.6 lib/git_crecord/ui/color.rb
git-crecord-1.0.5 lib/git_crecord/ui/color.rb
git-crecord-1.0.4 lib/git_crecord/ui/color.rb
git-crecord-1.0.3 lib/git_crecord/ui/color.rb
git-crecord-1.0.2 lib/git_crecord/ui/color.rb
git-crecord-1.0.1 lib/git_crecord/ui/color.rb
git-crecord-1.0.0 lib/git_crecord/ui/color.rb