scrolltable

package
v0.0.45 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Reserved = 4 // how much space things like headers and borders take up

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnDefinition

type ColumnDefinition[T any] struct {
	Mode        ColumnMode       // the width behavior of the column
	StaticWidth int              // static width of the column; only valid for StaticColumn
	Header      string           // header text
	Style       StyleSelectFn[T] // function to get the style for a given cell
	RenderCell  RenderCellFn[T]  // function to get the string content for a given cell
}

ColumnDefinition defines the behavior for a given column in the scrolltable.

type ColumnMode

type ColumnMode int

ColumnMode configures the width behavior of a column in the scrolltable.

const (
	StaticColumn  ColumnMode = iota // the columns width is always the same
	DynamicColumn                   // the column will take up as much space as it can
)

type RenderCellFn

type RenderCellFn[T any] func(datum T) string

RenderCellFn is a function that renders the string content for a given cell.

type ScrolltableModel

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

ScrolltableModel is the ScrolltableModel for a scrolltable. The scrolltable is a table that supports data larger than the screen itself.

func InitialModel

func InitialModel[T any](name string, hideHeader bool, columnDefinitions []ColumnDefinition[T]) ScrolltableModel[T]

InitialModel builds a scrolltable model.

func (ScrolltableModel[T]) Data

func (m ScrolltableModel[T]) Data() []T

Data returns the entire data source.

func (ScrolltableModel[T]) Empty

func (m ScrolltableModel[T]) Empty() bool

Empty returns true if the current frame is Empty.

func (ScrolltableModel[T]) Frame

func (m ScrolltableModel[T]) Frame() []T

Frame returns the currently visible Frame of data.

func (ScrolltableModel[T]) Index

func (m ScrolltableModel[T]) Index() int

Index returns the absolute Index of the current selection.

func (ScrolltableModel[T]) Init

func (m ScrolltableModel[T]) Init() tea.Cmd

Init initializes the scrolltable model.

func (*ScrolltableModel[T]) MoveDown

func (m *ScrolltableModel[T]) MoveDown() tea.Cmd

MoveDown moves the cursor down the table.

func (*ScrolltableModel[T]) MoveUp

func (m *ScrolltableModel[T]) MoveUp() tea.Cmd

MoveUp moves the cursor up the table.

func (*ScrolltableModel[T]) Reload

func (m *ScrolltableModel[T]) Reload(data []T, move msgs.Direction) tea.Cmd

Reload reloads that data in the table.

func (*ScrolltableModel[T]) Resize

func (m *ScrolltableModel[T]) Resize(width int, height int)

Resize changes the size of the table.

func (ScrolltableModel[T]) Selection

func (m ScrolltableModel[T]) Selection() T

Selection returns the current Selection.

func (ScrolltableModel[T]) Update

func (m ScrolltableModel[T]) Update(msg tea.Msg) (ScrolltableModel[T], tea.Cmd)

Update updates the scrolltable model from a message.

func (ScrolltableModel[T]) View

func (m ScrolltableModel[T]) View() string

View renders the scrolltable model.

type StyleSelectFn

type StyleSelectFn[T any] func(datum T, isSelected bool, isHeader bool) lipgloss.Style

StyleSelectFn is a function to get the correct style for a given cell.

Jump to

Keyboard shortcuts

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