tuicomposeable

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultWindowStyle = lg.NewStyle().Border(lg.RoundedBorder()).Margin(1, 1)

	DefaultBadStatusStyle = lg.NewStyle().
							Foreground(lg.AdaptiveColor{Light: "#ad0000", Dark: "#820000"})
	DefaultGoodStatusStyle = lg.NewStyle().
							Foreground(lg.AdaptiveColor{Light: "#00db0f", Dark: "#005706"})
	DefaultWarnStatusStyle = lg.NewStyle().
							Foreground(lg.AdaptiveColor{Light: "#fcba03", Dark: "#fcba03"})
)

Functions

func NewBlurEventCmd

func NewBlurEventCmd() tea.Cmd

func NewFocusEventCmd

func NewFocusEventCmd() tea.Cmd

func NewRecomputeFocusableElements

func NewRecomputeFocusableElements() tea.Cmd

func NewRemoveFocusCmd

func NewRemoveFocusCmd() tea.Cmd

func NewUpdateSelectorItems

func NewUpdateSelectorItems[T any](id int, data []T) tea.Cmd

func NewUpdateStatusSpinnerCmd

func NewUpdateStatusSpinnerCmd(id int, status Status, err error) tea.Cmd

func NewUpdateTableDataCmd

func NewUpdateTableDataCmd[T any](id int, data [][]T) tea.Cmd

func NewValueErrPairCmd

func NewValueErrPairCmd[T any](
	raw string,
	op func(raw string) ValueErrPair[T],
) tea.Cmd

Types

type BlurEvent

type BlurEvent struct{}

type Button

type Button struct {
	HoveredFocused

	Style lg.Style
	// contains filtered or unexported fields
}

func NewButton

func NewButton(style lg.Style, name string, clickCmd tea.Cmd) *Button

func (*Button) CanFocus

func (b *Button) CanFocus() bool

func (*Button) FocusableElements

func (b *Button) FocusableElements() []Composeable

func (*Button) Init

func (b *Button) Init() tea.Cmd

func (*Button) Update

func (b *Button) Update(msg tea.Msg) tea.Cmd

func (*Button) View

func (b *Button) View() string

type Column

type Column struct {
	// contains filtered or unexported fields
}

func NewColumn

func NewColumn(style lg.Style, components ...Composeable) *Column

func (*Column) Blur

func (l *Column) Blur()

func (*Column) CanFocus

func (l *Column) CanFocus() bool

func (*Column) Focus

func (l *Column) Focus()

func (*Column) FocusableElements

func (l *Column) FocusableElements() []Composeable

func (*Column) Focused

func (l *Column) Focused() bool

func (*Column) Hover

func (l *Column) Hover()

func (*Column) Hovered

func (l *Column) Hovered() bool

func (*Column) Init

func (l *Column) Init() tea.Cmd

func (*Column) UnHover

func (l *Column) UnHover()

func (*Column) Update

func (c *Column) Update(msg tea.Msg) tea.Cmd

func (*Column) View

func (c *Column) View() string

type Composeable

type Composeable interface {
	Init() tea.Cmd
	Update(msg tea.Msg) tea.Cmd
	View() string

	Focus()
	Hover()
	UnHover()
	Blur()
	Focused() bool
	Hovered() bool
	CanFocus() bool
	FocusableElements() []Composeable
}

type DataTable

type DataTable[T any] struct {
	HoveredFocused
	table.Model

	Style lg.Style
	// contains filtered or unexported fields
}

func NewDataTable

func NewDataTable[T any](style lg.Style, id int) *DataTable[T]

func (*DataTable[T]) Blur

func (d *DataTable[T]) Blur()

func (*DataTable[T]) CanFocus

func (d *DataTable[T]) CanFocus() bool

func (*DataTable[T]) Focus

func (d *DataTable[T]) Focus()

func (*DataTable[T]) FocusableElements

func (d *DataTable[T]) FocusableElements() []Composeable

