module Chamomile::ColorProfile
Constants
- ANSI
- ANSI256
- ANSI256_TO_ANSI
-
ANSI256to ANSI16 lookup table - NO_COLOR
- TRUE_COLOR
Public Class Methods
Source
# File lib/chamomile/styling/color_profile.rb, line 56 def detect return NO_COLOR if ENV.key?("NO_COLOR") colorterm = ENV.fetch("COLORTERM", "") return TRUE_COLOR if %w[truecolor 24bit].include?(colorterm) term = ENV.fetch("TERM", "") return ANSI256 if term.include?("256color") return ANSI if term.include?("color") || term.include?("ansi") ANSI end
Source
# File lib/chamomile/styling/color_profile.rb, line 69 def downsample(color, target_profile) return Color::NoColor.new if target_profile == NO_COLOR case color when Color::TrueColor case target_profile when TRUE_COLOR then color when ANSI256 then truecolor_to_256(color) when ANSI then ansi256_to_ansi(truecolor_to_256(color)) end when Color::ANSI256Color case target_profile when TRUE_COLOR, ANSI256 then color when ANSI then ansi256_to_ansi(color) end else # ANSIColor, NoColor, etc. color end end