table

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell added in v0.1.5

type Cell struct {
	Content string

	// Prefix defines the prefix of the cell.
	Prefix string
	// PrefixFunc defines the prefix function of the cell.
	PrefixFunc func(isFirst, isLast bool) string

	// Suffix defines the suffix of the cell.
	Suffix string
	// SuffixFunc defines the suffix function of the cell.
	SuffixFunc func(isFirst, isLast bool) string
	// contains filtered or unexported fields
}

type CellStyle added in v0.1.2

type CellStyle struct {
	// Align defines the alignment of the text.
	Align text.Align

	// WrapText defines if the text should be wrapped.
	WrapText *bool

	// Markdown defines if the text should be rendered as markdown.
	Markdown *bool

	// TextAttrs defines the text attributes.
	TextAttrs text.Colors

	// CellAttrs defines the cell attributes.
	CellAttrs text.Colors
}

CellStyle is the style of a cell in the table

type Row added in v0.1.5

type Row []any

type Table

type Table interface {
	AddHeader(header ...string)
	AddRow(row Row)
	AddRows(rows []Row)

	Length() int

	SetStyle(style *TableStyle)
	SetHeaderStyle(style *CellStyle)
	SetRowStyle(row int, style *CellStyle)
	SetColStyle(col int, style *CellStyle)

	Render() string
}

func NewTable

func NewTable() Table

func NewTableWithStyle added in v0.1.2

func NewTableWithStyle(style *TableStyle) Table

type TableStyle added in v0.1.2

type TableStyle struct {
	// DefaultWidth defines the default width of the table.
	DefaultWidth int
	// FitToTerminal defines if the table should fit to the terminal width.
	FitToTerminal bool

	// WrapText defines if the text should be wrapped.
	WrapText bool
	// Markdown defines if the text should be rendered as markdown.
	Markdown bool
	// HideEmpty defines if empty rows should be hidden.
	HideEmpty bool

	// OuterPadding defines the padding around the table.
	OuterPadding int
	// InnerPadding defines the padding between the cells.
	InnerPadding int
}

Jump to

Keyboard shortcuts

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