Documentation
¶
Index ¶
- Variables
- func ColorEnabled() bool
- func FitColumnWidths(natural []int, available int) []int
- func GetTableStyle(name string) (style table.Style)
- func SetGlobalTableStyle(writer table.Writer, useSimpleFormatting bool)
- func SimpleFormattingRequired() bool
- func StylingEnabled() bool
- type Table
- func (t *Table) AppendRow(cells ...string)
- func (t *Table) FitTerminal()
- func (t *Table) NaturalWidths() []int
- func (t *Table) Overhead() int
- func (t *Table) Render() string
- func (t *Table) SetColumnStyle(col int, style lipgloss.Style)
- func (t *Table) SetFooter(cells ...string)
- func (t *Table) SetMaxWidths(widths ...int)
- func (t *Table) SetSnip(col int)
- func (t *Table) SetTitle(lines ...string)
- func (t *Table) SetUnlimited(unlimited bool)
- func (t *Table) SortBy(col int)
Constants ¶
This section is empty.
Variables ¶
var ( Link = func() lipgloss.Style { return attr(lipgloss.NewStyle().Underline(true)) } Muted = func() lipgloss.Style { return lipgloss.NewStyle().Foreground(color(lipgloss.BrightBlack)) } Good = func() lipgloss.Style { return lipgloss.NewStyle().Foreground(color(lipgloss.Green)) } Warning = func() lipgloss.Style { return lipgloss.NewStyle().Foreground(color(lipgloss.Yellow)) } Bad = func() lipgloss.Style { return lipgloss.NewStyle().Foreground(color(lipgloss.Red)) } Strong = func() lipgloss.Style { return attr(lipgloss.NewStyle().Bold(true)) } Note = func() lipgloss.Style { return attr(lipgloss.NewStyle().Italic(true)) } // Hint is secondary text. Faint dims the theme's own text color, which // stays readable where gray is not, and terminals without it show // normal text. Hint = func() lipgloss.Style { return attr(lipgloss.NewStyle().Faint(true)) } )
Text styles shared by the tables. Colors are the terminal's own ANSI colors, as in ddev tui, so they follow its theme. Gray, the theme's bright black, is unreadable in some themes, so it marks only borders and status symbols, never text that must be read. Blue is too dark on many dark backgrounds, so headers are bold and links underlined, without color.
var DefaultTableStyle = "StyleLight"
Functions ¶
func ColorEnabled ¶ added in v1.25.6
func ColorEnabled() bool
ColorEnabled reports whether output gets colors: styling is on, and neither NO_COLOR nor CLICOLOR=0 is set.
func FitColumnWidths ¶ added in v1.25.6
FitColumnWidths returns the natural widths when they fit in available. Otherwise the widest columns are capped at one shared width, lowered until the row fits or it reaches minWidth, so narrow columns keep their full width and the space goes where it's needed.
func GetTableStyle ¶
GetTableStyle Get a style by name, returning the default if not found
func SetGlobalTableStyle ¶
SetGlobalTableStyle sets the table style to the globally configured style
func SimpleFormattingRequired ¶
func SimpleFormattingRequired() bool
SimpleFormattingRequired returns true if we should not be colorizing/styling text
func StylingEnabled ¶ added in v1.25.6
func StylingEnabled() bool
StylingEnabled reports whether output gets text attributes such as bold, and status symbols: stdout is a terminal and simple formatting is off.
Types ¶
type Table ¶ added in v1.25.6
type Table struct {
// contains filtered or unexported fields
}
Table is a table rendered with lipgloss in the look of the configured table_style. Callers add cells, which may hold color and OSC 8 hyperlinks, optionally limit column widths, and render. With simple formatting it is plain text without borders.
func (*Table) FitTerminal ¶ added in v1.25.6
func (t *Table) FitTerminal()
FitTerminal limits the columns' widths so the table fits the terminal, unless it is set to be unlimited. Piped output and simple formatting keep full widths, so scripts can match whole values.
func (*Table) NaturalWidths ¶ added in v1.25.6
NaturalWidths returns the widest line of each column, header and footer included.
func (*Table) Overhead ¶ added in v1.25.6
Overhead returns the width that borders and padding add to the columns' content in the configured style.
func (*Table) SetColumnStyle ¶ added in v1.25.6
SetColumnStyle sets the text style of a column's cells.
func (*Table) SetFooter ¶ added in v1.25.6
SetFooter sets a last row, separated from the others by a line.
func (*Table) SetMaxWidths ¶ added in v1.25.6
SetMaxWidths limits the content width of each column, 0 for no limit. Text in a column wider than its limit wraps.
func (*Table) SetSnip ¶ added in v1.25.6
SetSnip makes a one-line cell, or a line without spaces, in column col that is wider than the column's limit end in "…" instead of wrapping. Its hyperlink keeps the full target.
func (*Table) SetUnlimited ¶ added in v1.25.6
SetUnlimited ignores the width limits, so nothing is wrapped or snipped.