Sha256: d450b4491972c5e8aaf70ab633405b6353d6a4848921c6462e988da6a5710a27

Contents?: true

Size: 792 Bytes

Versions: 1

Compression:

Stored size: 792 Bytes

Contents

# frozen_string_literal: true

require 'curses'

module GitCrecord
  module UI
    module Color
      MAP = {
        normal: 1,
        green: 2,
        red: 3,
        hl: 4,
        status_bar: 5
      }.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_BLACK, Curses::COLOR_GREEN)
        Curses.init_pair(
          MAP[:status_bar], Curses::COLOR_BLACK, Curses::COLOR_BLUE
        )
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git-crecord-1.2.0 lib/git_crecord/ui/color.rb