Documentation ¶
Index ¶
- Variables
- func TruncateLeft(s string, w int, prefix string) string
- func TruncateRight(s string, w int, tail string) string
- type BulkInsertMsg
- type Column
- type ColumnKey
- type DeselectMsg
- type Model
- func (m *Model[K, V]) Blur()
- func (m Model[K, V]) Cursor() int
- func (m *Model[K, V]) DeselectAll()
- func (m *Model[K, V]) Focus()
- func (m Model[K, V]) Focused() bool
- func (m *Model[K, V]) GotoBottom()
- func (m *Model[K, V]) GotoTop()
- func (m Model[K, V]) Height() int
- func (m Model[K, V]) Highlighted() (Row[K, V], bool)
- func (m Model[K, V]) HighlightedKey() (K, bool)
- func (m Model[K, V]) HighlightedOrSelected() []Row[K, V]
- func (m Model[K, V]) HighlightedOrSelectedKeys() []K
- func (m Model[K, V]) Items() map[K]V
- func (m *Model[K, V]) MoveDown(n int)
- func (m *Model[K, V]) MoveUp(n int)
- func (m *Model[K, V]) SetColumns(c []Column)
- func (m *Model[K, V]) SetCursor(n int)
- func (m *Model[K, V]) SetItems(items map[K]V)
- func (m *Model[K, V]) SetStyles(s Styles)
- func (m *Model[K, V]) ToggleSelectAll()
- func (m *Model[K, V]) ToggleSelection()
- func (m *Model[K, V]) ToggleSelectionByKey(key K)
- func (m Model[K, V]) Update(msg tea.Msg) (Model[K, V], tea.Cmd)
- func (m *Model[K, V]) UpdateViewport()
- func (m Model[K, V]) View() string
- func (m Model[K, V]) Width() int
- func (m Model[K, V]) WithFocused(f bool) Model[K, V]
- func (m Model[K, V]) WithSelectable(s bool) Model[K, V]
- func (m Model[K, V]) WithSortFunc(sortFunc func(V, V) int) Model[K, V]
- func (m Model[K, V]) WithStyles(s Styles) Model[K, V]
- type RenderedRow
- type Resource
- type ResourceOptions
- type ResourceValue
- type Row
- type RowRenderer
- type SortFunc
- type Styles
- type TruncationFunc
Constants ¶
This section is empty.
Variables ¶
var ( IDColumn = Column{ Key: "id", Title: "ID", Width: resource.IDEncodedMaxLen, FlexFactor: 1, } ModuleColumn = Column{ Key: "module", Title: "MODULE", TruncationFunc: TruncateLeft, FlexFactor: 3, } WorkspaceColumn = Column{ Key: "workspace", Title: "WORKSPACE", FlexFactor: 2, } RunColumn = Column{ Key: "run", Title: "RUN", Width: resource.IDEncodedMaxLen, FlexFactor: 1, } TaskColumn = Column{ Key: "task", Title: "TASK", Width: resource.IDEncodedMaxLen, FlexFactor: 1, } RunStatusColumn = Column{ Key: "run_status", Title: "STATUS", Width: run.MaxStatusLen, } RunChangesColumn = Column{ Key: "run_changes", Title: "CHANGES", FlexFactor: 1, } )
Functions ¶
Types ¶
type BulkInsertMsg ¶
type BulkInsertMsg[T any] []T
BulkInsertMsg performs a bulk insertion of entities into a table
type Column ¶
type Column struct { Key ColumnKey // TODO: Default to upper case of key Title string Width int FlexFactor int TruncationFunc func(s string, w int, tail string) string }
Column defines the table structure.
type DeselectMsg ¶
type DeselectMsg struct{}
DeselectMsg deselects any table rows currently selected.
type Model ¶
type Model[K comparable, V any] struct { Selected map[K]V // contains filtered or unexported fields }
Model defines a state for the table widget.
func New ¶
func New[K comparable, V any](columns []Column, fn RowRenderer[V], width, height int) Model[K, V]
New creates a new model for the table widget.
func (*Model[K, V]) Blur ¶
func (m *Model[K, V]) Blur()
Blur blurs the table, preventing selection or movement.
func (*Model[K, V]) DeselectAll ¶
func (m *Model[K, V]) DeselectAll()
DeselectAll de-selects any rows that are currently selected
func (*Model[K, V]) Focus ¶
func (m *Model[K, V]) Focus()
Focus focuses the table, allowing the user to move around the rows and interact.
func (*Model[K, V]) GotoBottom ¶
func (m *Model[K, V]) GotoBottom()
GotoBottom moves the highlightion to the last row.
func (*Model[K, V]) GotoTop ¶
func (m *Model[K, V]) GotoTop()
GotoTop moves the highlightion to the first row.
func (Model[K, V]) Highlighted ¶
Highlighted returns the currently highlighted entity.
func (Model[K, V]) HighlightedKey ¶
Highlighted returns the currently highlighted entity key.
func (Model[K, V]) HighlightedOrSelected ¶
HighlightedOrSelected returns either the selected entities, if there are no selections, the currently highlighted entity.
func (Model[K, V]) HighlightedOrSelectedKeys ¶
func (m Model[K, V]) HighlightedOrSelectedKeys() []K
func (*Model[K, V]) MoveDown ¶
MoveDown moves the highlightion down by any number of rows. It can not go below the last row.
func (*Model[K, V]) MoveUp ¶
MoveUp moves the highlightion up by any number of rows. It can not go above the first row.
func (*Model[K, V]) SetColumns ¶
SetColumns sets a new columns state.
func (*Model[K, V]) SetItems ¶
func (m *Model[K, V]) SetItems(items map[K]V)
SetItems sets new items on the table, overwriting existing items.
func (*Model[K, V]) ToggleSelectAll ¶
func (m *Model[K, V]) ToggleSelectAll()
ToggleSelectAll toggles the selection of all rows.
func (*Model[K, V]) ToggleSelection ¶
func (m *Model[K, V]) ToggleSelection()
ToggleSelection toggles the selection of the currently highlighted row.
func (*Model[K, V]) ToggleSelectionByKey ¶
func (m *Model[K, V]) ToggleSelectionByKey(key K)
ToggleSelectionByKey toggles the selection of the row with the given key. If the key does not exist no action is taken.
func (*Model[K, V]) UpdateViewport ¶
func (m *Model[K, V]) UpdateViewport()
UpdateViewport updates the list content based on the previously defined columns and rows.
func (Model[K, V]) WithFocused ¶
WithFocused sets the focus state of the table.
func (Model[K, V]) WithSelectable ¶
WithSelectable sets whether rows are selectable.
func (Model[K, V]) WithSortFunc ¶
WithSortFunc configures the table to sort rows using the given func.
func (Model[K, V]) WithStyles ¶
WithStyles sets the table styles.
type RenderedRow ¶
RenderedRow provides the rendered string for each column in a row.
type Resource ¶
type Resource[K resource.ID, V ResourceValue] struct { Model[K, V] // contains filtered or unexported fields }
Resource is a wrapper of table.Model specifically for use with pug resources.
func NewResource ¶
func NewResource[K resource.ID, V ResourceValue](opts ResourceOptions[V]) Resource[K, V]
NewResource creates a new resource table
type ResourceOptions ¶
type ResourceOptions[V ResourceValue] struct { Columns []Column Renderer RowRenderer[V] Width, Height int Parent resource.Resource SortFunc SortFunc[V] }
type ResourceValue ¶
type Row ¶
type Row[K comparable, V any] struct { Key K Value V }
type RowRenderer ¶
type RowRenderer[V any] func(V) RenderedRow
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.