table

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorBadCellType added in v1.5.0

type ErrorBadCellType struct {
	// contains filtered or unexported fields
}

ErrorBadCellType type of cell does not match type of column

func (ErrorBadCellType) Error added in v1.5.0

func (e ErrorBadCellType) Error() string

type ErrorBadType added in v1.5.0

type ErrorBadType struct {
	// contains filtered or unexported fields
}

ErrorBadType type does not match Ordered interface types

func (ErrorBadType) Error added in v1.5.0

func (e ErrorBadType) Error() string

type ErrorRowLen added in v1.5.0

type ErrorRowLen struct {
	// contains filtered or unexported fields
}

ErrorRowLen row length is not matching headers len

func (ErrorRowLen) Error added in v1.5.0

func (e ErrorRowLen) Error() string

type Ordered

type Ordered interface {
	int | int8 | int32 | int16 | int64 | float32 | float64 | string
}

type SortingOrderKey added in v1.5.0

type SortingOrderKey int
const (
	SortingOrderAscending SortingOrderKey = iota
	SortingOrderDescending
)

type StyleKey added in v1.5.0

type StyleKey int
const (
	StyleKeyHeader StyleKey = iota
	StyleKeyFooter
	StyleKeyRows
	StyleKeyRowsSubsequent
	StyleKeyRowsCursor
	StyleKeyCellCursor
)

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table responsive, x/y scrollable table that uses magic of FlexBox

func NewTable

func NewTable(width, height int, columnHeaders []string) *Table

NewTable initialize Table object with defaults

func (*Table) AddRows

func (r *Table) AddRows(rows [][]any) (*Table, error)

AddRows add multiple rows, will return error on the first instance of a row that does not match the type set on table will update rows only when there are no errors

func (*Table) ClearRows added in v1.4.1

func (r *Table) ClearRows() *Table

ClearRows removes all previously added rows, can be used as part of an update loop

func (*Table) CursorDown

func (r *Table) CursorDown() *Table

CursorDown move table cursor down

func (*Table) CursorLeft

func (r *Table) CursorLeft() *Table

CursorLeft move table cursor left

func (*Table) CursorRight

func (r *Table) CursorRight() *Table

CursorRight move table cursor right

func (*Table) CursorUp

func (r *Table) CursorUp() *Table

CursorUp move table cursor up

func (*Table) GetCursorLocation

func (r *Table) GetCursorLocation() (int, int)

GetCursorLocation returns the current x,y position of the cursor

func (*Table) GetCursorValue

func (r *Table) GetCursorValue() string

GetCursorValue returns the string of the cell under the cursor

func (*Table) GetFilter

func (r *Table) GetFilter() (columnIndex int, s string)

GetFilter returns string used for filtering and the column index TODO: enable multi column filtering

func (*Table) GetOrder added in v1.4.1

func (r *Table) GetOrder() (int, SortingOrderKey)

GetOrder returns the current order column index and phase

func (*Table) GetVisibleColumnRange added in v1.5.0

func (r *Table) GetVisibleColumnRange() (int, int)

GetVisibleColumnRange returns the left and right visible column indexes

func (*Table) MustAddRows

func (r *Table) MustAddRows(rows [][]any) *Table

MustAddRows executes AddRows and panics if there is an error

func (*Table) OrderByAsc added in v1.4.1

func (r *Table) OrderByAsc(index int) *Table

OrderByAsc orders rows by a column with index n, in ascending order

func (*Table) OrderByDesc added in v1.4.1

func (r *Table) OrderByDesc(index int) *Table

OrderByDesc orders rows by a column with index n, in descending order

func (*Table) Render

func (r *Table) Render() string

Render renders the table into the string

func (*Table) SetFilter

func (r *Table) SetFilter(columnIndex int, s string) *Table

SetFilter sets filtering string on a column

func (*Table) SetHeight

func (r *Table) SetHeight(value int) *Table

SetHeight sets the height of the table including the header and footer

func (*Table) SetMinWidth

func (r *Table) SetMinWidth(values []int) *Table

SetMinWidth replaces the minimum width slice, it has to be exactly the len of the headers/rows slices if it's not matching len it will trigger fatal error

func (*Table) SetRatio

func (r *Table) SetRatio(values []int) *Table

SetRatio replaces the ratio slice, it has to be exactly the len of the headers/rows slices also each value have to be greater than 0, if either fails we panic

func (*Table) SetStylePassing

func (r *Table) SetStylePassing(value bool) *Table

SetStylePassing sets the style passing flag, if true, styles are passed all the way down from box to cell

func (*Table) SetStyles

func (r *Table) SetStyles(styles map[StyleKey]lipgloss.Style) *Table

SetStyles allows overrides of styling elements of the table When only a partial set of overrides are provided, the default styling will be used

func (*Table) SetTypes

func (r *Table) SetTypes(columnTypes ...any) (*Table, error)

SetTypes sets the column type, setting this will remove all the rows so make sure you do it when instantiating Table object or add new rows after this, types have to be one of Ordered interface types

func (*Table) SetWidth

func (r *Table) SetWidth(value int) *Table

SetWidth sets the width of the table

func (*Table) UnsetFilter

func (r *Table) UnsetFilter() *Table

UnsetFilter resets filtering

Jump to

Keyboard shortcuts

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