Module utils

Module utils 

Source

Constants§

DEFAULT_ANSI_ALL_COLORS

Functions§

color_palette
Creates a HashMap of ANSI color codes from the given entries.
colorize_text
Replaces placeholders in a string with ANSI escape codes to colorize the output.
get_ascii_and_colors
Given a distro name, returns a string of its corresponding ASCII art. If the distro isn’t found, an empty string is returned. If the distro is “off”, an empty string is returned.
get_bar
Generates a visual bar representation of a percentage using Unicode blocks.
get_colors_in_order
Given a slice of color indices or a distro name, generates a HashMap of cX keys (where X is the index, starting from 1) mapped to the corresponding ANSI foreground color codes.
get_custom_ascii
Reads a file at the given custom path and returns its content as a string. If there is an error while reading the file, an empty string is returned.
get_custom_colors_order
Given a string of comma-separated color indices or a distro name, returns a HashMap of color codes c0 to cX as found in the given distro’s color definition. The color codes are from the ANSI color palette.
get_distro_colors
Given a distro name, returns a HashMap of color codes c0 to cX as found in the given distro’s color definition. The color codes are from the ANSI color palette. If the distro isn’t found, an empty HashMap is returned.
get_terminal_color
Generates a vector of 2 strings, each containing a row of 8 blocks colored with different ANSI foreground colors. The first string has normal colors, the second has bold colors.