colr

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 1 Imported by: 1

README

colr

An extremely lightweight cross-platform package to colorize text in terminals.

This is not meant for maximal compatibility, nor is it meant to handle a plethora of scenarios. It will simply wrap a message with the necessary characters, if the OS handles it.

Based on go-color

Usage

go get g.tizu.dev/colr
Using Functions
package main

import "g.tizu.dev/colr"

func main() {
	// Special
	println(colr.Bold("hello!"))
	println(colr.Dim("hello!"))
	println(colr.Italic("hello!"))
	println(colr.Underline("hello!"))
	println(colr.Blink("hello!"))
	println(colr.Strikethrough("hello!"))

	// Text colors
	println(colr.Black("hello!"))
	println(colr.Red("hello!"))
	println(colr.Green("hello!"))
	println(colr.Yellow("hello!"))
	println(colr.Blue("hello!"))
	println(colr.Purple("hello!"))
	println(colr.Cyan("hello!"))
	println(colr.Gray("hello!"))
	println(colr.White("hello!"))

	// back colors
	println(colr.OnBlack("hello!"))
	println(colr.OnRed("hello!"))
	println(colr.OnGreen("hello!"))
	println(colr.OnYellow("hello!"))
	println(colr.OnBlue("hello!"))
	println(colr.OnPurple("hello!"))
	println(colr.OnCyan("hello!"))
	println(colr.OnGray("hello!"))
	println(colr.OnWhite("hello!"))

	// .. or combined
	println(colr.BlackOnBlack("hello!"))
	println(colr.BlackOnRed("hello!"))
	println(colr.BlackOnGreen("hello!"))
	println(colr.BlackOnYellow("hello!"))
	println(colr.BlackOnBlue("hello!"))
	println(colr.BlackOnPurple("hello!"))
	println(colr.BlackOnCyan("hello!"))
	println(colr.BlackOnGray("hello!"))
	println(colr.BlackOnWhite("hello!"))
	println(colr.RedOnBlack("hello!"))
	println(colr.RedOnRed("hello!"))
	println(colr.RedOnGreen("hello!"))
	println(colr.RedOnYellow("hello!"))
	println(colr.RedOnBlue("hello!"))
	println(colr.RedOnPurple("hello!"))
	println(colr.RedOnCyan("hello!"))
	println(colr.RedOnGray("hello!"))
	println(colr.RedOnWhite("hello!"))
	println(colr.GreenOnBlack("hello!"))
	println(colr.GreenOnRed("hello!"))
	println(colr.GreenOnGreen("hello!"))
	println(colr.GreenOnYellow("hello!"))
	println(colr.GreenOnBlue("hello!"))
	println(colr.GreenOnPurple("hello!"))
	println(colr.GreenOnCyan("hello!"))
	println(colr.GreenOnGray("hello!"))
	println(colr.GreenOnWhite("hello!"))
	println(colr.YellowOnBlack("hello!"))
	println(colr.YellowOnRed("hello!"))
	println(colr.YellowOnGreen("hello!"))
	println(colr.YellowOnYellow("hello!"))
	println(colr.YellowOnBlue("hello!"))
	println(colr.YellowOnPurple("hello!"))
	println(colr.YellowOnCyan("hello!"))
	println(colr.YellowOnGray("hello!"))
	println(colr.YellowOnWhite("hello!"))
	println(colr.BlueOnBlack("hello!"))
	println(colr.BlueOnRed("hello!"))
	println(colr.BlueOnGreen("hello!"))
	println(colr.BlueOnYellow("hello!"))
	println(colr.BlueOnBlue("hello!"))
	println(colr.BlueOnPurple("hello!"))
	println(colr.BlueOnCyan("hello!"))
	println(colr.BlueOnGray("hello!"))
	println(colr.BlueOnWhite("hello!"))
	println(colr.PurpleOnBlack("hello!"))
	println(colr.PurpleOnRed("hello!"))
	println(colr.PurpleOnGreen("hello!"))
	println(colr.PurpleOnYellow("hello!"))
	println(colr.PurpleOnBlue("hello!"))
	println(colr.PurpleOnPurple("hello!"))
	println(colr.PurpleOnCyan("hello!"))
	println(colr.PurpleOnGray("hello!"))
	println(colr.PurpleOnWhite("hello!"))
	println(colr.CyanOnBlack("hello!"))
	println(colr.CyanOnRed("hello!"))
	println(colr.CyanOnGreen("hello!"))
	println(colr.CyanOnYellow("hello!"))
	println(colr.CyanOnBlue("hello!"))
	println(colr.CyanOnPurple("hello!"))
	println(colr.CyanOnCyan("hello!"))
	println(colr.CyanOnGray("hello!"))
	println(colr.CyanOnWhite("hello!"))
	println(colr.GrayOnBlack("hello!"))
	println(colr.GrayOnRed("hello!"))
	println(colr.GrayOnGreen("hello!"))
	println(colr.GrayOnYellow("hello!"))
	println(colr.GrayOnBlue("hello!"))
	println(colr.GrayOnPurple("hello!"))
	println(colr.GrayOnCyan("hello!"))
	println(colr.GrayOnGray("hello!"))
	println(colr.GrayOnWhite("hello!"))
	println(colr.WhiteOnBlack("hello!"))
	println(colr.WhiteOnRed("hello!"))
	println(colr.WhiteOnGreen("hello!"))
	println(colr.WhiteOnYellow("hello!"))
	println(colr.WhiteOnBlue("hello!"))
	println(colr.WhiteOnPurple("hello!"))
	println(colr.WhiteOnCyan("hello!"))
	println(colr.WhiteOnGray("hello!"))
	println(colr.WhiteOnWhite("hello!"))
}
Examples
println("My name is " + colr.Green("John Doe") + " and I have " + colr.Red(32) + " apples.")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Black

