terminal

package
v0.3.24 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 7 Imported by: 35

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 IndentSpaces = 2

Variables

View Source
var ColorizeStderr bool
View Source
var ColorizeStdout bool
View Source
var Indent = strings.Repeat(" ", IndentSpaces)
View Source
var Quiet bool = false
View Source
var StderrStylist = NewStylist(false)
View Source
var StdoutStylist = NewStylist(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 InitializeColorization added in v0.3.9

func InitializeColorization(colorize string) (CleanupFunc, CleanupFunc, error)

Attempts to enable colorization for os.Stdout and os.Stderr according to the colorize argument. If it succeeds it may return two [CleanupFunc]s that should be called to restore os.Stdout and os.Stderr to their original mode. The [CleanupFunc]s may also be nil.

The colorize argument can be:

Other colorize values will return an error.

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 CleanupFunc added in v0.3.9

type CleanupFunc func() error

func EnableColor

func EnableColor(file *os.File) (bool, CleanupFunc, error)

Returns true if the file supports colorization.

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 int
const (
	TopSeparatorTableStyle TableStyle = 1 << iota
	ColumnSeparatorTableStyle
	RowSeparatorTableStyle
	BottomSeparatorTableStyle
)

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