tint

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2019 License: Apache-2.0 Imports: 3 Imported by: 3

README

Tint aims to provide functions that you can use to color your cli text output.

Contributing to this project

First step is to read the contributing and that is about it.

Trello board

I use this trello board to track changes for this project and any new feature, bug or ideas for upcoming releases are posted here.

Import

go get github.com/printzero/tint

License

This project is licensed under Apache 2.0

Documentation

Index

Constants

View Source
const (
	// Normal equates to no style
	Normal color = iota
	// Black color brackets in ansi format
	Black
	// Red color
	Red
	// Green color
	Green
	// Yellow color
	Yellow
	// Blue color
	Blue
	// Magenta color
	Magenta
	// Cyan color
	Cyan
	// White color
	White
	// BlackBright color
	BlackBright
	// RedBright color
	RedBright
	// GreenBright color
	GreenBright
	// YellowBright color
	YellowBright
	// BlueBright color
	BlueBright
	// MagentaBright color
	MagentaBright
	// CyanBright color
	CyanBright
	// WhiteBright color
	WhiteBright

	// BgBlack color
	BgBlack
	// BgRed color
	BgRed
	// BgGreen color
	BgGreen
	// BgYellow color
	BgYellow
	// BgBlue color
	BgBlue
	// BgMagenta color
	BgMagenta
	// BgCyan color
	BgCyan
	// BgWhite color
	BgWhite
	// Hyperlink text
	Hyperlink
	// Dim text
	Dim
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Mixin

type Mixin struct {
	// contains filtered or unexported fields
}

Mixin helps bind a color to a specific text

type TerminalLevel

type TerminalLevel int

TerminalLevel of color support for terminal and how does tint works with these levels

const (
	// LevelNone for terminal that supports no colot
	LevelNone TerminalLevel = iota + 1
	// Level16bit for terminal that supports 16bit colors
	Level16bit
	// Level256 for terminal that supports 256 bit colors
	Level256
	// Level16m for terminal that supports 16 million colors (truecolor)
	Level16m
)

type Tint

type Tint struct {
	Level         TerminalLevel
	SupportsColor bool
	LogInstance   *log.Logger
}

Tint struct holds the whole library

func Init

func Init() *Tint

Init initializes variables that tint uses and then returns the pointer to a Tint struct

func (*Tint) Exp

func (t *Tint) Exp(expStr string) string

Exp returns a string constructed from a series of color expressions given as an argument

func (*Tint) Log

func (t *Tint) Log(text string, colors ...color)

Log text with the standard lib log module

func (*Tint) Palette

func (t *Tint) Palette(mixins ...Mixin) string

Palette lets you build a string with specific words with different background or foreground color of your choice NOTE: no need to specify space character at end of mixin

func (*Tint) Print

func (t *Tint) Print(text string, colors ...color)

Print single line of text with specified color

func (*Tint) Println

func (t *Tint) Println(text string, colors ...color)

Println single line of text with enter character

func (*Tint) Raw

func (t *Tint) Raw(text string, colors ...color) string

Raw returns the raw string with applied colors

func (*Tint) Swatch

func (t *Tint) Swatch(colors ...color) func(text string)

Swatch helps you create your own function with spesified color Example:

green := tint.Swatch(tint.Green)

func (*Tint) SwatchRaw

func (t *Tint) SwatchRaw(colors ...color) func(text string) string

SwatchRaw returns a functions that returns a raw colored string

func (*Tint) With

func (t *Tint) With(text string, colors ...color) Mixin

With is used to build a Mixin with text and color

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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