func Black(s any) string

func BlackOnBlack

func BlackOnBlack(s any) string

func BlackOnBlue

func BlackOnBlue(s any) string

func BlackOnCyan

func BlackOnCyan(s any) string

func BlackOnGray

func BlackOnGray(s any) string

func BlackOnGreen

func BlackOnGreen(s any) string

func BlackOnPurple

func BlackOnPurple(s any) string

func BlackOnRed

func BlackOnRed(s any) string

func BlackOnWhite

func BlackOnWhite(s any) string

func BlackOnYellow

func BlackOnYellow(s any) string
func Blink(s any) string

func Blue

func Blue(s any) string

func BlueOnBlack

func BlueOnBlack(s any) string

func BlueOnBlue

func BlueOnBlue(s any) string

func BlueOnCyan

func BlueOnCyan(s any) string

func BlueOnGray

func BlueOnGray(s any) string

func BlueOnGreen

func BlueOnGreen(s any) string

func BlueOnPurple

func BlueOnPurple(s any) string

func BlueOnRed

func BlueOnRed(s any) string

func BlueOnWhite

func BlueOnWhite(s any) string

func BlueOnYellow

func BlueOnYellow(s any) string

func Bold

func Bold(s any) string

func Cyan

func Cyan(s any) string

func CyanOnBlack

func CyanOnBlack(s any) string

func CyanOnBlue

func CyanOnBlue(s any) string

func CyanOnCyan

func CyanOnCyan(s any) string

func CyanOnGray

func CyanOnGray(s any) string

func CyanOnGreen

func CyanOnGreen(s any) string

func CyanOnPurple

func CyanOnPurple(s any) string

func CyanOnRed

func CyanOnRed(s any) string

func CyanOnWhite

func CyanOnWhite(s any) string

func CyanOnYellow

func CyanOnYellow(s any) string

func Dim

func Dim(s any) string

func Gray

func Gray(s any) string

func GrayOnBlack

func GrayOnBlack(s any) string

func GrayOnBlue

func GrayOnBlue(s any) string

func GrayOnCyan

