Documentation ¶
Index ¶
- type CellPosition
- type Column
- type KeyMap
- type Model
- func (m *Model) Blur()
- func (m *Model) ColIndex(n int) int
- func (m Model) Cursor() int
- func (m *Model) Focus()
- func (m Model) Focused() bool
- func (m *Model) FromValues(value, separator string)
- func (m *Model) GotoBottom()
- func (m *Model) GotoTop()
- func (m Model) Height() int
- func (m *Model) MaxHScroll() int
- func (m *Model) MoveDown(n int)
- func (m *Model) MoveLeft(n int)
- func (m *Model) MoveRight(n int)
- func (m *Model) MoveUp(n int)
- func (m Model) Rows() []Row
- func (m Model) SelectedRow() Row
- func (m *Model) SetColumns(c []Column)
- func (m *Model) SetCursor(n int)
- func (m *Model) SetHeight(h int)
- func (m *Model) SetRows(r []Row)
- func (m *Model) SetStyles(s Styles)
- func (m *Model) SetWidth(w int)
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m *Model) UpdateViewport()
- func (m Model) View() string
- func (m Model) Width() int
- type Option
- type Row
- type Styles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CellPosition ¶
CellPosition holds row and column indexes.
type KeyMap ¶
type KeyMap struct { LineUp key.Binding LineDown key.Binding PageUp key.Binding PageDown key.Binding HalfPageUp key.Binding HalfPageDown key.Binding GotoTop key.Binding GotoBottom key.Binding MoveLeft key.Binding MoveRight 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 ¶
type Model struct { KeyMap KeyMap // contains filtered or unexported fields }
Model defines a state for the table widget.
func (*Model) ColIndex ¶
ColIndex gets the index of a column n, where if n is positive it returns n clamped, and if n is negative it reutrns the column index counting from the right
func (*Model) Focus ¶
func (m *Model) Focus()
Focus focusses the table, allowing the user to move around the rows and interact.
func (*Model) FromValues ¶
FromValues create the table rows from a simple string. It uses `\n` by default for getting all the rows and the given separator for the fields on each row.
func (*Model) GotoBottom ¶
func (m *Model) GotoBottom()
GotoBottom moves the selection to the last row.
func (*Model) MaxHScroll ¶
Gets the maximum useful horizontal scroll
func (*Model) MoveDown ¶
MoveDown moves the selection down by any number of row. It can not go below the last row.
func (*Model) MoveUp ¶
MoveUp moves the selection up by any number of row. It can not go above the first row.
func (Model) SelectedRow ¶
SelectedRow returns the selected row. You can cast it to your own implementation.
func (*Model) SetColumns ¶
SetColumns set a new columns state.
func (*Model) UpdateViewport ¶
func (m *Model) UpdateViewport()
UpdateViewport updates the list content based on the previously defined columns and rows.
type Option ¶
type Option func(*Model)
Option is used to set options in New. For example:
table := New(WithColumns([]Column{{Title: "ID", Width: 10}}))
func WithColumns ¶
WithColumns sets the table columns (headers).
type Styles ¶
type Styles struct { Header lipgloss.Style Cell lipgloss.Style Selected lipgloss.Style // RenderCell is a low-level primitive for stylizing cells. // It is responsible for rendering the selection style. Styles.Cell is ignored. // // Example implementation: // s.RenderCell = func(model table.Model, value string, position table.CellPosition) string { // cellStyle := s.Cell.Copy() // // switch { // case position.IsRowSelected: // return cellStyle.Background(lipgloss.Color("57")).Render(value) // case position.Column == 1: // return cellStyle.Foreground(lipgloss.Color("21")).Render(value) // default: // return cellStyle.Render(value) // } // } RenderCell func(model Model, value string, position CellPosition) string }
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.