Documentation ¶
Index ¶
Constants ¶
const CountSpecialColors int = 1
Number of colors with which we occupy the initial bits of the first mask. The color SpecialColorTransparent is zero, so it is not counted.
const SpecialColorRemover uint64 = 1 << 0
@color remover works so: C + remover = transparent.
const SpecialColorTransparent uint64 = 0
All functions without any colors are transparent: C + transparent = C.
Variables ¶
var MaxColorsInMask = 64
MaxColorsInMask stores the maximum number of colors in the mask. Used in tests. It cannot be more than 64.
Functions ¶
This section is empty.
Types ¶
type Color ¶
type Color struct { // Val is the mask of the current color. // A one bit determines the number of the current color. Val uint64 // Index is the ordinal number of the mask, // in which this color is indicated by bit one. Index int }
Color structure describes a color. The color is represented by two components. The first component is a mask, which contains single one bit that defines the color number. The second component is the index of the mask in which this one bit is.
The length of the mask in any color cannot be more than MaxColorsInMask.
So, for example, if the number of colors in the mask can be a maximum of 3, then if you need to keep the fourth color, then for this you need to use the following mask, so the mask Index will be 1, and the Val in the mask will be
1 << 4 % MaxColorsInMask,
then there is 0b01.
type ColorContainer ¶
type ColorContainer struct {
Colors []Color
}
ColorContainer is class containing colors after @color parsing above each function (order is important).
func (*ColorContainer) Add ¶
func (c *ColorContainer) Add(color Color)
func (*ColorContainer) Contains ¶
func (c *ColorContainer) Contains(needColor Color) bool
func (*ColorContainer) Empty ¶
func (c *ColorContainer) Empty() bool
func (*ColorContainer) String ¶
func (c *ColorContainer) String(palette *Palette, withHighlights ColorMasks) string
type ColorMasks ¶
type ColorMasks []ColorMask
func NewColorMasks ¶
func NewColorMasks(colors []Color) ColorMasks
func NewEmptyColorMasks ¶
func NewEmptyColorMasks() ColorMasks
func (ColorMasks) Add ¶
func (masks ColorMasks) Add(color Color) ColorMasks
func (ColorMasks) Contains ¶
func (masks ColorMasks) Contains(color Color) bool
type Palette ¶
Palette is a group of rulesets. All colors are stored as Color struct, not as strings.
func OpenPaletteFromFile ¶
OpenPaletteFromFile returns a ready-use palette from a file.
func ReadPaletteFileYAML ¶
The ReadPaletteFileYAML function interprets the passed text as a config in YAML format and returns a ready-made palette.
func (*Palette) AddRuleset ¶
func (*Palette) ColorExists ¶
func (*Palette) GetColorByName ¶
func (*Palette) GetNameByColor ¶
func (*Palette) RegisterColorName ¶
type Rule ¶
type Rule struct { Colors []Color Masks ColorMasks Error string }
Rule are representation of human-written "api has-curl" => "error text" or "api allow-curl has-curl" => 1 All colors are pre-converted to numeric while reading strings.
func (*Rule) ContainsIn ¶
func (r *Rule) ContainsIn(colorMasks ColorMasks) bool
ContainsIn checks if the rule's colors are contained in the passed mask.