Documentation
¶
Index ¶
- Constants
- func DefaultColumns() []column
- func DefaultRows() []naiveRow
- func NewCell(value string) cell
- func NewHeaderList(opts ...func(*headerList)) headerList
- func NewTableModelBuilder() *tableModelBuilder
- func WithItems(items []list.Item) func(*headerList)
- func WithTables(tables []TableModel) func(*headerList)
- func Write(m Model)
- type Model
- type Option
- type TableModel
- func (m TableModel) Cursor() int
- func (m TableModel) Height() int
- func (m TableModel) Rows() []row
- func (m TableModel) SelectedRow() row
- func (m *TableModel) SetColumns(c []column)
- func (m *TableModel) SetCursor(n int)
- func (m *TableModel) SetHeight(h int)
- func (m *TableModel) SetRows(r []row)
- func (m *TableModel) SetStyles(s tableStyles)
- func (m *TableModel) SetWidth(w int)
- func (m TableModel) Update(msg tea.Msg) (TableModel, tea.Cmd)
- func (m TableModel) View() string
- func (m TableModel) Width() int
- type TableOption
- func WithColumns(cols []column) TableOption
- func WithFocused(f bool) TableOption
- func WithHeight(h int) TableOption
- func WithKeyMap(km keyMap) TableOption
- func WithNaiveRows(rows []naiveRow) TableOption
- func WithRows(rows []row) TableOption
- func WithStyles(s tableStyles) TableOption
- func WithWidth(w int) TableOption
Constants ¶
const ( NORMAL = iota INSERT HEADER HEADER_INSERT HELP )
Enum of Mode
Variables ¶
This section is empty.
Functions ¶
func DefaultColumns ¶
func DefaultColumns() []column
func DefaultRows ¶
func DefaultRows() []naiveRow
func NewHeaderList ¶
func NewHeaderList(opts ...func(*headerList)) headerList
func NewTableModelBuilder ¶
func NewTableModelBuilder() *tableModelBuilder
func WithTables ¶
func WithTables(tables []TableModel) func(*headerList)
Types ¶
type TableModel ¶
type TableModel struct {
// contains filtered or unexported fields
}
TableModel defines a state for the table widget.
func NewTableModel ¶
func NewTableModel(opts ...TableOption) TableModel
NewTableModel creates a new model for the table widget.
func (TableModel) Cursor ¶
func (m TableModel) Cursor() int
Cursor returns the index of the selected row.
func (TableModel) Height ¶
func (m TableModel) Height() int
Height returns the viewport height of the table.
func (TableModel) SelectedRow ¶
func (m TableModel) SelectedRow() row
SelectedRow returns the selected row. You can cast it to your own implementation.
func (*TableModel) SetColumns ¶
func (m *TableModel) SetColumns(c []column)
SetColumns sets a new columns state.
func (*TableModel) SetCursor ¶
func (m *TableModel) SetCursor(n int)
SetCursor sets the cursor.y position in the table.
func (*TableModel) SetHeight ¶
func (m *TableModel) SetHeight(h int)
SetHeight sets the height of the viewport of the table.
func (*TableModel) SetStyles ¶
func (m *TableModel) SetStyles(s tableStyles)
SetStyles sets the table styles.
func (*TableModel) SetWidth ¶
func (m *TableModel) SetWidth(w int)
SetWidth sets the width of the viewport of the table.
func (TableModel) Update ¶
func (m TableModel) Update(msg tea.Msg) (TableModel, tea.Cmd)
Update is the Bubble Tea update loop.
func (TableModel) Width ¶
func (m TableModel) Width() int
Width returns the viewport width of the table.
type TableOption ¶
type TableOption func(*TableModel)
TableOption is used to set options in New. For example:
table := New(WithColumns([]Column{{Title: "ID", Width: 10}}))
func WithColumns ¶
func WithColumns(cols []column) TableOption
WithColumns sets the table columns (headers).
func WithFocused ¶
func WithFocused(f bool) TableOption
WithFocused sets the focus state of the table.
func WithNaiveRows ¶
func WithNaiveRows(rows []naiveRow) TableOption