table

package
v0.0.0-...-56ac0d2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyMap

type KeyMap struct {
	End      key.Binding
	Home     key.Binding
	PageDown key.Binding
	PageUp   key.Binding
	Down     key.Binding
	Up       key.Binding
	Right    key.Binding
	Left     key.Binding
}

KeyMap holds the key bindings for the table.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap used by the `New` constructor.

type Model

type Model struct {
	KeyMap KeyMap
	Styles Styles
	// contains filtered or unexported fields
}

Model of a table component.

func New

func New(cols []string, width, height int) Model

New model.

func (*Model) Blur

func (m *Model) Blur()

func (Model) Cursor

func (m Model) Cursor() int

Cursor returns the index of the selected row.

func (Model) CursorIsAtBottom

func (m Model) CursorIsAtBottom() bool

CursorIsAtBottom of the table.

func (Model) CursorIsAtTop

func (m Model) CursorIsAtTop() bool

CursorIsAtTop of the table.

func (Model) CursorIsPastBottom

func (m Model) CursorIsPastBottom() bool

CursorIsPastBottom of the table.

func (*Model) Focus

func (m *Model) Focus()

func (*Model) GetViewportHeight

func (m *Model) GetViewportHeight() int

func (*Model) GetViewportWidth

func (m *Model) GetViewportWidth() int

func (*Model) GoBottom

func (m *Model) GoBottom()

GoBottom moves the selection to the last row.

func (*Model) GoDown

func (m *Model) GoDown()

GoDown moves the selection to the next row. It can not go below the last row.

func (*Model) GoLeft

func (m *Model) GoLeft()

func (*Model) GoPageDown

func (m *Model) GoPageDown()

GoPageDown moves the selection one page down. It can not go below the last row.

func (*Model) GoPageUp

func (m *Model) GoPageUp()

GoPageUp moves the selection one page up. It can not go above the first row.

func (*Model) GoRight

func (m *Model) GoRight()

func (*Model) GoTop

func (m *Model) GoTop()

GoTop moves the selection to the first row.

func (*Model) GoUp

func (m *Model) GoUp()

GoUp moves the selection to the previous row. It can not go above the first row.

func (Model) SelectedRow

func (m Model) SelectedRow() Row

SelectedRow returns the selected row. You can cast it to your own implementation.

func (*Model) SetRows

func (m *Model) SetRows(rows []Row)

SetRows of the table and makes sure to update the view and the selected row does not go out of bounds.

func (*Model) SetSize

func (m *Model) SetSize(width, height int)

SetSize of the table and makes sure to update the view and the selected row does not go out of bounds.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update tea.Model implementor. It handles the key events.

func (Model) View

func (m Model) View() string

View tea.Model implementors. It renders the table inside a viewport.

type Row

type Row interface {
	// Render the row into the given tabwriter.
	// To render correctly, join each cell by a tab character '\t'.
	// Use `m.Cursor() == index` to determine if the row is selected.
	// Take a look at the `SimpleRow` implementation for an example.
	Render(w io.Writer, model Model, index int)
}

Row renderer.

type SimpleRow

type SimpleRow []any

SimpleRow is a set of cells that can be rendered into a table. It supports row highlight if selected.

func (SimpleRow) Render

func (row SimpleRow) Render(w io.Writer, model Model, index int)

Render a simple row.

type StaticTable

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

func NewStatic

func NewStatic(columns []string) *StaticTable

func (*StaticTable) Render

func (t *StaticTable) Render() string

func (*StaticTable) SetRows

func (t *StaticTable) SetRows(rows []SimpleRow)

type Styles

type Styles struct {
	Header        lipgloss.Style
	Cell          lipgloss.Style
	HeaderCell    lipgloss.Style
	UnselectedRow lipgloss.Style
	SelectedRow   lipgloss.Style
}

Styles holds the styling for the table.

func DefaultStyles

func DefaultStyles() Styles

DefaultStyles used by the `New` constructor.

Jump to

Keyboard shortcuts

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