Documentation ¶
Overview ¶
Package tablewriter creates & generates text based table
Index ¶
- Constants
- func ConditionString(cond bool, valid, inValid string) string
- func DisplayWidth(str string) int
- func Pad(s, pad string, width int) string
- func PadLeft(s, pad string, width int) string
- func PadRight(s, pad string, width int) string
- func Title(name string) string
- func WrapString(s string, lim int) ([]string, int)
- func WrapWords(words []string, spc, lim, pen int) [][]string
- type Border
- type Table
- func (t *Table) Append(row []string)
- func (t *Table) AppendBulk(rows [][]string)
- func (t *Table) RenderAll()
- func (t *Table) SetAlignment(align int)
- func (t *Table) SetAutoFormatHeaders(auto bool)
- func (t *Table) SetAutoWrapText(auto bool)
- func (t *Table) SetBorder(border bool)
- func (t *Table) SetBorders(border Border)
- func (t *Table) SetCellTrans(row, col int, trans textTransFunc)
- func (t *Table) SetCenterSeparator(sep string)
- func (t *Table) SetColTrans(col int, trans textTransFunc)
- func (t *Table) SetColWidth(width int)
- func (t *Table) SetColumnSeparator(sep string)
- func (t *Table) SetFooter(keys []string)
- func (t *Table) SetFooterAlignment(fAlign int)
- func (t *Table) SetHeader(keys []string)
- func (t *Table) SetHeaderAlignment(hAlign int)
- func (t *Table) SetHeaderDisable(disable bool)
- func (t *Table) SetHeaderLine(line bool)
- func (t *Table) SetHeaderTrans(trans textTransFunc)
- func (t *Table) SetRowLine(line bool)
- func (t *Table) SetRowSeparator(sep string)
Constants ¶
const ( // BorderCenterChar defines char at center of border BorderCenterChar = "+" // BorderRowChar defines char of row border BorderRowChar = "-" // BorderColumnChar defines char of column border BorderColumnChar = "|" // Empty defines no padding space or border Empty = "" // Space defines space char for padding and borders Space = " " )
const ( AlignDefault = iota AlignLeft AlignCenter AlignRight )
AlignDefault and other alignment constants
const (
MaxRowWidth = 30
)
MaxRowWidth defines maximum row width
Variables ¶
This section is empty.
Functions ¶
func ConditionString ¶
ConditionString returns valid or invalid string based on condition
func WrapString ¶
WrapString wraps s into a paragraph of lines of length lim, with minimal raggedness.
func WrapWords ¶
WrapWords is the low-level line-breaking algorithm, useful if you need more control over the details of the text wrapping process. For most uses, WrapString will be sufficient and more convenient.
WrapWords splits a list of words into lines with minimal "raggedness", treating each rune as one unit, accounting for spc units between adjacent words on each line, and attempting to limit lines to lim units. Raggedness is the total error over all lines, where error is the square of the difference of the length of the line and lim. Too-long lines (which only happen when a single word is longer than lim units) have pen penalty units added to the error.
Types ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table struct
func (*Table) AppendBulk ¶
AppendBulk allows support for Bulk Append Eliminates repeated for loops
func (*Table) SetAlignment ¶
SetAlignment sets Table Alignment
func (*Table) SetAutoFormatHeaders ¶
SetAutoFormatHeaders turns header autoformatting on/off. Default is on (true).
func (*Table) SetAutoWrapText ¶
SetAutoWrapText turns automatic multiline text adjustment on/off. Default is on (true).
func (*Table) SetCellTrans ¶
SetCellTrans sets the cell transformer.
REVISIT: does this even work? How does it interact with SetColTrans?
func (*Table) SetCenterSeparator ¶
SetCenterSeparator sets the center Separator
func (*Table) SetColTrans ¶
SetColTrans sets the column transformer.
func (*Table) SetColWidth ¶
SetColWidth sets the default column width
func (*Table) SetColumnSeparator ¶
SetColumnSeparator sets the Column Separator
func (*Table) SetFooterAlignment ¶
SetFooterAlignment sets Footer Alignment
func (*Table) SetHeaderAlignment ¶
SetHeaderAlignment sets Header Alignment
func (*Table) SetHeaderDisable ¶
SetDisableHeader enable / disable printing of headers
func (*Table) SetHeaderLine ¶
SetHeaderLine enable / disable a line after the header
func (*Table) SetHeaderTrans ¶
func (t *Table) SetHeaderTrans(trans textTransFunc)
SetHeaderTrans sets the transformer for the header row.
func (*Table) SetRowLine ¶
SetRowLine enable / disable a line on each row of the table
func (*Table) SetRowSeparator ¶
SetRowSeparator sets the Row Separator