Documentation
¶
Overview ¶
Package table is a customized implementation of the simple table implementation at "charm.land/bubbles/v2/table".
Index ¶
- type Column
- type Field
- type FieldDelegate
- type HeaderDelegate
- type KeyMap
- type Model
- func (m *Model) AppendRows(r []Row)
- func (m *Model) Blur()
- func (m *Model) Columns() []Column
- func (m *Model) Cursor() int
- func (m *Model) CursorAtEnd() bool
- func (m *Model) DynamicColumnWidth() bool
- func (m *Model) Focus()
- func (m *Model) Focused() bool
- func (m *Model) FromValues(value, separator string, cb func(v string) Field)
- func (m *Model) GotoBottom()
- func (m *Model) GotoLeft()
- func (m *Model) GotoRight()
- func (m *Model) GotoTop()
- func (m *Model) Height() int
- func (m *Model) HelpView() string
- func (m *Model) MoveContentBoundaries(n int)
- func (m *Model) MoveDown(n int)
- func (m *Model) MoveUp(n int)
- func (m *Model) ResetVirtualRows()
- func (m *Model) Rows() []Row
- func (m *Model) ScrollLeft(n int)
- func (m *Model) ScrollRight(n int)
- func (m *Model) SelectedRow() *Row
- func (m *Model) SetColumns(c []Column)
- func (m *Model) SetContent(c []Column, r []Row)
- func (m *Model) SetCursor(n int)
- func (m *Model) SetDynamicColumnWidth(b bool)
- func (m *Model) SetHeight(h int)
- func (m *Model) SetRows(r []Row)
- func (m *Model) SetStyles(s Styles)
- func (m *Model) SetVirtualRows(r []Row)
- func (m *Model) SetWidth(w int)
- func (m *Model) Update(msg tea.Msg) tea.Cmd
- func (m *Model) UpdateContent() (updateHeader bool)
- func (m *Model) UpdateHeader()
- func (m *Model) View() string
- func (m *Model) ViewAtEnd() bool
- func (m *Model) VirtualRows() []Row
- func (m *Model) VisualRows() []Row
- func (m *Model) Width() int
- type Option
- func WithColumns(cols []Column) Option
- func WithDynamicColumnWidth(b bool) Option
- func WithFieldDelegate(f FieldDelegate) Option
- func WithFocused(f bool) Option
- func WithHeaderDelegate(f HeaderDelegate) Option
- func WithHeight(h int) Option
- func WithKeyMap(km KeyMap) Option
- func WithRows(rows []Row) Option
- func WithStyles(s Styles) Option
- func WithVirtualRows(rows []Row) Option
- func WithWidth(w int) Option
- type Row
- type Rows
- type Styles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FieldDelegate ¶
type HeaderDelegate ¶
type KeyMap ¶
type KeyMap struct {
LineUp key.Binding
LineDown key.Binding
ScrollRight key.Binding
ScrollLeft key.Binding
ShiftRight key.Binding
ShiftLeft key.Binding
PageUp key.Binding
PageDown key.Binding
HalfPageUp key.Binding
HalfPageDown key.Binding
GotoTop key.Binding
GotoBottom key.Binding
GotoLeft key.Binding
GotoRight key.Binding
}
KeyMap defines keybindings. It satisfies to the help.KeyMap interface, which is used to render the help menu.
func DefaultKeyMap ¶
func DefaultKeyMap() *KeyMap
DefaultKeyMap returns a default set of keybindings.
type Model ¶
Model defines a state for the table widget.
func (*Model) AppendRows ¶
AppendRows appends rows to the table's state. This can be unsafe if the number of columns is not equal to that of existing rows.
func (*Model) CursorAtEnd ¶
CursorAtEnd returns whether the selected row is the last available row
func (*Model) DynamicColumnWidth ¶
DynamicColumnWidth returns the current setting for dynamic-column-width
func (*Model) Focus ¶
func (m *Model) Focus()
Focus focuses 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. This does not apply styling
func (*Model) GotoBottom ¶
func (m *Model) GotoBottom()
GotoBottom moves the selection to the last row.
func (*Model) HelpView ¶
HelpView is a helper method for rendering the help menu from the keymap. Note that this view is not rendered by default and you must call it manually in your application, where applicable.
func (*Model) MoveContentBoundaries ¶
func (*Model) MoveDown ¶
MoveDown moves the selection down by any number of rows. It can not go below the last row.
func (*Model) MoveUp ¶
MoveUp moves the selection up by any number of rows. It can not go above the first row.
func (*Model) ResetVirtualRows ¶
func (m *Model) ResetVirtualRows()
resetVirtaulRows empties virtual rows and ensures that the base rows are returned
func (*Model) ScrollLeft ¶
ScrollLeft scrolls the header and viewport contents to the left
func (*Model) ScrollRight ¶
ScrollRight scrolls the header and viewport contents to the right
func (*Model) SelectedRow ¶
SelectedRow returns the selected row. You can cast it to your own implementation.
func (*Model) SetColumns ¶
SetColumns sets a new columns state. Can be unsafe if the number of columns changes. Use SetContent if rows and columns change together.
func (*Model) SetContent ¶
SetContent is suited when columns and rows change simultaneously, especially when the number of columns changes from the previous content state. This operation also completely resets any virtual rows.
func (*Model) SetDynamicColumnWidth ¶
SetDynamicColumnWidth updates the setting for dynamic-column-width and updates the view appropriately
func (*Model) SetRows ¶
SetRows sets a new rows state.Can be unsafe if the number of columns changes. Use SetContent if rows and columns change together.
func (*Model) SetVirtualRows ¶
SetVirtualRows sets the virtual rows Note that supplying nil or [] does not reset the view. To completely remove virtual rows (even if empty) from view, use the `ResetVirtualRows` method.
func (*Model) UpdateContent ¶
UpdateContent updates the list content based on the previously defined columns and rows. OPTIM: update-content cannot reflect on previous state to determine what rows actually require new rendering; therefore, it renders everything, even if the row was already included in the viewport contents and its selection-state did not change.
func (*Model) UpdateHeader ¶
func (m *Model) UpdateHeader()
func (*Model) VirtualRows ¶
VirtualRows returns the current virtual rows.
func (*Model) VisualRows ¶
Visual rows returns virtual rows when set or falls back to 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).
func WithDynamicColumnWidth ¶
func WithFieldDelegate ¶
func WithFieldDelegate(f FieldDelegate) Option
WithFieldDelegate sets the field delegate
func WithHeaderDelegate ¶
func WithHeaderDelegate(f HeaderDelegate) Option
WithHeaderDelegate sets the header delegate
func WithVirtualRows ¶
WithVirtualRows sets the table virtual rows (data view).
type Styles ¶
type Styles struct {
Header lipgloss.Style
// only affects default styling, remains unused when using a delegate
Cell lipgloss.Style
// only affects default styling, remains unused when using a delegate
Selected lipgloss.Style
}
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.