func GrayOnCyan(s any) string

func GrayOnGray

func GrayOnGray(s any) string

func GrayOnGreen

func GrayOnGreen(s any) string

func GrayOnPurple

func GrayOnPurple(s any) string

func GrayOnRed

func GrayOnRed(s any) string

func GrayOnWhite

func GrayOnWhite(s any) string

func GrayOnYellow

func GrayOnYellow(s any) string

func Green

func Green(s any) string

func GreenOnBlack

func GreenOnBlack(s any) string

func GreenOnBlue

func GreenOnBlue(s any) string

func GreenOnCyan

func GreenOnCyan(s any) string

func GreenOnGray

func GreenOnGray(s any) string

func GreenOnGreen

func GreenOnGreen(s any) string

func GreenOnPurple

func GreenOnPurple(s any) string

func GreenOnRed

func GreenOnRed(s any) string

func GreenOnWhite

func GreenOnWhite(s any) string

func GreenOnYellow

func GreenOnYellow(s any) string

func Italic

func Italic(s any) string

func OnBlack

func OnBlack(s any) string

func OnBlue

func OnBlue(s any) string

func OnCyan

func OnCyan(s any) string

func OnGray

func OnGray(s any) string

func OnGreen

func OnGreen(s any) string

func OnPurple

func OnPurple(s any) string

func OnRed

func OnRed(s any) string

func OnWhite

func OnWhite(s any) string

func OnYellow

func OnYellow(s any) string

func Purple

func Purple(s any) string

func PurpleOnBlack

func PurpleOnBlack(s any) string

func PurpleOnBlue

func PurpleOnBlue(s any) string

func PurpleOnCyan

func PurpleOnCyan(s any) string

func PurpleOnGray

func PurpleOnGray(s any) string

func PurpleOnGreen

func PurpleOnGreen(s any) string

func PurpleOnPurple

func PurpleOnPurple(s any) string

func PurpleOnRed

func PurpleOnRed(s any) string

func PurpleOnWhite

func PurpleOnWhite(s any) string

func PurpleOnYellow

func PurpleOnYellow(s any) string

func Red

func Red(s any) string

func RedOnBlack

func RedOnBlack(s any) string

func RedOnBlue

func RedOnBlue(s any) string

func RedOnCyan

func RedOnCyan(s any) string

func RedOnGray

func RedOnGray(s any) string

func RedOnGreen

func RedOnGreen(s any) string

func RedOnPurple

func RedOnPurple(s any) string

func RedOnRed

func RedOnRed(s any) string

func RedOnWhite

func RedOnWhite(s any) string

func RedOnYellow

func RedOnYellow(s any) string

func Strikethrough

func Strikethrough(s any) string

func Underline

func Underline(s any) string

func White

func White(s any) string

func WhiteOnBlack

func WhiteOnBlack(s any) string

func WhiteOnBlue

func WhiteOnBlue(s any) string

func WhiteOnCyan

func WhiteOnCyan(s any) string

func WhiteOnGray

func WhiteOnGray(s any) string

func WhiteOnGreen

func WhiteOnGreen(s any) string

func WhiteOnPurple

func WhiteOnPurple(s any) string

func WhiteOnRed

func WhiteOnRed(s any) string

func WhiteOnWhite

func WhiteOnWhite(s any) string

func WhiteOnYellow

func WhiteOnYellow(s any) string

func Yellow

func Yellow(s any) string

func YellowOnBlack

func YellowOnBlack(s any) string

func YellowOnBlue

func YellowOnBlue(s any) string

func YellowOnCyan

func YellowOnCyan(s any) string

func YellowOnGray

func YellowOnGray(s any) string

func YellowOnGreen

func YellowOnGreen(s any) string

func YellowOnPurple

func YellowOnPurple(s any) string

func YellowOnRed

func YellowOnRed(s any) string

func YellowOnWhite

func YellowOnWhite(s any) string

func YellowOnYellow

func YellowOnYellow(s any) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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