package ansiterm

Import Path
	github.com/juju/ansiterm (on go.dev)

Dependency Relation
	imports 8 packages, and imported by one package

Involved Source Files attribute.go color.go context.go Package ansiterm provides a Writer that writes out the ANSI escape codes for color and styles. style.go tabwriter.go terminal.go writer.go
Package-Level Type Names (total 9, in which 5 are exported)
/* sort exporteds by: | */
Color represents one of the standard 16 ANSI colors. String returns the name of the color. T : fmt.Stringer func Background(color Color) *Context func Foreground(color Color) *Context func (*Context).SetBackground(color Color) *Context func (*Context).SetForeground(color Color) *Context func (*Writer).SetBackground(c Color) func (*Writer).SetForeground(c Color) const Black const Blue const BrightBlue const BrightCyan const BrightGreen const BrightMagenta const BrightRed const BrightYellow const Cyan const DarkGray const Default const Gray const Green const Magenta const Red const White const Yellow
Context provides a way to specify both foreground and background colors along with other styles and write text to a Writer with those colors and styles. Background Color Foreground Color Styles []Style Fprint will set the sgr values of the writer to the specified foreground, background and styles, then formats using the default formats for its operands and writes to w. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered. Fprintf will set the sgr values of the writer to the specified foreground, background and styles, then write the formatted string, then reset the writer. SetBackground sets the background to the specified color. SetForeground sets the foreground to the specified color. SetStyle replaces the styles with the new values. func Background(color Color) *Context func Foreground(color Color) *Context func Styles(styles ...Style) *Context func (*Context).SetBackground(color Color) *Context func (*Context).SetForeground(color Color) *Context func (*Context).SetStyle(styles ...Style) *Context
( T) String() string T : fmt.Stringer func Styles(styles ...Style) *Context func (*Context).SetStyle(styles ...Style) *Context func (*Writer).ClearStyle(s Style) func (*Writer).SetStyle(s Style) const Blink const Bold const Conceal const Faint const Italic const Reverse const Strikethrough const Underline
TabWriter is a filter that inserts padding around tab-delimited columns in its input to align them in the output. It also setting of colors and styles over and above the standard tabwriter package. Writer Writer ClearStyle clears the text style. Flush should be called after the last call to Write to ensure that any data buffered in the Writer is written to output. Any incomplete escape sequence at the end is considered complete for formatting purposes. A Writer must be initialized with a call to Init. The first parameter (output) specifies the filter output. The remaining parameters control the formatting: minwidth minimal cell width including any padding tabwidth width of tab characters (equivalent number of spaces) padding padding added to a cell before computing its width padchar ASCII char used for padding if padchar == '\t', the Writer will assume that the width of a '\t' in the formatted output is tabwidth, and cells are left-aligned independent of align_left (for correct-looking results, tabwidth must correspond to the tab width in the viewer displaying the result) flags formatting control Reset returns the default foreground and background colors with no styles. SetBackground sets the background color. SetColorCapable forces the writer to either write the ANSI escape color if capable is true, or to not write them if capable is false. SetColumnAlignRight will mark a particular column as align right. This is reset on the next flush. SetForeground sets the foreground color. SetStyle sets the text style. ( T) Write(p []byte) (n int, err error) T : io.Writer func NewTabWriter(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter func (*TabWriter).Init(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter
Writer allows colors and styles to be specified. If the io.Writer is not a terminal capable of color, all attempts to set colors or styles are no-ops. Writer io.Writer ClearStyle clears the text style. Reset returns the default foreground and background colors with no styles. SetBackground sets the background color. SetColorCapable forces the writer to either write the ANSI escape color if capable is true, or to not write them if capable is false. SetForeground sets the foreground color. SetStyle sets the text style. ( T) Write(p []byte) (n int, err error) T : io.Writer func NewWriter(w io.Writer) *Writer
Package-Level Functions (total 6, in which 5 are exported)
Background is a convenience function that creates a Context with the specified color as the background color.
Foreground is a convenience function that creates a Context with the specified color as the foreground color.
NewTabWriter returns a writer that is able to set colors and styels. The ansi escape codes are stripped for width calculations.
NewWriter returns a Writer that allows the caller to specify colors and styles. If the io.Writer is not a terminal capable of color, all attempts to set colors or styles are no-ops.
Styles is a convenience function that creates a Context with the specified styles set.
Package-Level Constants (total 27, in which 25 are exported)
const Black Color = 2
const Blue Color = 6
const Bold Style = 1
const BrightBlue Color = 14
const BrightCyan Color = 16
const BrightGreen Color = 12
const BrightMagenta Color = 15
const BrightRed Color = 11
const BrightYellow Color = 13
const Conceal Style = 8
const Cyan Color = 8
const DarkGray Color = 10
const Default Color = 1
const Faint Style = 2
const Gray Color = 9
const Green Color = 4
const Italic Style = 3
const Magenta Color = 7
const Red Color = 3
const Reverse Style = 6
const Strikethrough Style = 7
const Underline Style = 4
const White Color = 17
const Yellow Color = 5