table

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Title  string
	Width  int
	Cursor bool
	// contains filtered or unexported fields
}

Column defines the table structure.

type KeyMap

type KeyMap struct {
	LineLeft   key.Binding
	LineRight  key.Binding
	LineUp     key.Binding
	LineDown   key.Binding
	PageUp     key.Binding
	PageDown   key.Binding
	GotoTop    key.Binding
	GotoBottom key.Binding
	CellFocus  key.Binding
}

KeyMap defines keybindings. It satisfies to the help.KeyMap interface, which is used to render the menu.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns a default set of keybindings.

type Model

type Model struct {
	KeyMap KeyMap
	Styles Styles
	// contains filtered or unexported fields
}

Model defines a state for the table widget.

func New

func New(columns []Column, opts ...func(Model) Model) Model

func (*Model) Blur

func (m *Model) Blur() tea.Cmd

Blur blurs the table, preventing selection or movement.

func (Model) Cell

func (m Model) Cell() (any, error)

func (Model) Cursor

func (m Model) Cursor() (int, int)

Cursor returns the index of the selected row.

func (*Model) Focus

func (m *Model) Focus() tea.Cmd

Focus focuses the table, allowing the user to move around the rows and interact.

func (Model) Focused

func (m Model) Focused() bool

Focused returns the focus state of the table.

func (*Model) GotoBottom

func (m *Model) GotoBottom()

GotoBottom moves the selection to the last row.

func (*Model) GotoTop

func (m *Model) GotoTop()

GotoTop moves the selection to the first row.

func (Model) Height

func (m Model) Height() int

Height returns the viewport height of the table.

func (Model) ID

func (m Model) ID() uuid.UUID

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) KeyBindings added in v0.0.3

func (m Model) KeyBindings() []key.Binding

func (*Model) MoveDown

func (m *Model) MoveDown(n int)

MoveDown moves the selection down by any number of rows. It can not go below the last row.

func (*Model) MoveLeft

func (m *Model) MoveLeft()

MoveUp moves the selection up by any number of rows. It can not go above the first row.

func (*Model) MoveRight

func (m *Model) MoveRight()

MoveUp moves the selection up by any number of rows. It can not go above the first row.

func (*Model) MoveUp

func (m *Model) MoveUp(n int)

MoveUp moves the selection up by any number of rows. It can not go above the first row.

func (*Model) PageDown

func (m *Model) PageDown()

func (*Model) PageUp

func (m *Model) PageUp()

func (*Model) SetCell added in v0.0.3

func (m *Model) SetCell(cell any)

func (*Model) SetCursor added in v0.0.3

func (m *Model) SetCursor(row, col int)

Cursor returns the index of the selected row.

func (*Model) SetRows

func (m *Model) SetRows(rows []Row)

func (*Model) SetWindow

func (m *Model) SetWindow(height, width int)

func (Model) Update

func (m Model) Update(msg tea.Msg) (_ tea.Model, cmd tea.Cmd)

Update is the Bubble Tea update loop.

func (*Model) UpdateViewport

func (m *Model) UpdateViewport()

UpdateViewport updates the list content based on the previously defined columns and rows.

func (Model) View

func (m Model) View() string

View renders the component.

func (Model) Width

func (m Model) Width() int

Width returns the viewport width of the table.

type Row

type Row []any

Row represents one line in the table.

type Styles

type Styles struct {
	Header       func() lipgloss.Style
	Cell         func() lipgloss.Style
	CursorHeader func() lipgloss.Style
	CursorRow    func() lipgloss.Style
	CursorColumn func(int) lipgloss.Style
	Border       lipgloss.Border
	BorderHeader bool
	BorderRow    bool
	BorderColumn bool
	BorderTop    bool
	BorderBottom bool
	BorderLeft   bool
	BorderRight  bool
}

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.

func (Styles) BorderHeight added in v0.0.3

func (s Styles) BorderHeight() int

func (Styles) Table

func (s Styles) Table(row, column int) *table.Table

StyleFunc sets the style for a cell based on it's position (row, column).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL