customise

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidValue = errors.New("invalid value")

Functions

This section is empty.

Types

type Item

type Item interface {
	Name() string
	Value() string
	Description() string
	Group() string
	Validate(s string) error
	Set(s string) error
	AllowedValues() []string
	Type() Type
}

type Model

type Model struct {
	Items []Item

	Cursor string

	Style Styles
	// contains filtered or unexported fields
}

func NewModel

func NewModel(items []Item) Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

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

func (Model) View

func (m Model) View() string

type RadioButton

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

func (RadioButton) Init

func (r RadioButton) Init() tea.Cmd

func (*RadioButton) SetValues

func (r *RadioButton) SetValues(v []string, selected string)

func (RadioButton) Update

func (r RadioButton) Update(msg tea.Msg) (RadioButton, tea.Cmd)

func (RadioButton) Value

func (r RadioButton) Value() string

func (RadioButton) View

func (r RadioButton) View() string

type Styles

type Styles struct {
	Normal      lipgloss.Style
	Selected    lipgloss.Style
	Description lipgloss.Style
}

type Type

type Type int
const (
	TText Type = iota
	TMultiline
	TRadio
	TCheckbox // for booleans
	TFile
	TFileExisting
)

type VarWrapper

type VarWrapper struct {
	ItemName          string
	ItemDescr         string
	ItemGroup         string
	ItemType          Type
	ValueFunc         func() string
	SetFunc           func(string) error
	ValidateFunc      func(string) error
	AllowedValuesFunc func() []string
}

func BoolVar

func BoolVar(value *bool, name, descr, group string) VarWrapper

func FilenameVar

func FilenameVar(value *string, name, descr, group string, mustexist bool) VarWrapper

func IntVar

func IntVar[T ~int | ~int8 | ~int16 | ~int32 | ~int64](value *T, name, descr, group string) VarWrapper

func MultilineVar

func MultilineVar(value *string, name, descr, group string) VarWrapper

func RadioStringVar

func RadioStringVar(value *string, name, descr, group string, choices []string) VarWrapper

func StringVar

func StringVar(value *string, name, descr, group string) VarWrapper

func (VarWrapper) AllowedValues

func (w VarWrapper) AllowedValues() []string

func (VarWrapper) Description

func (w VarWrapper) Description() string

func (VarWrapper) Group

func (w VarWrapper) Group() string

func (VarWrapper) Name

func (w VarWrapper) Name() string

func (VarWrapper) Set

func (w VarWrapper) Set(s string) error

func (VarWrapper) Type

func (w VarWrapper) Type() Type

func (VarWrapper) Validate

func (w VarWrapper) Validate(s string) error

func (VarWrapper) Value

func (w VarWrapper) Value() string

Jump to

Keyboard shortcuts

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