func (*DataTable[T]) Focused

func (d *DataTable[T]) Focused() bool

func (*DataTable[T]) Init

func (d *DataTable[T]) Init() tea.Cmd

func (*DataTable[T]) SetCustomUpdate

func (d *DataTable[T]) SetCustomUpdate(
	customUpdate func(tea.Msg) tea.Cmd,
) *DataTable[T]

func (*DataTable[T]) SetHeadersAndData

func (d *DataTable[T]) SetHeadersAndData(
	headers []string,
	data [][]T,
	maxWidths []int,
) *DataTable[T]

func (*DataTable[T]) Update

func (d *DataTable[T]) Update(msg tea.Msg) tea.Cmd

func (*DataTable[T]) View

func (d *DataTable[T]) View() string

type FocusEvent

type FocusEvent struct{}

type HoveredFocused

type HoveredFocused struct {
	// contains filtered or unexported fields
}

func (*HoveredFocused) Blur

func (h *HoveredFocused) Blur()

func (*HoveredFocused) Focus

func (h *HoveredFocused) Focus()

func (*HoveredFocused) Focused

func (h *HoveredFocused) Focused() bool

func (*HoveredFocused) Hover

func (h *HoveredFocused) Hover()

func (*HoveredFocused) Hovered

func (h *HoveredFocused) Hovered() bool

func (*HoveredFocused) UnHover

func (h *HoveredFocused) UnHover()

type InputValue

type InputValue[T any] struct {
	textinput.Model
	HoveredFocused
	Err  *error
	Data *T

	Style  lg.Style
	Prompt string
	Parse  func(raw string) ValueErrPair[T]
	Format func(v T) string
	// contains filtered or unexported fields
}

func NewInputValue

func NewInputValue[T any](style lg.Style) *InputValue[T]

func (*InputValue[T]) Blur

func (i *InputValue[T]) Blur()

func (*InputValue[T]) CanFocus

func (i *InputValue[T]) CanFocus() bool

func (*InputValue[T]) Focus

func (i *InputValue[T]) Focus()

func (*InputValue[T]) FocusableElements

func (i *InputValue[T]) FocusableElements() []Composeable

func (*InputValue[T]) Focused

func (i *InputValue[T]) Focused() bool

func (*InputValue[T]) GetValue

func (i *InputValue[T]) GetValue() *T

func (*InputValue[T]) Hovered

func (i *InputValue[T]) Hovered() bool

func (*InputValue[T]) Init

func (i *InputValue[T]) Init() tea.Cmd

func (*InputValue[T]) SetData

func (i *InputValue[T]) SetData(d *T, err *error) *InputValue[T]

func (*InputValue[T]) SetFormater

func (i *InputValue[T]) SetFormater(fmter func(v T) string) *InputValue[T]

func (*InputValue[T]) SetInputChanedCmd

func (i *InputValue[T]) SetInputChanedCmd(cmd tea.Cmd) *InputValue[T]

func (*InputValue[T]) SetParser

func (i *InputValue[T]) SetParser(
	parser func(raw string) ValueErrPair[T],
) *InputValue[T]

func (*InputValue[T]) SetPrompt

func (i *InputValue[T]) SetPrompt(prompt string) *InputValue[T]

func (*InputValue[T]) SetTextInput

func (i *InputValue[T]) SetTextInput(
	placeholder string,
	charLimit int,
) *InputValue[T]

func (*InputValue[T]) Update

func (i *InputValue[T]) Update(msg tea.Msg) tea.Cmd

func (*InputValue[T]) View

func (i *InputValue[T]) View() string

type RecomputeFocusableElements

type RecomputeFocusableElements struct{}

type RemoveFocus

type RemoveFocus struct{}

type Row

type Row struct {
	// contains filtered or unexported fields
}

func NewRow

func NewRow(style lg.Style, components ...Composeable) *Row

func (*Row) Blur

func (l *Row) Blur()

func (*Row) CanFocus

