flexibletable

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2018 License: BSD-3-Clause, BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alignment

type Alignment int

Alignment defines how the content of a cell should align

const (
	Left Alignment = iota // default
	Right
	Center
)

Possible Alignment values

type BadOptionError

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

BadOptionError indicates, well, bad options, are given.

func (BadOptionError) Error

func (e BadOptionError) Error() string

Error implements the error interface

type Cell

type Cell struct {
	// Content is the content of the cell. It can be either a SingleCell or a
	// MultiCell
	Content cellContent

	// Alignment specifies how the content of a cell should align
	Alignment Alignment

	// Frame defines a "frame" around the content. The array defines two strings,
	// which are added before and after the content, before any paddings are
	// inserted.
	Frame [2]string
}

Cell defines a cell (column) in a row

type ColumnConstraint

type ColumnConstraint int

ColumnConstraint specifies how a column should behave while being rendered. Use positive to specify a maximum width for the column, or one of const values for expandable width.

const (

	// Expandable is a special ColumnConstraint where the column and may expand
	// automatically if other columns end up taking less actual width.
	Expandable ColumnConstraint = 0

	// ExpandableWrappable is a special ColumnConstraint where the column is
	// expandable. In addition, it  can wrap into multiple lines if needed.
	ExpandableWrappable ColumnConstraint = -1
)

type InconsistentRowsError

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

InconsistentRowsError is an error that is returned when number of columns are inconsistent across rows.

func (InconsistentRowsError) Error

func (e InconsistentRowsError) Error() string

Error implements the error interface

type MultiCell

type MultiCell struct {
	// Sep is the separator between different items
	Sep string
	// Items are the content
	Items []string
}

MultiCell defines cell content with multiple strings. If being truncated, it looks like this: "item1,item2,+4..."

type NoRowsError

type NoRowsError struct{}

NoRowsError indicates no rows in the table.

func (NoRowsError) Error

func (e NoRowsError) Error() string

Error implements the error interface

type Row

type Row []Cell

Row defines a row

type SingleCell

type SingleCell struct {
	// Item is, well, the contnet.
	Item string
}

SingleCell defines cell content with a single string. If being truncated, the truncated part is replaced with "..."

type Table

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

Table defines a table and is used to do the rendering

func (*Table) Insert

func (t *Table) Insert(row Row) error

Insert inserts a row into the table

func (*Table) NumInserts added in v1.0.19

func (t *Table) NumInserts() int

func (Table) Render

func (t Table) Render(w io.Writer, cellSep string, maxWidth int, constraints []ColumnConstraint) error

Render renders the table into writer. The constraints parameter specifies how each column should be constrained while being rendered. Positive values limit the maximum width.

type WidthTooSmallError

type WidthTooSmallError struct{}

WidthTooSmallError indicates the width constraints is too small.

func (WidthTooSmallError) Error

func (e WidthTooSmallError) Error() string

Error implements the error interface

Jump to

Keyboard shortcuts

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