table

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Header      string
	Footer      string
	HeaderStyle *style.Style
	FooterStyle *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 Edge

type Edge struct {
	Size        int
	Ratio       int
	MinimumSize int
}

Edge describes a slot with size, ratio, and minimum constraints.

type Row

type Row struct {
	Style      *style.Style
	EndSection bool
}

Row holds metadata for a single table row.

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 NewTable

func NewTable(headers ...string) *Table

NewTable creates a new Table with the given column headers.

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) AddRow

func (t *Table) AddRow(values ...any)

AddRow adds a row of values to the table.

func (*Table) AddSection

func (t *Table) AddSection()

AddSection marks the previous row as the end of a section.

func (*Table) AddStyledRow

func (t *Table) AddStyledRow(values []any, s *style.Style, endSection bool)

AddStyledRow adds a row with an optional row style.

func (*Table) Measure

func (t *Table) Measure(c *console.Console, opts console.Options) console.Measurement

Measure implements console.Measurable.

func (*Table) Render

func (t *Table) Render(c *console.Console, opts console.Options) []segment.Segment

Render implements console.Renderable.

type TableOption

type TableOption func(*Table)

TableOption configures a Table.

func WithBorderStyle

func WithBorderStyle(s *style.Style) TableOption

WithBorderStyle sets the border style.

func WithBox

func WithBox(b *box.Box) TableOption

WithBox sets the border box style.

func WithCaption

func WithCaption(caption string) TableOption

WithCaption sets the table caption.

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.

func WithStyle

func WithStyle(s *style.Style) TableOption

WithStyle sets the default table style.

func WithTitle

func WithTitle(title string) TableOption

WithTitle sets the table title.

func WithWidth

func WithWidth(width int) TableOption

WithWidth sets a fixed table width.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL