Documentation ¶
Overview ¶
Package tablewrappers exposes different ways to wrap text under display width constraint.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func DisplayWidth ¶
DisplayWidth yields the size of a string when rendered on a terminal.
ANSI escape sequences are discared.
Types ¶
type DefaultCellWrapper ¶
type DefaultCellWrapper struct { *DefaultWrapper // contains filtered or unexported fields }
DefaultCellWrapper wraps the content of a table with predefined constraints on column widths.
func NewDefaultCellWrapper ¶
func NewDefaultCellWrapper(matrix [][]string, colMaxWidth map[int]int, opts ...Option) *DefaultCellWrapper
func (*DefaultCellWrapper) WrapCell ¶
func (w *DefaultCellWrapper) WrapCell(row, col int) []string
type DefaultWrapper ¶
type DefaultWrapper struct {
// contains filtered or unexported fields
}
func (*DefaultWrapper) WrapString ¶
func (w *DefaultWrapper) WrapString(s string, limit int) []string
Wrap input string s into a paragraph of lines of limited length, with minimal raggedness.
type Option ¶
type Option func(*wrapOptions)
func WithWrapStrictMaxWidth ¶
func WithWrapWordSplitters ¶
WithWrapWordSplitters defines a wrapper's word boundaries split functions.
The default is to break words on IsSpace runes and new-line/carriage return.
type RowWrapper ¶
type RowWrapper struct {
// contains filtered or unexported fields
}
RowWrapper wraps the content of a table with a single constraint on the table width.
func NewRowWrapper ¶
func NewRowWrapper(matrix [][]string, rowWidthLimit int, opts ...Option) *RowWrapper
TODO: introduce colMaxWidth local limits for backward-compatible layout
func (*RowWrapper) WrapCell ¶
func (w *RowWrapper) WrapCell(row, col int) []string