Documentation
¶
Overview ¶
Package printedtable prints rows as a table for a command that prints and exits, as a rich table prints for a Python one. It lays the table out through lipgloss's table, which measures a cell by the width it prints at, so a colored cell lines up where text/tabwriter would count its escapes as width. Each cell prints in the gotermstyle code it carries, through a palette the caller resolves once, so a palette that is off prints no escape at all. Each cell's text and each title loses its terminal controls before it is measured, so a stored value cannot drive the terminal the table prints to.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cell ¶
Cell is a cell's text and the gotermstyle code it prints in, such as gotermstyle.CodeRed. An empty Code prints the text in the terminal's own foreground.
type Column ¶
type Column struct {
// Title heads the column in bold. A table whose columns all have none prints no title line.
Title string
// Right sets the column's cells and title against its right edge, as a count reads.
Right bool
// Whole keeps the column's cells whole where the table is cut to its Width, because a cut
// handle is a command that fails when typed. The other columns give up the room, and where
// they cannot, the table prints wider than Width.
Whole bool
}
Column is one column's title and how its cells sit.
type Table ¶
type Table struct {
Columns []Column
Rows [][]Cell
// Width is how many columns wide the table may print. A wider table cuts its widest cells to
// fit, each ending in "…". Zero prints every cell whole, as piped output is read whole.
Width int
// Gap is the blank columns between two neighbors. Zero takes two.
Gap int
}
Table is one printed table's columns and rows, and the room it prints in. A row holding more cells than Columns names adds columns with no title.