gtable

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinHorizontal added in v0.5.5

func JoinHorizontal(pos lipgloss.Position, strs ...string) string

func JoinVertical added in v0.5.5

func JoinVertical(pos lipgloss.Position, strs ...string) string

Types

type Column added in v0.5.5

type Column struct {
	Title string
	Width int
}

Column defines the table structure.

type KeyMap added in v0.5.5

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
}

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

func DefaultKeyMap added in v0.5.5

func DefaultKeyMap() KeyMap

DefaultKeyMap returns a default set of keybindings.

type Model added in v0.5.5

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

Model defines a state for the table widget.

func New added in v0.5.5

func New(opts ...Option) Model

New creates a new model for the table widget.

func (*Model) Blur added in v0.5.5

func (m *Model) Blur()

Blur blurs the table, preventing selection or movement.

func (Model) Cursor added in v0.5.5

func (m Model) Cursor() int

Cursor returns the index of the selected row.

func (*Model) Focus added in v0.5.5

func (m *Model) Focus()

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

func (Model) Focused added in v0.5.5

func (m Model) Focused() bool

Focused returns the focus state of the table.

func (*Model) FromValues added in v0.5.5

func (m *Model) FromValues(value, separator string)

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 added in v0.5.5

func (m *Model) GotoBottom()

GotoBottom moves the selection to the last row.

func (*Model) GotoTop added in v0.5.5

func (m *Model) GotoTop()

GotoTop moves the selection to the first row.

func (Model) Height added in v0.5.5

func (m Model) Height() int

Height returns the viewport height of the table.

func (*Model) MoveDown added in v0.5.5

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) MoveUp added in v0.5.5

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) Rows added in v0.5.5

func (m Model) Rows() []Row

Rows returns the current rows.

func (Model) SelectedRow added in v0.5.5

func (m Model) SelectedRow() Row

SelectedRow returns the selected row. You can cast it to your own implementation.

func (*Model) SetColumns added in v0.5.5

func (m *Model) SetColumns(c []Column)

SetColumns sets a new columns state.

func (*Model) SetCursor added in v0.5.5

func (m *Model) SetCursor(n int)

SetCursor sets the cursor position in the table.

func (*Model) SetHeight added in v0.5.5

func (m *Model) SetHeight(h int)

SetHeight sets the height of the viewport of the table.

func (*Model) SetRows added in v0.5.5

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

SetRows sets a new rows state.

func (*Model) SetStyles added in v0.5.5

func (m *Model) SetStyles(s Styles)

SetStyles sets the table styles.

func (*Model) SetWidth added in v0.5.5

func (m *Model) SetWidth(w int)

SetWidth sets the width of the viewport of the table.

func (Model) Update added in v0.5.5

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

Update is the Bubble Tea update loop.

func (*Model) UpdateViewport added in v0.5.5

func (m *Model) UpdateViewport()

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

func (Model) View added in v0.5.5

func (m Model) View() string

View renders the component.

func (Model) Width added in v0.5.5

func (m Model) Width() int

Width returns the viewport width of the table.

type Option added in v0.5.5

type Option func(*Model)

Option is used to set options in New. For example:

table := New(WithColumns([]Column{{Title: "ID", Width: 10}}))

func WithColumns added in v0.5.5

func WithColumns(cols []Column) Option

WithColumns sets the table columns (headers).

func WithFocused added in v0.5.5

func WithFocused(f bool) Option

WithFocused sets the focus state of the table.

func WithHeight added in v0.5.5

func WithHeight(h int) Option

WithHeight sets the height of the table.

func WithKeyMap added in v0.5.5

func WithKeyMap(km KeyMap) Option

WithKeyMap sets the key map.

func WithRows added in v0.5.5

func WithRows(rows []Row) Option

WithRows sets the table rows (data).

func WithStyles added in v0.5.5

func WithStyles(s Styles) Option

WithStyles sets the table styles.

func WithWidth added in v0.5.5

func WithWidth(w int) Option

WithWidth sets the width of the table.

type Row added in v0.5.5

type Row []string

Row represents one line in the table.

type Styles added in v0.5.5

type Styles struct {
	Header   lipgloss.Style
	Cell     lipgloss.Style
	Selected lipgloss.Style
}

Styles contains style definitions for this list component. By default, these values are generated by DefaultStyles.

func DefaultStyles added in v0.5.5

func DefaultStyles() Styles

DefaultStyles returns a set of default style definitions for this table.

type Table

type Table struct {
	Program *tea.Program
	// contains filtered or unexported fields
}

func NewTable

func NewTable(opts ...Option) (t *Table)

func (*Table) Run

func (that *Table) Run()

func (*Table) SetProgramOpts added in v0.7.2

func (that *Table) SetProgramOpts(opts ...tea.ProgramOption)

type TableModel

type TableModel struct {
	// contains filtered or unexported fields
}

func (*TableModel) Init

func (that *TableModel) Init() tea.Cmd

func (*TableModel) Update

func (that *TableModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*TableModel) View

func (that *TableModel) View() string

Jump to

Keyboard shortcuts

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