func (l *Row) CanFocus() bool

func (*Row) Focus

func (l *Row) Focus()

func (*Row) FocusableElements

func (l *Row) FocusableElements() []Composeable

func (*Row) Focused

func (l *Row) Focused() bool

func (*Row) Hover

func (l *Row) Hover()

func (*Row) Hovered

func (l *Row) Hovered() bool

func (*Row) Init

func (l *Row) Init() tea.Cmd

func (*Row) UnHover

func (l *Row) UnHover()

func (*Row) Update

func (r *Row) Update(msg tea.Msg) tea.Cmd

func (*Row) View

func (r *Row) View() string

type Selector

type Selector[T any, U interface {
	*T
	list.DefaultItem
}] struct {
	HoveredFocused
	list.Model

	Style           lg.Style
	GoodStatusStyle lg.Style
	BadStatusStyle  lg.Style
	// contains filtered or unexported fields
}

func NewSelector

func NewSelector[T any, U interface {
	*T
	list.DefaultItem
}](
	style lg.Style,
	id int,
	title string,
	initialData []T,
) *Selector[T, U]

func (*Selector[T, U]) CanFocus

func (s *Selector[T, U]) CanFocus() bool

func (*Selector[T, U]) FocusableElements

func (s *Selector[T, U]) FocusableElements() []Composeable

func (*Selector[T, U]) Init

func (s *Selector[T, U]) Init() tea.Cmd

func (*Selector[T, U]) SetCustomUpdate

func (s *Selector[T, U]) SetCustomUpdate(
	customUpdate func(tea.Msg) tea.Cmd,
) *Selector[T, U]

func (*Selector[T, U]) SetSelectedItem

func (s *Selector[T, U]) SetSelectedItem(v **T) *Selector[T, U]

func (*Selector[T, U]) SetSelectionCmd

func (s *Selector[T, U]) SetSelectionCmd(cmd tea.Cmd) *Selector[T, U]

func (*Selector[T, U]) Update

func (s *Selector[T, U]) Update(msg tea.Msg) tea.Cmd

func (*Selector[T, U]) View

func (s *Selector[T, U]) View() string

type Status

type Status int
const (
	Waiting Status = iota
	Ok
	Error
)

func (Status) Symbol

func (s Status) Symbol() rune

type StatusSpinner

type StatusSpinner struct {
	Status
	spinner.Model

	Err        error
	GoodMsg    string
	WaitingMsg string
	ErrMsg     string

	Style              lg.Style
	GoodStatusStyle    lg.Style
	BadStatusStyle     lg.Style
	WaitingStatusStyle lg.Style
	// contains filtered or unexported fields
}

func NewStatusSpinner

func NewStatusSpinner(style lg.Style, id int) *StatusSpinner

func (*StatusSpinner) Blur

func (s *StatusSpinner) Blur()

func (*StatusSpinner) CanFocus

func (s *StatusSpinner) CanFocus() bool

func (*StatusSpinner) Focus

func (s *StatusSpinner) Focus()

func (*StatusSpinner) FocusableElements

func (s *StatusSpinner) FocusableElements() []Composeable

func (*StatusSpinner) Focused

func (s *StatusSpinner) Focused() bool

func (*StatusSpinner) Hover

func (s *StatusSpinner) Hover()

func (*StatusSpinner) Hovered

func (s *StatusSpinner) Hovered() bool

func (*StatusSpinner) Init

func (s *StatusSpinner) Init() tea.Cmd

func (*StatusSpinner) SetErrMsg

func (s *StatusSpinner) SetErrMsg(m string) *StatusSpinner

func (*StatusSpinner) SetGoodMsg

func (s *StatusSpinner) SetGoodMsg(m string) *StatusSpinner

func (*StatusSpinner) SetWaitingMsg

func (s *StatusSpinner) SetWaitingMsg(m string) *StatusSpinner

func (*StatusSpinner) UnHover

func (s *StatusSpinner) UnHover()

