console

package
v0.0.0-...-de190fe Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fprint

func Fprint(w io.Writer, args ...interface{}) (n int, err error)

Fprint 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 Fprintf

func Fprintf(w io.Writer, format string, args ...interface{}) (n int, err error)

Fprintf formats according to a format specifier and writes to w. It returns the number of bytes written and any write error encountered.

func Fprintln

func Fprintln(w io.Writer, args ...interface{}) (n int, err error)

Fprintln formats using the default formats for its operands and writes to w. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func Print

func Print(args ...interface{}) (n int, err error)

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func Printf

func Printf(format string, args ...interface{}) (n int, err error)

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

func Println

func Println(args ...interface{}) (n int, err error)

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func Sprint

func Sprint(args ...interface{}) string

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.

func Sprintf

func Sprintf(format string, args ...interface{}) string

Sprintf formats according to a format specifier and returns the resulting string.

func Sprintln

func Sprintln(args ...interface{}) string

Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.

func TerminalHeight

func TerminalHeight(fw FileWriter) int

TerminalHeight returns the terminal height of given FileWriter.

func TerminalSize

func TerminalSize(fw FileWriter) (w, h int)

TerminalSize returns the terminal width and height of given FileWriter.

func TerminalWidth

func TerminalWidth(fw FileWriter) int

TerminalWidth returns the terminal width of given FileWriter.

Types

type FileWriter

type FileWriter interface {
	io.Writer
	Fd() uintptr
}

FileWriter is an io.Writer which also provides access to the file descriptor. The interface is satisfied by *os.File.

type Printer

type Printer struct {
	io.Writer
}

Printer wraps an io.Writer for writing colorful strings to it.

func NewPrinter

func NewPrinter(w io.Writer) *Printer

NewPrinter returns a new *Printer which writes to w.

func (*Printer) Print

func (p *Printer) Print(args ...interface{}) (n int, err error)

Print formats using the default formats for its operands and writes to the underlying io.Writer. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func (*Printer) Printf

func (p *Printer) Printf(format string, args ...interface{}) (n int, err error)

Printf formats according to a format specifier and writes to the underlying io.Writer. It returns the number of bytes written and any write error encountered.

func (*Printer) Println

func (p *Printer) Println(args ...interface{}) (n int, err error)

Println formats using the default formats for its operands and writes to to the underlying io.Writer. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

type Renderable

type Renderable interface {
	// Measure returns a width measurement which indicates the minimum and
	// maximum widths required to correctly render the Renderable. The passed
	// in maxWidth value indicates the maximum usable width.
	Measure(maxWidth int) measure.Measurement

	// Render renders the Renderable using the given width. If width is not
	// within the bounds returned by Measure, the rendered result may be
	// undefined.
	Render(width int) string
}

Renderable is an object that can be rendered to a console.

Jump to

Keyboard shortcuts

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