Documentation ¶
Index ¶
- type ColumnSpec
- type KeyMap
- type Model
- func (m *Model[E]) Blur()
- func (m Model[E]) Cursor() int
- func (m *Model[E]) Focus()
- func (m Model[E]) Focused() bool
- func (m *Model[E]) GotoBottom()
- func (m *Model[E]) GotoTop()
- func (m *Model[E]) GrowColumn()
- func (m Model[E]) Height() int
- func (m *Model[E]) MoveDown(n int)
- func (m *Model[E]) MoveLeft(n int)
- func (m *Model[E]) MoveRight(n int)
- func (m *Model[E]) MoveUp(n int)
- func (m Model[E]) SelectedRow() E
- func (m *Model[E]) SetColumns(cols []ColumnSpec[E])
- func (m *Model[E]) SetCursor(n int)
- func (m *Model[E]) SetHeight(h int)
- func (m *Model[E]) SetRows(r []E)
- func (m *Model[E]) SetStyles(s Styles)
- func (m *Model[E]) SetWidth(w int)
- func (m *Model[E]) ShrinkColumn()
- func (m Model[E]) Update(msg tea.Msg) (Model[E], tea.Cmd)
- func (m *Model[E]) UpdateViewport()
- func (m Model[E]) View() string
- func (m Model[E]) Width() int
- type Option
- func WithColumns[E any](cols []ColumnSpec[E]) Option[E]
- func WithFocused[E any](f bool) Option[E]
- func WithHeight[E any](h int) Option[E]
- func WithKeyMap[E any](km KeyMap) Option[E]
- func WithRows[E any](rows []E) Option[E]
- func WithStyles[E any](s Styles) Option[E]
- func WithWidth[E any](w int) Option[E]
- type Styles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColumnSpec ¶
type KeyMap ¶
type KeyMap struct { LineUp key.Binding LineDown key.Binding LineLeft key.Binding LineRight key.Binding PageUp key.Binding PageDown key.Binding HalfPageUp key.Binding HalfPageDown key.Binding GotoTop key.Binding GotoBottom key.Binding ShrinkColumn key.Binding GrowColumn key.Binding }
KeyMap defines keybindings. It satisfies to the help.KeyMap interface, which is used to render the menu menu.
func DefaultKeyMap ¶
func DefaultKeyMap() KeyMap
DefaultKeyMap returns a default set of keybindings.
type Model ¶
Model[E] defines a state for the table widget.
func (*Model[E]) Blur ¶
func (m *Model[E]) Blur()
Blur blurs the table, preventing selection or movement.
func (*Model[E]) Focus ¶
func (m *Model[E]) Focus()
Focus focusses the table, allowing the user to move around the rows and interact.
func (*Model[E]) GotoBottom ¶
func (m *Model[E]) GotoBottom()
GotoBottom moves the selection to the last row.
func (*Model[E]) GotoTop ¶
func (m *Model[E]) GotoTop()
GotoTop moves the selection to the first row.
func (*Model[E]) GrowColumn ¶
func (m *Model[E]) GrowColumn()
GrowColumn grows the current column by one character.
func (*Model[E]) MoveDown ¶
MoveDown moves the selection down by any number of row. It can not go below the last row.
func (*Model[E]) MoveLeft ¶
MoveLeft moves the selection left by any number of columns. It can not go left of the first column.
func (*Model[E]) MoveRight ¶
MoveRight moves the selection right by any number of columns. It can not go right of the last column.
func (*Model[E]) MoveUp ¶
MoveUp moves the selection up by any number of row. It can not go above the first row.
func (Model[E]) SelectedRow ¶
func (m Model[E]) SelectedRow() E
SelectedRow returns the selected row. You can cast it to your own implementation.
func (*Model[E]) SetColumns ¶
func (m *Model[E]) SetColumns(cols []ColumnSpec[E])
SetColumns sets the table columns (headers).
func (*Model[E]) ShrinkColumn ¶
func (m *Model[E]) ShrinkColumn()
ShrinkColumn shrinks the current column by one character.
func (*Model[E]) UpdateViewport ¶
func (m *Model[E]) UpdateViewport()
UpdateViewport updates the list content based on the previously defined columns and rows.
type Option ¶
Option[E] is used to set options in New. For example:
table := New(WithColumns([]Column{{Title: "ID", Width: 10}}))
func WithColumns ¶
func WithColumns[E any](cols []ColumnSpec[E]) Option[E]
WithColumns sets the table columns (headers).
func WithFocused ¶
WithFocused sets the focus state of the table.
type Styles ¶
Styles contains style definitions for this list component. By default, these values are generated by DefaultStyles.
func DefaultStyles ¶
func DefaultStyles() Styles
DefaultStyles returns a set of default style definitions for this table.