Documentation
¶
Index ¶
- type Column
- type ColumnOption
- func WithColumnFooterStyle(s string) ColumnOption
- func WithColumnHeaderStyle(s string) ColumnOption
- func WithColumnJustify(j console.Justify) ColumnOption
- func WithColumnMaxWidth(w int) ColumnOption
- func WithColumnMinWidth(w int) ColumnOption
- func WithColumnNoWrap() ColumnOption
- func WithColumnOverflow(o console.Overflow) ColumnOption
- func WithColumnRatio(r int) ColumnOption
- func WithColumnStyle(s string) ColumnOption
- func WithColumnVertical(v align.VerticalMethod) ColumnOption
- func WithColumnWidth(w int) ColumnOption
- type Edge
- type Row
- type Table
- func (t *Table) AddColumn(header string, opts ...ColumnOption) *Column
- func (t *Table) AddRow(values ...any)
- func (t *Table) AddSection()
- func (t *Table) AddStyledRow(values []any, s *style.Style, endSection bool)
- func (t *Table) Measure(c *console.Console, opts console.Options) console.Measurement
- func (t *Table) Render(c *console.Console, opts console.Options) []segment.Segment
- type TableOption
- func WithBorderStyle(s *style.Style) TableOption
- func WithBox(b *box.Box) TableOption
- func WithCaption(caption string) TableOption
- func WithCollapsePadding() TableOption
- func WithExpand() TableOption
- func WithFooterStyle(s *style.Style) TableOption
- func WithHeaderStyle(s *style.Style) TableOption
- func WithLeading(leading int) TableOption
- func WithMinWidth(minWidth int) TableOption
- func WithPad(top, right, bottom, left int) TableOption
- func WithPadEdge(pad bool) TableOption
- func WithRowStyles(ss ...*style.Style) TableOption
- func WithShowEdge(show bool) TableOption
- func WithShowFooter(show bool) TableOption
- func WithShowHeader(show bool) TableOption
- func WithShowLines() TableOption
- func WithStyle(s *style.Style) TableOption
- func WithTitle(title string) TableOption
- func WithWidth(width int) TableOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column struct {
Header string
HeaderStyle *style.Style
Style *style.Style
Justify console.Justify
Vertical align.VerticalMethod
Overflow console.Overflow
Width int // 0 = auto
MinWidth int
MaxWidth int
Ratio int // 0 = not flexible
NoWrap bool
// contains filtered or unexported fields
}
Column defines a column within a Table.
type ColumnOption ¶
type ColumnOption func(*Column)
ColumnOption configures a Column.
func WithColumnFooterStyle ¶
func WithColumnFooterStyle(s string) ColumnOption
WithColumnFooterStyle sets the footer style for this column.
func WithColumnHeaderStyle ¶
func WithColumnHeaderStyle(s string) ColumnOption
WithColumnHeaderStyle sets the header style for this column.
func WithColumnJustify ¶
func WithColumnJustify(j console.Justify) ColumnOption
WithColumnJustify sets the text justification for this column.
func WithColumnMaxWidth ¶
func WithColumnMaxWidth(w int) ColumnOption
WithColumnMaxWidth sets a maximum width for this column.
func WithColumnMinWidth ¶
func WithColumnMinWidth(w int) ColumnOption
WithColumnMinWidth sets a minimum width for this column.
func WithColumnNoWrap ¶
func WithColumnNoWrap() ColumnOption
WithColumnNoWrap disables text wrapping for this column.
func WithColumnOverflow ¶
func WithColumnOverflow(o console.Overflow) ColumnOption
WithColumnOverflow sets the overflow behavior for this column.
func WithColumnRatio ¶
func WithColumnRatio(r int) ColumnOption
WithColumnRatio sets a ratio for flexible width distribution.
func WithColumnStyle ¶
func WithColumnStyle(s string) ColumnOption
WithColumnStyle sets the default style for cells in this column.
func WithColumnVertical ¶
func WithColumnVertical(v align.VerticalMethod) ColumnOption
WithColumnVertical sets the vertical alignment for this column.
func WithColumnWidth ¶
func WithColumnWidth(w int) ColumnOption
WithColumnWidth sets a fixed width for this column.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table implements a console-renderable table with optional borders, headers, footers, and dynamic column width calculation.
func NewTableWithOptions ¶
func NewTableWithOptions(headers []string, opts ...TableOption) *Table
NewTableWithOptions creates a Table with headers and options.
func (*Table) AddColumn ¶
func (t *Table) AddColumn(header string, opts ...ColumnOption) *Column
AddColumn adds a column to the table with optional column options.
func (*Table) AddSection ¶
func (t *Table) AddSection()
AddSection marks the previous row as the end of a section.
func (*Table) AddStyledRow ¶
AddStyledRow adds a row with an optional row style.
type TableOption ¶
type TableOption func(*Table)
TableOption configures a Table.
func WithBorderStyle ¶
func WithBorderStyle(s *style.Style) TableOption
WithBorderStyle sets the border style.
func WithCollapsePadding ¶
func WithCollapsePadding() TableOption
WithCollapsePadding enables padding collapsing between adjacent cells.
func WithExpand ¶
func WithExpand() TableOption
WithExpand enables expanding the table to fill available width.
func WithFooterStyle ¶
func WithFooterStyle(s *style.Style) TableOption
WithFooterStyle sets the footer style.
func WithHeaderStyle ¶
func WithHeaderStyle(s *style.Style) TableOption
WithHeaderStyle sets the header style.
func WithLeading ¶
func WithLeading(leading int) TableOption
WithLeading sets blank lines between rows.
func WithMinWidth ¶
func WithMinWidth(minWidth int) TableOption
WithMinWidth sets the minimum table width.
func WithPad ¶
func WithPad(top, right, bottom, left int) TableOption
WithPadding sets cell padding.
func WithPadEdge ¶
func WithPadEdge(pad bool) TableOption
WithPadEdge enables padding on edge cells.
func WithRowStyles ¶
func WithRowStyles(ss ...*style.Style) TableOption
WithRowStyles sets alternating row styles.
func WithShowEdge ¶
func WithShowEdge(show bool) TableOption
WithShowEdge sets whether to draw outer box edges.
func WithShowFooter ¶
func WithShowFooter(show bool) TableOption
WithShowFooter sets whether to show the footer row.
func WithShowHeader ¶
func WithShowHeader(show bool) TableOption
WithShowHeader sets whether to show the header row.
func WithShowLines ¶
func WithShowLines() TableOption
WithShowLines enables divider lines between every row.