co

package module
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: MIT Imports: 6 Imported by: 0

README

co

The library for terminal output formatting with ANSI colors

Install

$ go get -u github.com/Binbiubiubiu/co

Example

package main

import (
	. "github.com/Binbiubiubiu/co"
)

func main() {
	println(GreenBright("Hello"), BgCyanBright(RedBright("Binbiubiubiu")))
}

Bench

$ go test -bench=. 
goos: darwin
goarch: amd64
pkg: github.com/Binbiubiubiu/co
cpu: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Benchmark_co-8                   1986559               606.8 ns/op
Benchmark_fatih_color-8           534586              2065 ns/op
Benchmark_gookit_color-8         1463462               804.2 ns/op
PASS
ok      github.com/Binbiubiubiu/co      6.429s

Thanks

colorette 🌈Easily set your terminal text color & styles.

Documentation

Overview

Example
fmt.Println(GreenBright("Hello"), BgCyanBright(RedBright("Binbiubiubiu")))
fmt.Println(Compose(BgGreen, Blue)("123"))
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	IsColorSupported = !isDisabled &&
		(isForced || (isWindows && !isDumbTerminal) || isCompatibleTerminal || isCI)
)

Functions

func BgBlack

func BgBlack(input string) string

func BgBlackBright

func BgBlackBright(input string) string

func BgBlue

func BgBlue(input string) string

func BgBlueBright

func BgBlueBright(input string) string

func BgCyan

func BgCyan(input string) string

func BgCyanBright

func BgCyanBright(input string) string

func BgGreen

func BgGreen(input string) string

func BgGreenBright

func BgGreenBright(input string) string

func BgMagenta

func BgMagenta(input string) string

func BgMagentaBright

func BgMagentaBright(input string) string

func BgRed

func BgRed(input string) string

func BgRedBright

func BgRedBright(input string) string

func BgWhite

func BgWhite(input string) string

func BgWhiteBright

func BgWhiteBright(input string) string

func BgYellow

func BgYellow(input string) string

func BgYellowBright

func BgYellowBright(input string) string

func Black

func Black(input string) string

func BlackBright

func BlackBright(input string) string

func Blue

func Blue(input string) string

func BlueBright

func BlueBright(input string) string

func Bold

func Bold(input string) string

func Compose added in v1.0.6

func Compose(styl ...StyleFunc) func(str string) string

func Cyan

func Cyan(input string) string

func CyanBright added in v0.1.2

func CyanBright(input string) string

func Dim

func Dim(input string) string

func Gray

func Gray(input string) string

func Green

func Green(input string) string

func GreenBright

func GreenBright(input string) string

func Hidden

func Hidden(input string) string

func Inverse

func Inverse(input string) string

func Italic

func Italic(input string) string

func Magenta

func Magenta(input string) string

func MagentaBright

func MagentaBright(input string) string

func Red

func Red(input string) string

func RedBright

func RedBright(input string) string

func Reset

func Reset(input string) string

func Strikethrough

func Strikethrough(input string) string

func Underline

func Underline(input string) string

func White

func White(input string) string

func WhiteBright

func WhiteBright(input string) string

func Yellow

func Yellow(input string) string

func YellowBright

func YellowBright(input string) string

Types

type Style added in v1.0.2

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

func CreateStyles added in v1.0.2

func CreateStyles() *Style

Create a ansi-style tool function

func UseStyles added in v1.0.2

func UseStyles(isColorSupported bool) *Style

Create a style utility function with isSupportColor

func (*Style) BgBlack added in v1.0.2

func (s *Style) BgBlack(input string) string

func (*Style) BgBlackBright added in v1.0.2

func (s *Style) BgBlackBright(input string) string

func (*Style) BgBlue added in v1.0.2

func (s *Style) BgBlue(input string) string

func (*Style) BgBlueBright added in v1.0.2

func (s *Style) BgBlueBright(input string) string

func (*Style) BgCyan added in v1.0.2

func (s *Style) BgCyan(input string) string

func (*Style) BgCyanBright added in v1.0.2

func (s *Style) BgCyanBright(input string) string

func (*Style) BgGreen added in v1.0.2

func (s *Style) BgGreen(input string) string

func (*Style) BgGreenBright added in v1.0.2

func (s *Style) BgGreenBright(input string) string

func (*Style) BgMagenta added in v1.0.2

func (s *Style) BgMagenta(input string) string

func (*Style) BgMagentaBright added in v1.0.2

func (s *Style) BgMagentaBright(input string) string

func (*Style) BgRed added in v1.0.2

func (s *Style) BgRed(input string) string

func (*Style) BgRedBright added in v1.0.2

func (s *Style) BgRedBright(input string) string

func (*Style) BgWhite added in v1.0.2

func (s *Style) BgWhite(input string) string

func (*Style) BgWhiteBright added in v1.0.2

func (s *Style) BgWhiteBright(input string) string

func (*Style) BgYellow added in v1.0.2

func (s *Style) BgYellow(input string) string

func (*Style) BgYellowBright added in v1.0.2

func (s *Style) BgYellowBright(input string) string

func (*Style) Black added in v1.0.2

func (s *Style) Black(input string) string

func (*Style) BlackBright added in v1.0.2

func (s *Style) BlackBright(input string) string

func (*Style) Blue added in v1.0.2

func (s *Style) Blue(input string) string

func (*Style) BlueBright added in v1.0.2

func (s *Style) BlueBright(input string) string

func (*Style) Bold added in v1.0.2

func (s *Style) Bold(input string) string

func (*Style) Cyan added in v1.0.2

func (s *Style) Cyan(input string) string

func (*Style) CyanBright added in v1.0.2

func (s *Style) CyanBright(input string) string

func (*Style) Dim added in v1.0.2

func (s *Style) Dim(input string) string

func (*Style) Gray added in v1.0.2

func (s *Style) Gray(input string) string

func (*Style) Green added in v1.0.2

func (s *Style) Green(input string) string

func (*Style) GreenBright added in v1.0.2

func (s *Style) GreenBright(input string) string

func (*Style) Hidden added in v1.0.2

func (s *Style) Hidden(input string) string

func (*Style) Inverse added in v1.0.2

func (s *Style) Inverse(input string) string

func (*Style) Italic added in v1.0.2

func (s *Style) Italic(input string) string

func (*Style) Magenta added in v1.0.2

func (s *Style) Magenta(input string) string

func (*Style) MagentaBright added in v1.0.2

func (s *Style) MagentaBright(input string) string

func (*Style) Red added in v1.0.2

func (s *Style) Red(input string) string

func (*Style) RedBright added in v1.0.2

func (s *Style) RedBright(input string) string

func (*Style) Reset added in v1.0.2

func (s *Style) Reset(input string) string

func (*Style) Strikethrough added in v1.0.2

func (s *Style) Strikethrough(input string) string

func (*Style) Underline added in v1.0.2

func (s *Style) Underline(input string) string

func (*Style) White added in v1.0.2

func (s *Style) White(input string) string

func (*Style) WhiteBright added in v1.0.2

func (s *Style) WhiteBright(input string) string

func (*Style) Yellow added in v1.0.2

func (s *Style) Yellow(input string) string

func (*Style) YellowBright added in v1.0.2

func (s *Style) YellowBright(input string) string

type StyleFunc added in v1.0.2

type StyleFunc func(string) string

Style formatting functions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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