...

Text file src/github.com/emissary-ingress/emissary/v3/build-aux/colors.mk

Documentation: github.com/emissary-ingress/emissary/v3/build-aux

     1ifeq ($(words $(filter $(abspath $(lastword $(MAKEFILE_LIST))),$(abspath $(MAKEFILE_LIST)))),1)
     2
     3_colors.mk := $(lastword $(MAKEFILE_LIST))
     4include $(dir $(_colors.mk))prelude.mk
     5
     6# CSI is the "control sequence introducer" that initiates a control
     7# seqnece.
     8_csi := $(shell printf '\033[')
     9
    10# Usage: $(call _cs,INT_ARG1 INT_ARG2..., OPERATION)
    11#
    12# Evaluate to a "control sequence" for the terminal.
    13_cs = $(_csi)$(call joinlist,;,$1)$(strip $2)
    14
    15# Usage: $(call _sgr, prop1=val1 prop2=val2)
    16#
    17# Evaluate to the SGR control sequence to change how text is rendered,
    18# using human-friendly key/value pairs.
    19#
    20# Unknown key/value pairs are ignored.
    21#
    22# Known settings:
    23#
    24#  `reset`       reset all properties
    25#
    26#  `wgt=bold`    font weight = bold
    27#  `wgt=normal`  font weight = normal (not bold)
    28#
    29#  `fg=blk`      foreground color = black
    30#  `fg=red`      foreground color = red
    31#  `fg=grn`      foreground color = green
    32#  `fg=yel`      foreground color = yellow
    33#  `fg=blu`      foreground color = blue
    34#  `fg=prp`      foreground color = purple
    35#  `fg=cyn`      foreground color = cyan
    36#  `fg=wht`      foreground color = white
    37#  `fg=def`      foreground color = default
    38_sgr = $(call _cs,$(foreach param,$1,$(_sgr/$(subst =,/,$(param)))),m)
    39
    40# The definitions of those settings:
    41_sgr/reset  = 0
    42_sgr/wgt/bold   = 1
    43_sgr/wgt/normal = 22
    44_sgr/fg/blk = 30
    45_sgr/fg/red = 31
    46_sgr/fg/grn = 32
    47_sgr/fg/yel = 33
    48_sgr/fg/blu = 34
    49_sgr/fg/prp = 35
    50_sgr/fg/cyn = 36
    51_sgr/fg/wht = 37
    52# 38 is 8bit/24bit color
    53_sgr/fg/def = 39
    54
    55# Now expose things for public consumption...
    56#
    57# Choose colors carefully. If they don't work on both a black
    58# background and a white background, pick other colors (so white,
    59# yellow, and black are poor choices).
    60RED = $(call _sgr,wgt=bold fg=red)
    61GRN = $(call _sgr,wgt=bold fg=grn)
    62BLU = $(call _sgr,wgt=bold fg=blu)
    63CYN = $(call _sgr,wgt=bold fg=cyn)
    64BLD = $(call _sgr,wgt=bold)
    65END = $(call _sgr,reset)
    66
    67endif

View as plain text