func (*StatusSpinner) Update

func (s *StatusSpinner) Update(msg tea.Msg) tea.Cmd

func (*StatusSpinner) View

func (s *StatusSpinner) View() string

type Tabs

type Tabs struct {
	// contains filtered or unexported fields
}

func NewTabs

func NewTabs(style lg.Style, names []string, components ...Composeable) *Tabs

func (*Tabs) Blur

func (t *Tabs) Blur()

func (*Tabs) CanFocus

func (t *Tabs) CanFocus() bool

func (*Tabs) Focus

func (t *Tabs) Focus()

func (*Tabs) FocusableElements

func (t *Tabs) FocusableElements() []Composeable

func (*Tabs) Focused

func (t *Tabs) Focused() bool

func (*Tabs) Hover

func (t *Tabs) Hover()

func (*Tabs) Hovered

func (t *Tabs) Hovered() bool

func (*Tabs) Init

func (t *Tabs) Init() tea.Cmd

func (*Tabs) UnHover

func (t *Tabs) UnHover()

func (*Tabs) Update

func (t *Tabs) Update(msg tea.Msg) tea.Cmd

func (*Tabs) View

func (t *Tabs) View() string

type UpdateSelectorItems

type UpdateSelectorItems[T any] struct {
	SelectorID int
	Data       []T
}

type UpdateStatusSpinner

type UpdateStatusSpinner struct {
	StatusSpinnerID int
	Status
	Err error
}

func (UpdateStatusSpinner) Error

func (s UpdateStatusSpinner) Error() string

type UpdateTableData

type UpdateTableData[T any] struct {
	TableID int
	Data    [][]T
}

type ValueErrPair

type ValueErrPair[T any] struct {
	Value T
	Err   error
}

func (ValueErrPair[T]) Error

func (v ValueErrPair[T]) Error() string

type Window

type Window struct {
	Root  Composeable
	Style lg.Style
	// contains filtered or unexported fields
}

func NewWindow

func NewWindow(style lg.Style, root Composeable) Window

func (Window) Init

func (w Window) Init() tea.Cmd

func (Window) Main

func (w Window) Main() error

func (Window) Update

func (w Window) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Window) View

func (w Window) View() string

type WindowKeyBindingModes

type WindowKeyBindingModes int
const (
	Navigation WindowKeyBindingModes = iota
	Interactive
)

type WindowKeyBindings

type WindowKeyBindings struct {
	// The keyboard short cuts that will navigate to the next focusable
	// UI components.
	Next key.Binding
	// The keyboard short cuts that will navigate to the previous focusable
	// UI components.
	Prev key.Binding
	// The keyboard shortcuts to navigate to the first focusable UI
	// component.
	First key.Binding
	// The keyboard shortcuts to navigate to the last focusable UI
	// component.
	Last key.Binding
	// The keyboard short cuts that will leave navigation mode and enter
	// the interactive mode for interacting with UI components.
	Focus key.Binding
	// The keyboard short cuts that will leave interactive mode and enter
	// the navigation mode for navigating the UI components.
	Blur           key.Binding
	NavigationHelp key.Binding
	Exit           key.Binding
}

Defines a set of keybindings that split the UI into two modes: navigation and intaractive mode.

func NewWindowKeyBindings

func NewWindowKeyBindings() WindowKeyBindings

func (WindowKeyBindings) FullHelp

func (w WindowKeyBindings) FullHelp() [][]key.Binding

func (WindowKeyBindings) FullHelpHeight

func (w WindowKeyBindings) FullHelpHeight() int

func (*WindowKeyBindings) SetMode

func (w *WindowKeyBindings) SetMode(mode WindowKeyBindingModes)

func (WindowKeyBindings) ShortHelp

func (w WindowKeyBindings) ShortHelp() []key.Binding

func (WindowKeyBindings) ShortHelpHeight

func (w WindowKeyBindings) ShortHelpHeight() int

Jump to

Keyboard shortcuts

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