table

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	Rows      []*Row
	LineCount int
	SepWidth  int
	MaxWidth  int // prevents line wrapping
}

func New

func New(rows []*Row) *Model

func NewEmpty

func NewEmpty(n int) *Model

func (*Model) AppendRow

func (t *Model) AppendRow(row *Row)

func (*Model) AppendRows

func (t *Model) AppendRows(rows ...*Row)

func (*Model) Empty

func (t *Model) Empty() bool

func (*Model) GetAlignedRows

func (t *Model) GetAlignedRows() string

Helper functions for retrieving specific rows in a table Aligned but unstyled rows

func (*Model) GetAllRowsofHeading

func (t *Model) GetAllRowsofHeading(heading string) []*Row

func (*Model) GetCopyOfHeadings

func (t *Model) GetCopyOfHeadings() []Row

func (*Model) GetCopyOfRowsWithoutHeadings

func (t *Model) GetCopyOfRowsWithoutHeadings() []Row

func (*Model) GetPlainHeadings

func (t *Model) GetPlainHeadings() []string

func (*Model) GetPlainRowsWithoutHeadings

func (t *Model) GetPlainRowsWithoutHeadings() []string

func (*Model) Join

func (t *Model) Join(table *Model)

func (*Model) Render

func (t *Model) Render() string

Align and style rows

func (*Model) Reset

func (t *Model) Reset()

type Row

type Row struct {
	Text      string
	Key       string
	Prefix    string
	PrefixSep string

	// default false unless prefix defined
	ShowPrefix bool
	// only used to show row's corresponding heading during filtering
	Heading string

	MatchedIndex []int
	Styles       RowStyles

	IsHeading  bool
	IsSelected bool
	IsFiltered bool
	Reversed   bool
}

func EmptyRow

func EmptyRow() *Row

func NewHeading

func NewHeading(text string) *Row

func NewRow

func NewRow(text, key, prefix, heading string) *Row

func (*Row) Render

func (r *Row) Render() string

func (*Row) ReverseString

func (r *Row) ReverseString() string

func (*Row) String

func (r *Row) String() string

type RowStyles

type RowStyles struct {
	Normal          lipgloss.Style
	Heading         lipgloss.Style
	Selected        lipgloss.Style
	SelectedHeading lipgloss.Style
	Filtered        lipgloss.Style
}

Jump to

Keyboard shortcuts

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