table

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeyMap = KeyMap{

	PrevPage: key.NewBinding(
		key.WithKeys("left", "h", "pgup"),
		key.WithHelp("←/h/pgup", "prev page"),
	),
	NextPage: key.NewBinding(
		key.WithKeys("right", "l", "pgdown"),
		key.WithHelp("→/l/pgdn", "next page"),
	),
	GoToStart: key.NewBinding(
		key.WithKeys("home", "g"),
		key.WithHelp("g/home", "go to start"),
	),
	GoToEnd: key.NewBinding(
		key.WithKeys("end", "G"),
		key.WithHelp("G/end", "go to end"),
	),
	ToggleFullscreen: key.NewBinding(
		key.WithKeys("f"),
		key.WithHelp("f", "toggle fullscreen"),
	),

	ToggleDeleted: key.NewBinding(
		key.WithKeys("d"),
		key.WithHelp("d", "show/hide deleted"),
	),

	Filter: key.NewBinding(
		key.WithKeys("/"),
		key.WithHelp("/", "filter by text"),
	),
	CloseFilter: key.NewBinding(
		key.WithKeys("enter"),
		key.WithHelp("enter", "close the filter input field"),
	),
	ClearFilter: key.NewBinding(
		key.WithKeys("esc"),
		key.WithHelp("esc", "clear the applied filter"),
	),
	NextSuggestion: key.NewBinding(
		key.WithKeys("down", "ctrl+n"),
		key.WithHelp("↓/ctrl+n", "show next suggestion"),
	),
	PrevSuggestion: key.NewBinding(
		key.WithKeys("up", "ctrl+p"),
		key.WithHelp("↑/ctrl+p", "show previous suggestion"),
	),
	AcceptSuggestion: key.NewBinding(
		key.WithKeys("tab"),
		key.WithHelp("tab", "accept a suggestion"),
	),

	ShowFullHelp: key.NewBinding(
		key.WithKeys("?"),
		key.WithHelp("?", "more"),
	),
	CloseFullHelp: key.NewBinding(
		key.WithKeys("?", "esc"),
		key.WithHelp("?/esc", "close help"),
	),

	ForceQuit: key.NewBinding(
		key.WithKeys("ctrl+c"),
		key.WithHelp("ctrl+c", "quit"),
	),
}

DefaultKeyMap is a default set of keybindings.

View Source
var DefaultRowStyle = RowStyles{
	Cell:    lipgloss.NewStyle(),
	Error:   lipgloss.NewStyle().Foreground(lipgloss.Color("1")),
	Deleted: lipgloss.NewStyle().Foreground(lipgloss.Color("8")),
}
View Source
var DefaultStyles = Styles{
	TitleBar: lipgloss.NewStyle(),
	Title:    lipgloss.NewStyle(),
	Row:      DefaultRowStyle,

	NoneFound: lipgloss.NewStyle().
		Foreground(lipgloss.ANSIColor(3)).
		SetString("No resources found"),
	Error: lipgloss.NewStyle().
		Foreground(lipgloss.ANSIColor(9)).
		SetString("ERROR:"),
	Pagination: lipgloss.NewStyle().
		Foreground(subduedColor).
		SetString("PAGE:"),
	FilterPrompt: lipgloss.NewStyle().
		Foreground(lipgloss.ANSIColor(11)).
		SetString("FILTER:"),
	FilterInfo: lipgloss.NewStyle().
		Foreground(subduedColor).
		SetString("FILTERING:"),
	FilterNoneVisible: lipgloss.NewStyle().
		Foreground(lipgloss.ANSIColor(3)).
		SetString("No resources visible"),
	StatusDelim: lipgloss.NewStyle().
		Foreground(subduedColor).
		Bold(true).
		SetString(" | "),

	Toggles: lipgloss.NewStyle().
		Foreground(subduedColor),
}

Functions

This section is empty.

Types

type AgoColumn

type AgoColumn struct {
	Value string
	Time  time.Time
}

func (AgoColumn) String

func (c AgoColumn) String() string

type JoinedColumn added in v0.6.0

type JoinedColumn struct {
	Delimiter string
	Values    []any
}

type KeyMap

type KeyMap struct {
	// Keybindings used when browsing the list.
	NextPage  key.Binding
	PrevPage  key.Binding
	GoToStart key.Binding
	GoToEnd   key.Binding

	// Keybindings for view settings
	ToggleDeleted    key.Binding
	ToggleFullscreen key.Binding

	// Keybindings used while the text-filter is enabled.
	Filter           key.Binding
	CloseFilter      key.Binding
	ClearFilter      key.Binding
	NextSuggestion   key.Binding
	PrevSuggestion   key.Binding
	AcceptSuggestion key.Binding

	// Help toggle keybindings.
	ShowFullHelp  key.Binding
	CloseFullHelp key.Binding

	// The quit-no-matter-what keybinding. This will be caught when filtering.
	ForceQuit key.Binding
}

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

func (KeyMap) EscapeFilterText

func (k KeyMap) EscapeFilterText(keyMsg tea.KeyMsg) bool

type Model

type Model struct {
	Styles      Styles
	CellSpacing int
	HideDeleted bool
	ShowHelp    bool

	// Key mappings for navigating the list.
	KeyMap KeyMap

	Paginator paginator.Model
	// contains filtered or unexported fields
}

func New

func New() *Model

func (*Model) AddRow

func (m *Model) AddRow(row Row) tea.Cmd

func (Model) FullHelp

func (m Model) FullHelp() [][]key.Binding

FullHelp returns bindings to show the full help view. It's part of the help.KeyMap interface.

func (Model) Init

func (m Model) Init() tea.Cmd

func (*Model) RowIndex

func (m *Model) RowIndex(id string) int

func (*Model) SetError

func (m *Model) SetError(err error)

func (*Model) SetHeaders

func (m *Model) SetHeaders(headers []string)

func (*Model) SetRows

func (m *Model) SetRows(rows []Row) tea.Cmd

func (*Model) StartSpinner

func (m *Model) StartSpinner() tea.Cmd

func (*Model) StopSpinner

func (m *Model) StopSpinner()

func (*Model) Update

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

func (Model) View

func (m Model) View() string

type Row

type Row struct {
	ID         string
	Fields     []any
	Status     Status
	SortKey    string
	Suggestion string
	// contains filtered or unexported fields
}

func (*Row) ReRenderFields

func (r *Row) ReRenderFields()

func (*Row) RenderedFields

func (r *Row) RenderedFields() []string

func (Row) SortValue

func (r Row) SortValue() string

SortValue value is the value we use when sorting the list.

type RowStyles

type RowStyles struct {
	Cell    lipgloss.Style
	Error   lipgloss.Style
	Deleted lipgloss.Style
}

type Status

type Status int
const (
	StatusDefault Status = iota
	StatusError
	StatusWarning
	StatusDeleted
)

type StyledColumn

type StyledColumn struct {
	Value any
	Style lipgloss.Style
}

type Styles

type Styles struct {
	TitleBar lipgloss.Style
	Title    lipgloss.Style
	Row      RowStyles

	NoneFound         lipgloss.Style
	Error             lipgloss.Style
	Pagination        lipgloss.Style
	FilterPrompt      lipgloss.Style
	FilterInfo        lipgloss.Style
	FilterNoneVisible lipgloss.Style
	StatusDelim       lipgloss.Style

	Toggles lipgloss.Style
}

type TickMsg

type TickMsg time.Time

Jump to

Keyboard shortcuts

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