colorize

package module
v0.0.0-...-958e258 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoColor                = ""
	DefaultColor           = "white"
	YellowColor            = "yellow"
	GreenColor             = "green"
	GoldenRodColor         = "goldenrod"
	OrangeColor            = "orange"
	TealColor              = "teal"
	CornSilkColor          = "cornsilk"
	DeepPinkColor          = "deeppink"
	RedColor               = "red"
	BlueColor              = "blue"
	LightBlueColor         = "lightblue"
	LightCoralColor        = "lightcoral"
	LightCyanColor         = "lightcyan"
	LavenderColor          = "lavender"
	LightSalmonColor       = "lightsalmon"
	MediumBlueColor        = "mediumblue"
	MistyRoseColor         = "mistyrose"
	SkyBlueColor           = "skyblue"
	LightSkyBlueColor      = "lightskyblue"
	MediumSpringGreenColor = "mediumspringgreen"
	WheatColor             = "wheat"
	YellowGreenColor       = "yellowgreen"
	LightYellowColor       = "lightyellow"
	DarkOrangeColor        = "darkorange"
	LightGreenColor        = "lightgreen"
	DarkMagentaColor       = "darkmagenta"
	CyanColor              = "aqua"
)

Color constant names we can use

Variables

This section is empty.

Functions

func Blue

func Blue(a interface{}, w ...interface{}) string

Blue - return string based on the color given

func ColorWithName

func ColorWithName(color string, a interface{}, w ...interface{}) string

ColorWithName - Find and set the color by name. This function takes a color name as a string, converts it to lowercase, and checks if it exists in the tcell.ColorNames map. If it does, the color is used. If it doesn't, the color is set to the default color, OrangeColor. Then, it calls the Colorize function with the determined color, the provided value, and any additional parameters.

Parameters: - color: A string representing the color name. - a: The value to be colorized. It can be of type string, integer, float, or any other type. - w: A variadic parameter that can contain optional width, precision, foreground color, background color, and flags.

Returns: - A string with the colorized value.

Usage:

colorize.ColorWithName("red", "Hello, World!", 20, 2, "yellow", "blue")
colorize.ColorWithName("", 123.456, 10, 2)
colorize.ColorWithName("green", "Goodbye", -10) // Left alignment

func Colorize

func Colorize(color string, v interface{}, w ...interface{}) string

Colorize function is used to add color to the value passed, with optional width, precision, foreground color, background color, and flags.

Parameters: - color: A string representing the color to be applied. If empty, the default foreground color will be used. - v: The value to be colorized. It can be of type string, integer, float, or any other type. - w: A variadic parameter that can contain optional width, precision, foreground color, background color, and flags.

Returns: - A string with the colorized value.

Usage:

colorize.Colorize("red", "Hello, World!", 20, 2, "yellow", "blue")
colorize.Colorize("", 123.456, 10, 2)
colorize.Colorize("green", "Goodbye", -10) // Left alignment

func CornSilk

func CornSilk(a interface{}, w ...interface{}) string

CornSilk - return string based on the color given

func Cyan

func Cyan(a interface{}, w ...interface{}) string

Cyan - return string based on the color given

func DarkMagenta

func DarkMagenta(a interface{}, w ...interface{}) string

DarkMagenta - return string based on the color given

func DarkOrange

func DarkOrange(a interface{}, w ...interface{}) string

DarkOrange - return string based on the color given

func DeepPink

func DeepPink(a interface{}, w ...interface{}) string

DeepPink - return string based on the color given

func Default

func Default(a interface{}, w ...interface{}) string

Default - The default color for the text

func DefaultBackgroundColor

func DefaultBackgroundColor() string

DefaultBackgroundColor returns the default color

func DefaultFlags

func DefaultFlags() string

DefaultFlags returns the default flags

func DefaultForegroundColor

func DefaultForegroundColor() string

DefaultForegroundColor returns the default color

func DefaultWidth

func DefaultWidth() int

DefaultWidth returns the default width

func FloatPrecision

func FloatPrecision() int

FloatPrecision returns the default precision

func GoldenRod

func GoldenRod(a interface{}, w ...interface{}) string

GoldenRod - return string based on the color given

func Green

func Green(a interface{}, w ...interface{}) string

Green - return string based on the color given

func Lavender

func Lavender(a interface{}, w ...interface{}) string

Lavender - return string based on the color given

func LightBlue

func LightBlue(a interface{}, w ...interface{}) string

LightBlue - return string based on the color given

func LightCoral

func LightCoral(a interface{}, w ...interface{}) string

LightCoral - return string based on the color given

func LightCyan

func LightCyan(a interface{}, w ...interface{}) string

LightCyan - return string based on the color given

func LightGreen

func LightGreen(a interface{}, w ...interface{}) string

LightGreen - return string based on the color given

func LightSalmon

func LightSalmon(a interface{}, w ...interface{}) string

LightSalmon - return string based on the color given

func LightSkyBlue

func LightSkyBlue(a interface{}, w ...interface{}) string

LightSkyBlue - return string based on the color given

func LightYellow

func LightYellow(a interface{}, w ...interface{}) string

LightYellow - return string based on the color given

func MediumBlue

func MediumBlue(a interface{}, w ...interface{}) string

MediumBlue - return string based on the color given

func MediumSpringGreen

func MediumSpringGreen(a interface{}, w ...interface{}) string

MediumSpringGreen - return string based on the color given

func MistyRose

func MistyRose(a interface{}, w ...interface{}) string

MistyRose - return string based on the color given

func Orange

func Orange(a interface{}, w ...interface{}) string

Orange - return string based on the color given

func Red

func Red(a interface{}, w ...interface{}) string

Red - return string based on the color given

func SetDefault

func SetDefault(foreground, background string, width, precision int, flags string)

SetDefault initializes the colorizeInfo struct with default values for color, width, precision, and flags. If precision is negative, it is set to the default value.

Parameters: - foreground: A string representing the default foreground color. - background: A string representing the default background color. - width: An integer representing the default width of the field. - precision: An integer representing the default precision for float values. - flags: A string representing the default flags for color attributes.

func SetDefaultBackgroundColor

func SetDefaultBackgroundColor(color string)

SetDefaultBackgroundColor - Set the default background color

func SetDefaultFlags

func SetDefaultFlags(f string)

SetDefaultFlags - Set flags

func SetDefaultForegroundColor

func SetDefaultForegroundColor(color string)

SetDefaultForegroundColor - Set the default foreground color

func SetDefaultWidth

func SetDefaultWidth(w int)

SetDefaultWidth - Set the default width

func SetFloatPrecision

func SetFloatPrecision(w int)

SetFloatPrecision - Set float precision

func SkyBlue

func SkyBlue(a interface{}, w ...interface{}) string

SkyBlue - return string based on the color given

func Teal

func Teal(a interface{}, w ...interface{}) string

Teal - return string based on the color given

func Wheat

func Wheat(a interface{}, w ...interface{}) string

Wheat - return string based on the color given

func Yellow

func Yellow(a interface{}, w ...interface{}) string

Yellow - return string based on the color given

func YellowGreen

func YellowGreen(a interface{}, w ...interface{}) string

YellowGreen - return string based on the color given

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL