Documentation ¶
Index ¶
- func DefaultStyles(_, _ int) lipgloss.Style
- type Data
- type Filter
- type StringData
- type StyleFunc
- type Table
- func (t *Table) Border(border lipgloss.Border) *Table
- func (t *Table) BorderBottom(v bool) *Table
- func (t *Table) BorderColumn(v bool) *Table
- func (t *Table) BorderHeader(v bool) *Table
- func (t *Table) BorderLeft(v bool) *Table
- func (t *Table) BorderRight(v bool) *Table
- func (t *Table) BorderRow(v bool) *Table
- func (t *Table) BorderStyle(style lipgloss.Style) *Table
- func (t *Table) BorderTop(v bool) *Table
- func (t *Table) ClearRows() *Table
- func (t *Table) Data(data Data) *Table
- func (t *Table) Headers(headers ...string) *Table
- func (t *Table) Height(h int) *Table
- func (t *Table) Offset(o int) *Table
- func (t *Table) Render() string
- func (t *Table) Row(row ...string) *Table
- func (t *Table) Rows(rows ...[]string) *Table
- func (t *Table) String() string
- func (t *Table) StyleFunc(style StyleFunc) *Table
- func (t *Table) Width(w int) *Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultStyles ¶
DefaultStyles is a TableStyleFunc that returns a new Style with no attributes.
Types ¶
type Data ¶
type Data interface { // At returns the contents of the cell at the given index. At(row, cell int) string // Rows returns the number of rows in the table. Rows() int // Columns returns the number of columns in the table. Columns() int }
Data is the interface that wraps the basic methods of a table model.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter applies a filter on some data.
type StringData ¶
type StringData struct {
// contains filtered or unexported fields
}
StringData is a string-based implementation of the Data interface.
func NewStringData ¶
func NewStringData(rows ...[]string) *StringData
NewStringData creates a new StringData with the given number of columns.
func (*StringData) Append ¶
func (m *StringData) Append(row []string)
Append appends the given row to the table.
func (*StringData) At ¶
func (m *StringData) At(row, cell int) string
At returns the contents of the cell at the given index.
func (*StringData) Columns ¶
func (m *StringData) Columns() int
Columns returns the number of columns in the table.
func (*StringData) Item ¶
func (m *StringData) Item(rows ...string) *StringData
Item appends the given row to the table.
func (*StringData) Rows ¶
func (m *StringData) Rows() int
Rows returns the number of rows in the table.
type StyleFunc ¶
StyleFunc is the style function that determines the style of a Cell.
It takes the row and column of the cell as an input and determines the lipgloss Style to use for that cell position.
Example:
t := table.New(). Headers("Name", "Age"). Row("Kini", 4). Row("Eli", 1). Row("Iris", 102). StyleFunc(func(row, col int) lipgloss.Style { switch { case row == 0: return HeaderStyle case row%2 == 0: return EvenRowStyle default: return OddRowStyle } })
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a type for rendering tables.
func New ¶
func New() *Table
New returns a new Table that can be modified through different attributes.
By default, a table has no border, no styling, and no rows.
func (*Table) BorderBottom ¶
BorderBottom sets the bottom border.
func (*Table) BorderColumn ¶
BorderColumn sets the column border separator.
func (*Table) BorderHeader ¶
BorderHeader sets the header separator border.
func (*Table) BorderLeft ¶
BorderLeft sets the left border.
func (*Table) BorderRight ¶
BorderRight sets the right border.
func (*Table) BorderStyle ¶
BorderStyle sets the style for the table border.