printer

package
v0.0.0-...-35061d5 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Black uint16
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White
)
View Source
const (
	BackgroundBlack uint16
	BackgroundRed
	BackgroundGreen
	BackgroundYellow
	BackgroundBlue
	BackgroundMagenta
	BackgroundCyan
	BackgroundWhite
)
View Source
const (
	// Bold flag for ColorScheme.
	Bold uint16 = 1<<bitsBold | NoColor
)
View Source
const (
	// No color
	NoColor uint16 = 1 << 15
)

Variables

View Source
var (
	DefaultOut = colorable.NewColorableStdout()
)
View Source
var (
	DefaultScheme = &ColorScheme{
		Bool:            Cyan | Bold,
		Integer:         Blue | Bold,
		Float:           Magenta | Bold,
		String:          Red,
		StringQuotation: Red | Bold,
		EscapedChar:     Magenta | Bold,
		FieldName:       Yellow,
		PointerAdress:   Blue | Bold,
		Nil:             Cyan | Bold,
		Time:            Blue | Bold,
		StructName:      Green,
		ObjectLength:    Blue,
	}
)

Functions

func ColorizeText

func ColorizeText(text string, color uint16) string

Types

type ColorField

type ColorField int
const (
	BoolColor ColorField
	IntegerColor
	FloatColor
	StringColor
	StringQuotationColor
	EscapedCharColor
	FieldNameColor
	PointerAdressColor
	NilColor
	TimeColor
	StructNameColor
	ObjectLengthColor
)

type ColorScheme

type ColorScheme struct {
	Bool            uint16
	Integer         uint16
	Float           uint16
	String          uint16
	StringQuotation uint16
	EscapedChar     uint16
	FieldName       uint16
	PointerAdress   uint16
	Nil             uint16
	Time            uint16
	StructName      uint16
	ObjectLength    uint16
}

func (ColorScheme) Get

func (s ColorScheme) Get(field ColorField) uint16

type Printer

type Printer struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

func NewPrinter

func NewPrinter(
	object interface{},
	colorScheme *ColorScheme,
	decimalUint bool,
	exportedOnly bool,
	thousandsSeparator bool,
) *Printer

func (*Printer) ColorPrint

func (p *Printer) ColorPrint(text string, color ColorField)

func (*Printer) Colorize

func (p *Printer) Colorize(text string, color ColorField) string

func (*Printer) Format

func (p *Printer) Format(object interface{}) string

func (*Printer) Indent

func (p *Printer) Indent() string

func (*Printer) IndentPrint

func (p *Printer) IndentPrint(text string)

func (*Printer) IndentPrintf

func (p *Printer) IndentPrintf(format string, args ...interface{})

func (*Printer) IsColoringEnabled

func (p *Printer) IsColoringEnabled() bool

func (*Printer) Print

func (p *Printer) Print(text string)

func (*Printer) PrintFieldValue

func (p *Printer) PrintFieldValue(k string, v any)

func (*Printer) PrintKeyValue

func (p *Printer) PrintKeyValue(k, v any)

func (*Printer) Printf

func (p *Printer) Printf(format string, args ...interface{})

func (*Printer) Println

func (p *Printer) Println(text string)

func (*Printer) String

func (p *Printer) String() string

Jump to

Keyboard shortcuts

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