terminal

package
v0.1.65 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Apache-2.0 Imports: 7 Imported by: 36

Documentation

Index

Constants

View Source
const (
	ResetCode   = escapePrefix + "0" + escapeSuffix
	RedCode     = escapePrefix + "31" + escapeSuffix
	GreenCode   = escapePrefix + "32" + escapeSuffix
	YellowCode  = escapePrefix + "33" + escapeSuffix
	BlueCode    = escapePrefix + "34" + escapeSuffix
	MagentaCode = escapePrefix + "35" + escapeSuffix
	CyanCode    = escapePrefix + "36" + escapeSuffix
)
View Source
const (
	TopSeparatorTableStyle = 1 << iota
	ColumnSeparatorTableStyle
	RowSeparatorTableStyle
	BottomSeparatorTableStyle
)
View Source
const IndentSpaces = 2

Variables

View Source
var Colorize = false
View Source
var DefaultStylist = NewStylist(false)
View Source
var Indent = strings.Repeat(" ", IndentSpaces)
View Source
var Quiet bool = false

Functions

func ColorBlue added in v0.1.21

func ColorBlue(s string) string

Colorizer signature

func ColorCyan added in v0.1.21

func ColorCyan(s string) string

Colorizer signature

func ColorGreen added in v0.1.21

func ColorGreen(s string) string

Colorizer signature

func ColorMagenta added in v0.1.21

func ColorMagenta(s string) string

Colorizer signature

func ColorRed added in v0.1.21

func ColorRed(s string) string

Colorizer signature

func ColorYellow added in v0.1.21

func ColorYellow(s string) string

Colorizer signature

func Eprint added in v0.1.25

func Eprint(args ...any) (int, error)

func Eprintf added in v0.1.25

func Eprintf(format string, args ...any) (int, error)

func Eprintln added in v0.1.25

func Eprintln(args ...any) (int, error)

func GetSize added in v0.1.1

func GetSize() (int, int, error)

func IndentString

func IndentString(indent int) string

func Options

func Options(options []string) string

func Print added in v0.1.25

func Print(args ...any) (int, error)

func PrintIndent

func PrintIndent(indent int)

func Printf added in v0.1.25

func Printf(format string, args ...any) (int, error)

func Println added in v0.1.25

func Println(args ...any) (int, error)

func StylizedOptions added in v0.1.24

func StylizedOptions(options []string, colorizer Colorizer) string

Types

type Cleanup added in v0.1.62

type Cleanup func() error

func EnableColor

func EnableColor(force bool) (Cleanup, error)

func ProcessColorizeFlag

func ProcessColorizeFlag(colorize string) (Cleanup, error)

type Colorizer

type Colorizer func(name string) string

type Stylist added in v0.1.24

type Stylist struct {
	Colorize bool
}

func NewStylist added in v0.1.24

func NewStylist(colorize bool) *Stylist

func (*Stylist) Error added in v0.1.24

func (self *Stylist) Error(name string) string

Colorizer signature

func (*Stylist) Heading added in v0.1.24

func (self *Stylist) Heading(name string) string

Colorizer signature

func (*Stylist) Name added in v0.1.24

func (self *Stylist) Name(name string) string

Colorizer signature

func (*Stylist) Path added in v0.1.24

func (self *Stylist) Path(name string) string

Colorizer signature

func (*Stylist) TypeName added in v0.1.24

func (self *Stylist) TypeName(name string) string

Colorizer signature

func (*Stylist) Value added in v0.1.24

func (self *Stylist) Value(name string) string

Colorizer signature

type Table

type Table struct {
	Rows     [][][]string
	Style    TableStyle
	MaxWidth int

	HeadingSeparator       string
	RowSeparator           string
	TopDividerSeparator    string
	TopDivider             string
	MiddleDividerSeparator string
	MiddleDivider          string
	BottomDividerSeparator string
	BottomDivider          string
}

func NewTable

func NewTable(width int, headings ...string) *Table

func (*Table) Add

func (self *Table) Add(cells ...string)

func (*Table) ColumnWidths

func (self *Table) ColumnWidths() (int, []int)

func (*Table) Print

func (self *Table) Print()

func (*Table) Wrap

func (self *Table) Wrap()

func (*Table) Write

func (self *Table) Write(writer io.Writer, stylist *Stylist)

type TableStyle

type TableStyle uint8

type TreePrefix

type TreePrefix []bool

func (TreePrefix) Print

func (self TreePrefix) Print(indent int, last bool)

Jump to

Keyboard shortcuts

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