Documentation ¶
Overview ¶
Package gridtable implements a library for printing grid tables.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrColumnIndexOutOfRange indicates that an invalid column index was referenced. ErrColumnIndexOutOfRange = errors.New("column index out of range") // ErrShadowedCell indicates that a "shadowed" cell (one hidden by an already-spanned cell) was referenced. ErrShadowedCell = errors.New("wrote to shadowed cell") // ErrNegativeSpan indicates that a cell with a negative span was written. ErrNegativeSpan = errors.New("negative span") // ErrOverlappingSpans indicates that two different spans overlapped. ErrOverlappingSpans = errors.New("overlapping spans") // ErrSpanBeyondHeader indicates that a cell in the header spanned past the end of the header. ErrSpanBeyondHeader = errors.New("span extended beyond header") // ErrInvalidColumnSpec indicates that a column spec was invalid. ErrInvalidColumnSpec = errors.New("invalid column spec") // ErrBadWrap indicates that text could not be wrapped to fit into its column. ErrBadWrap = errors.New("text could not be wrapped") // ErrMalformedTable indicates that the grid table was malformed. ErrMalformedTable = errors.New("malformed grid table") // ErrReaderNotDone indicates that the requested operation requires the reader to have completely consumed the table already, // and it hasn't. ErrReaderNotDone = errors.New("reader not done reading table") )
Functions ¶
This section is empty.
Types ¶
type Cell ¶
type Cell struct { // The text to put into the cell. Text string // The number of additional rows this cell spans. 0 = no span. RowSpan int // The number of additional columns this cell spans. 0 = no span. ColSpan int }
Cell is the contents to write into the cell of a table.
type ColumnSpec ¶
type ColumnSpec struct { // Width of the column in number of characters (not counting the separators). Width int }
A ColumnSpec describes the parameters of a column.
type Config ¶
type Config struct { // The top `NumHeaderRows` are considered to be the header of the table. // 0 = no header. NumHeaderRows int // The specification of the columns in the table. Columns []ColumnSpec }
A Config configures the initialization of a Writer.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is an object that can be used to read in a grid table.
func NewReader ¶
NewReader instantiates a new Reader that reads table rows from an underlying io.Reader.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is an object that can be used to write out a grid table.
func NewWriter ¶
NewWriter initializes a new Writer based on the specified configuration. Rows are written to `out` as they become ready.
func (*Writer) NextRow ¶
func (w *Writer) NextRow()
NextRow finishes the current row and moves onto the next one.
Click to show internal directories.
Click to hide internal directories.