teax

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, model tea.Model) error

Run prepares the terminal and runs the TUI model.

Types

type Actor

type Actor[T any] interface {
	Load() ([]T, error)
	// OnKey is called when a key is pressed on a row.
	// Note: key might be a set of keys, e.g. "ctrl+c", it is important to
	// consider all possible combinations.
	// It is never called on "r", "ctrl+c" or "q" key presses, as they're
	// handled by the table itself.
	OnKey(key string, row int, val T) (hide bool, err error)
}

Actor is a data source for a table.

type Column

type Column[T any] struct {
	table.Column
	Extract func(T) string
}

Column is a column to show in the table. It also contains a function to extract the value from the data source.

type RefreshingDataTable added in v0.14.1

type RefreshingDataTable[T any] struct {
	RefreshingDataTableParams[T]
	// contains filtered or unexported fields
}

RefreshingDataTable is a table, that loads its data from an Actor with periodic updates, or on demand.

func NewRefreshingDataTable added in v0.14.1

func NewRefreshingDataTable[T any](params RefreshingDataTableParams[T]) (*RefreshingDataTable[T], error)

NewRefreshingDataTable creates a new RefreshingDataTable.

func (*RefreshingDataTable[T]) Focus added in v0.14.1

func (t *RefreshingDataTable[T]) Focus()

Focus focuses the table.

func (*RefreshingDataTable[T]) Init added in v0.14.1

func (t *RefreshingDataTable[T]) Init() tea.Cmd

Init does nothing.

func (*RefreshingDataTable[T]) Update added in v0.14.1

func (t *RefreshingDataTable[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update updates the table model.

func (*RefreshingDataTable[T]) View added in v0.14.1

func (t *RefreshingDataTable[T]) View() string

View renders the table.

type RefreshingDataTableParams added in v0.14.1

type RefreshingDataTableParams[T any] struct {
	Columns        []Column[T]
	Actor          Actor[T]
	PollInterval   time.Duration
	BorrowedHeight int // table will cut off these lines from the top at render
}

RefreshingDataTableParams are the parameters to initialize a RefreshingDataTable.

Jump to

Keyboard shortcuts

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