ui

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTooltipPadding = 5
	MaxTooltipWidth       = 108
)
View Source
const (
	ShowCursor = "\x1b[?25h"
)

Variables

View Source
var Dot = Spinner{
	Frames:   []string{"⣾ ", "⣽ ", "⣻ ", "⢿ ", "⡿ ", "⣟ ", "⣯ ", "⣷ "},
	Complete: styles.CorrectMark,
	FPS:      time.Second / 10,
}

Functions

func ByteCountSI

func ByteCountSI(b int64) string

func DefaultWait

func DefaultWait() tea.Cmd

func DoTick

func DoTick() tea.Cmd

Types

type CheckBox

type CheckBox[T any] struct {
	Options       []T
	Cursor        int
	Selected      map[int]bool // Tracks selected indices
	ToggleTooltip bool
	Tooltips      *[]Tooltip
	TooltipWidth  int
	// contains filtered or unexported fields
}

func NewCheckBox

func NewCheckBox[T any](options []T) *CheckBox[T]

func (*CheckBox[T]) EnableSelectAll

func (s *CheckBox[T]) EnableSelectAll()

func (*CheckBox[T]) GetSelected

func (s *CheckBox[T]) GetSelected() []T

func (*CheckBox[T]) GetSelectedString

func (s *CheckBox[T]) GetSelectedString() string

func (*CheckBox[T]) Select

func (s *CheckBox[T]) Select(msg tea.Msg) (*CheckBox[T], tea.Cmd, bool)

func (*CheckBox[T]) View

func (s *CheckBox[T]) View() string

func (*CheckBox[T]) ViewTooltip

func (s *CheckBox[T]) ViewTooltip(ctx context.Context)

func (*CheckBox[T]) ViewWithBottom

func (s *CheckBox[T]) ViewWithBottom(text string) string

func (*CheckBox[T]) WithTooltip

func (s *CheckBox[T]) WithTooltip(tooltips *[]Tooltip)

type Clickable

type Clickable struct {
	Items []*ClickableItem
}

func NewClickable

func NewClickable(items ...*ClickableItem) *Clickable

func (*Clickable) ClickableUpdate

func (c *Clickable) ClickableUpdate(msg tea.Msg) error

func (*Clickable) ClickableUpdatePositions

func (c *Clickable) ClickableUpdatePositions(text string) error

func (*Clickable) ClickableView

func (c *Clickable) ClickableView(index int) string

func (*Clickable) Init

func (c *Clickable) Init() tea.Cmd

func (*Clickable) PostUpdate

func (c *Clickable) PostUpdate() tea.Cmd

type ClickableItem

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

func NewClickableItem

func NewClickableItem(displayText map[bool]string, handleFn func() error) *ClickableItem

func (*ClickableItem) Update

func (ci *ClickableItem) Update(msg tea.Msg) error

func (*ClickableItem) UpdatePosition

func (ci *ClickableItem) UpdatePosition(cleanText string) error

func (*ClickableItem) View

func (ci *ClickableItem) View() string

type Downloader

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

func NewDownloader

func NewDownloader(text, url, dest string, validateFn func(string) error) *Downloader

func (*Downloader) GetCompletion

func (m *Downloader) GetCompletion() bool

func (*Downloader) GetError

func (m *Downloader) GetError() error

func (*Downloader) Init

func (m *Downloader) Init() tea.Cmd

func (*Downloader) SetCompletion

func (m *Downloader) SetCompletion(complete bool)

SetCompletion allows you to manually set the completion state for testing purposes.

func (*Downloader) SetError

func (m *Downloader) SetError(err error)

SetError allows you to manually set an error for testing purposes.

func (*Downloader) Update

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

func (*Downloader) View

func (m *Downloader) View() string

type EndLoading

type EndLoading struct {
	Ctx context.Context
}

type ErrorLoading

type ErrorLoading struct {
	Err error
}

type Loading

type Loading struct {
	Spinner    Spinner
	Style      lipgloss.Style
	Text       string
	Completing bool

	Err             error
	EndContext      context.Context
	NonRetryableErr error
	// contains filtered or unexported fields
}

func NewLoading

func NewLoading(text string, executeFn tea.Cmd) Loading

func (Loading) Init

func (m Loading) Init() tea.Cmd

func (Loading) Update

func (m Loading) Update(msg tea.Msg) (Loading, tea.Cmd)

func (Loading) View

func (m Loading) View() string

type NonRetryableErrorLoading

type NonRetryableErrorLoading struct {
	Err error
}

type Selector

type Selector[T any] struct {
	Options       []T
	Cursor        int
	CannotBack    bool
	ToggleTooltip bool
	Tooltips      *[]Tooltip
	TooltipWidth  int
}

func (*Selector[T]) GetFooter

func (s *Selector[T]) GetFooter() string

GetFooter returns the footer text based on the CannotBack flag.

func (*Selector[T]) Select

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

func (*Selector[T]) View

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

func (*Selector[T]) ViewTooltip

func (s *Selector[T]) ViewTooltip(ctx context.Context)

type Spinner

type Spinner struct {
	Frames   []string
	Complete string
	FPS      time.Duration
}

type TextInput

type TextInput struct {
	Text          string
	Cursor        int // Cursor position within the text
	Placeholder   string
	DefaultValue  string
	ValidationFn  func(string) error
	IsEntered     bool
	CannotBack    bool
	ToggleTooltip bool
	Tooltip       *Tooltip
	TooltipWidth  int
}

func NewTextInput

func NewTextInput(cannotBack bool) TextInput

func (TextInput) Update

func (ti TextInput) Update(msg tea.Msg) (TextInput, tea.Cmd, bool)

func (TextInput) View

func (ti TextInput) View() string

func (TextInput) ViewErr

func (ti TextInput) ViewErr(err error) string

func (*TextInput) ViewTooltip

func (ti *TextInput) ViewTooltip(ctx context.Context)

func (*TextInput) WithDefaultValue

func (ti *TextInput) WithDefaultValue(value string)

func (*TextInput) WithPlaceholder

func (ti *TextInput) WithPlaceholder(placeholder string)

func (*TextInput) WithPrefillValue

func (ti *TextInput) WithPrefillValue(value string)

func (*TextInput) WithTooltip

func (ti *TextInput) WithTooltip(t *Tooltip)

func (*TextInput) WithValidatorFn

func (ti *TextInput) WithValidatorFn(fn func(string) error)

type TickMsg

type TickMsg time.Time

type Tooltip

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

func NewTooltip

func NewTooltip(title, body, warning string, boldTexts, links, highlightTexts []string) Tooltip

func NewTooltipSlice

func NewTooltipSlice(tooltip Tooltip, size int) []Tooltip

func (*Tooltip) View

func (t *Tooltip) View(width int) string

type VersionSelector

type VersionSelector struct {
	Selector[string]
	// contains filtered or unexported fields
}

func NewVersionSelector

func NewVersionSelector(urlMap cosmosutils.BinaryVersionWithDownloadURL, currentVersion string, cannotBack bool) VersionSelector

func (*VersionSelector) View

func (v *VersionSelector) View() string

Jump to

Keyboard shortcuts

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