color

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: MIT Imports: 6 Imported by: 2

README

说明

  1. 同时支持 windows linux的终端颜色
  2. 还支持goland的调试终端的颜色
  3. 为了不访问github和golang.org, 无奈之举把用到的库合并进来
  4. 只会考虑windows和linux, 其他平台不考虑

Documentation

Index

Constants

View Source
const (
	Black = iota + 30
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White
)

字体颜色

View Source
const (
	HiBlack = iota + 90
	HiRed
	HiGreen
	HiYellow
	HiBlue
	HiMagenta
	HiCyan
	HiWhite
)

高亮颜色

View Source
const (
	BgBlack = iota + 40
	BgRed
	BgGreen
	BgYellow
	BgBlue
	BgMagenta
	BgCyan
	BgWhite
)

背景色

View Source
const (
	BgHiBlack = iota + 100
	BgHiRed
	BgHiGreen
	BgHiYellow
	BgHiBlue
	BgHiMagenta
	BgHiCyan
	BgHiWhite
)

背景高亮色

View Source
const (
	Reset = iota
)

Variables

This section is empty.

Functions

func B added in v1.0.1

func B(color int) string

func Color added in v1.0.1

func Color(color int, str string) string

func ColorStr

func ColorStr(color int, format string, args ...interface{}) string

func E added in v1.0.1

func E() string

func IsCygwinTerminal

func IsCygwinTerminal(fd uintptr) bool

IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 terminal. This is also always false on this environment.

func IsTerminal

func IsTerminal(fd uintptr) bool

IsTerminal return true if the file descriptor is terminal.

func NewColorable

func NewColorable(file *os.File) io.Writer

NewColorable return new instance of Writer which handle escape sequence.

func NewColorableStderr

func NewColorableStderr() io.Writer

NewColorableStderr return new instance of Writer which handle escape sequence for stderr.

func NewColorableStdout

func NewColorableStdout() io.Writer

NewColorableStdout return new instance of Writer which handle escape sequence for stdout.

func NewNonColorable

func NewNonColorable(w io.Writer) io.Writer

NewNonColorable return new instance of Writer which remove escape sequence from Writer.

Types

type NonColorable

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

NonColorable hold writer but remove escape sequence.

func (*NonColorable) Write

func (w *NonColorable) Write(data []byte) (n int, err error)

Write write data on console

Directories

Path Synopsis
Package unix contains an interface to the low-level operating system primitives.
Package unix contains an interface to the low-level operating system primitives.

Jump to

Keyboard shortcuts

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