1
0
mirror of https://github.com/strongdm/comply synced 2024-11-05 15:35:25 +00:00
comply/vendor/github.com/juju/ansiterm
2018-05-15 14:13:11 -07:00
..
tabwriter Initial commit 2018-05-15 14:13:11 -07:00
attribute.go Initial commit 2018-05-15 14:13:11 -07:00
color.go Initial commit 2018-05-15 14:13:11 -07:00
context.go Initial commit 2018-05-15 14:13:11 -07:00
doc.go Initial commit 2018-05-15 14:13:11 -07:00
LICENSE Initial commit 2018-05-15 14:13:11 -07:00
Makefile Initial commit 2018-05-15 14:13:11 -07:00
README.md Initial commit 2018-05-15 14:13:11 -07:00
style.go Initial commit 2018-05-15 14:13:11 -07:00
tabwriter.go Initial commit 2018-05-15 14:13:11 -07:00
terminal.go Initial commit 2018-05-15 14:13:11 -07:00
writer.go Initial commit 2018-05-15 14:13:11 -07:00

ansiterm

import "github.com/juju/ansiterm"

Package ansiterm provides a Writer that writes out the ANSI escape codes for color and styles.

type Color

type Color int

Color represents one of the standard 16 ANSI colors.

const (
    Default Color
    Black
    Red
    Green
    Yellow
    Blue
    Magenta
    Cyan
    Gray
    DarkGray
    BrightRed
    BrightGreen
    BrightYellow
    BrightBlue
    BrightMagenta
    BrightCyan
    White
)

func (Color) String

func (c Color) String() string

String returns the name of the color.

type Context

type Context struct {
    Foreground Color
    Background Color
    Styles     []Style
}

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.

func Background

func Background(color Color) *Context

Background is a convenience function that creates a Context with the specified color as the background color.

func Foreground

func Foreground(color Color) *Context

Foreground is a convenience function that creates a Context with the specified color as the foreground color.

func Styles

func Styles(styles ...Style) *Context

Styles is a convenience function that creates a Context with the specified styles set.

func (*Context) Fprint

func (c *Context) Fprint(w sgrWriter, args ...interface{})

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.

func (*Context) Fprintf

func (c *Context) Fprintf(w sgrWriter, format string, args ...interface{})

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.

func (*Context) SetBackground

func (c *Context) SetBackground(color Color) *Context

SetBackground sets the background to the specified color.

func (*Context) SetForeground

func (c *Context) SetForeground(color Color) *Context

SetForeground sets the foreground to the specified color.

func (*Context) SetStyle

func (c *Context) SetStyle(styles ...Style) *Context

SetStyle replaces the styles with the new values.

type Style

type Style int
const (
    Bold Style
    Faint
    Italic
    Underline
    Blink
    Reverse
    Strikethrough
    Conceal
)

func (Style) String

func (s Style) String() string

type TabWriter

type TabWriter struct {
    Writer
    // contains filtered or unexported fields
}

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.

func NewTabWriter

func NewTabWriter(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter

NewTabWriter returns a writer that is able to set colors and styels. The ansi escape codes are stripped for width calculations.

func (*TabWriter) Flush

func (t *TabWriter) Flush() error

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.

func (*TabWriter) Init

func (t *TabWriter) Init(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter

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

type Writer

type Writer struct {
    io.Writer
    // contains filtered or unexported fields
}

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.

func NewWriter

func NewWriter(w io.Writer) *Writer

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.

func (*Writer) ClearStyle

func (w *Writer) ClearStyle(s Style)

ClearStyle clears the text style.

func (*Writer) Reset

func (w *Writer) Reset()

Reset returns the default foreground and background colors with no styles.

func (*Writer) SetBackground

func (w *Writer) SetBackground(c Color)

SetBackground sets the background color.

func (*Writer) SetForeground

func (w *Writer) SetForeground(c Color)

SetForeground sets the foreground color.

func (*Writer) SetStyle

func (w *Writer) SetStyle(s Style)

SetStyle sets the text style.


Generated by godoc2md