printers

package
v0.0.0-...-95e0958 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	Content string
	Width   int
}

Cell is text with width information.

func MakeCells

func MakeCells(items []string) []Cell

MakeCells maps slice of strings into cells using go-runewidth package.

type DenseColumnMajor

type DenseColumnMajor struct {
	// contains filtered or unexported fields
}

DenseColumnMajor is a printer that displays items in a column-major table format.

func NewDenseColumnMajor

func NewDenseColumnMajor(width, spacing int) *DenseColumnMajor

NewDenseColumnMajor creates a DenseColumnMajor printer. The output format will be a table of given `width` in which columns are separated by `spacing` spaces.

func (*DenseColumnMajor) GetColumnSpacing

func (printer *DenseColumnMajor) GetColumnSpacing() int

GetColumnSpacing returns the space between columns.

func (*DenseColumnMajor) GetOutputWidth

func (printer *DenseColumnMajor) GetOutputWidth() int

GetOutputWidth returns the width of the table.

func (*DenseColumnMajor) Print

func (printer *DenseColumnMajor) Print(out io.Writer, cells []Cell) error

Print displays cells in a column-major table format.

type DenseRowMajor

type DenseRowMajor struct {
	// contains filtered or unexported fields
}

DenseRowMajor is a printer that displays items in a row-major table format.

func NewDenseRowMajor

func NewDenseRowMajor(width, spacing int) *DenseRowMajor

NewDenseRowMajor creates a DenseRowMajor printer. The output format will be a table of given `width` in which columns are separated by `spacing` spaces.

func (*DenseRowMajor) GetColumnSpacing

func (printer *DenseRowMajor) GetColumnSpacing() int

GetColumnSpacing returns the space between columns.

func (*DenseRowMajor) GetOutputWidth

func (printer *DenseRowMajor) GetOutputWidth() int

GetOutputWidth returns the width of the table.

func (*DenseRowMajor) Print

func (printer *DenseRowMajor) Print(out io.Writer, cells []Cell) error

Print displays cells in a row-major table format.

type Interface

type Interface interface {
	Print(out io.Writer, cells []Cell) error
}

Interface defines functions provided by printers. A printer writes given cells (strings with width information) to a Writer in a specific format.

Jump to

Keyboard shortcuts

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