settings

package
v0.629.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Label            string
	Key              string
	Value            string
	Type             FieldType
	Options          []string
	Masked           bool
	ReadOnly         bool
	Disabled         bool
	UseModelDialog   bool
	ModelDialogTitle string
	// Hint is optional helper text shown below the field row (e.g. recommended default).
	Hint string
}

func (Field) BoolValue

func (f Field) BoolValue() bool

func (Field) DisplayValue

func (f Field) DisplayValue(editing bool) string

func (*Field) SetBoolValue

func (f *Field) SetBoolValue(value bool)

type FieldType

type FieldType int
const (
	FieldText FieldType = iota
	FieldToggle
	FieldSelect
	FieldAction // triggers a command when enter/space is pressed
)

type OpenModelFieldDialogMsg added in v0.308.0

type OpenModelFieldDialogMsg struct {
	SectionTitle string
	Field        Field
}

type SaveFieldMsg

type SaveFieldMsg struct {
	SectionTitle string
	Field        Field
}

type Section

type Section struct {
	Title  string
	Group  string // optional group label shown as header in sidebar
	Fields []Field
	// contains filtered or unexported fields
}

func (*Section) ActiveField

func (s *Section) ActiveField() *Field

func (*Section) ActiveFieldIdx added in v0.624.0

func (s *Section) ActiveFieldIdx() int

ActiveFieldIdx returns the index of the currently active field.

func (*Section) FieldAtLine added in v0.624.0

func (s *Section) FieldAtLine(width, line int) int

FieldAtLine maps a content line to the field index that occupies it, or -1.

func (*Section) FieldHeights added in v0.624.0

func (s *Section) FieldHeights(width int) []int

FieldHeights returns the rendered line height of every field at the given width, matching exactly what View draws. Callers use the cumulative sums to map content lines to fields and back.

func (*Section) FieldLineOffset added in v0.624.0

func (s *Section) FieldLineOffset(width, idx int) int

FieldLineOffset returns the first content line (0-indexed) of field idx.

func (*Section) IsEditing

func (s *Section) IsEditing() bool

func (*Section) SetActiveFieldIdx added in v0.624.0

func (s *Section) SetActiveFieldIdx(idx int)

SetActiveFieldIdx sets the active field, clamped to the valid range.

func (*Section) SetWidth

func (s *Section) SetWidth(width int)

func (*Section) Update

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

func (*Section) View

func (s *Section) View(width int, active bool) string

type SelectFieldCmp

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

func NewSelectFieldCmp

func NewSelectFieldCmp(field Field, width int) SelectFieldCmp

func (*SelectFieldCmp) SetWidth

func (c *SelectFieldCmp) SetWidth(width int)

func (*SelectFieldCmp) Update

func (c *SelectFieldCmp) Update(msg tea.Msg) (tea.Cmd, bool)

func (SelectFieldCmp) Value

func (c SelectFieldCmp) Value() string

func (SelectFieldCmp) View

func (c SelectFieldCmp) View() string

type SettingsCmp

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

func NewSettingsCmp

func NewSettingsCmp() SettingsCmp

func (*SettingsCmp) ActiveSection

func (m *SettingsCmp) ActiveSection() *Section

func (SettingsCmp) Init

func (m SettingsCmp) Init() tea.Cmd

func (*SettingsCmp) Sections

func (m *SettingsCmp) Sections() []Section

func (*SettingsCmp) SetActiveField

func (m *SettingsCmp) SetActiveField(sectionTitle, fieldKey string)

func (*SettingsCmp) SetSections

func (m *SettingsCmp) SetSections(sections []Section)

SetSections replaces the sections, preserving the active section, the active field of every section and the scroll position across the rebuild.

Callers pass freshly built sections whose activeFieldIdx is always 0, so without this remapping any rebuild not followed by an explicit SetActiveField would snap focus and the viewport back to the top. That is what happened after saving a field: persisting writes the config file, the config watcher picks the write up and publishes a change event, and the resulting rebuild reset focus to the first field of the section.

func (*SettingsCmp) SetSize

func (m *SettingsCmp) SetSize(width, height int)

func (SettingsCmp) Update

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

func (SettingsCmp) View

func (m SettingsCmp) View() string

type TextFieldCmp

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

func NewTextFieldCmp

func NewTextFieldCmp(field Field, width int) TextFieldCmp

func (*TextFieldCmp) SetWidth

func (c *TextFieldCmp) SetWidth(width int)

func (*TextFieldCmp) Update

func (c *TextFieldCmp) Update(msg tea.Msg) (tea.Cmd, bool)

func (TextFieldCmp) Value

func (c TextFieldCmp) Value() string

func (TextFieldCmp) View

func (c TextFieldCmp) View() string

type ToggleFieldCmp

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

func NewToggleFieldCmp

func NewToggleFieldCmp(field Field) ToggleFieldCmp

func (*ToggleFieldCmp) SetWidth

func (c *ToggleFieldCmp) SetWidth(width int)

func (*ToggleFieldCmp) Update

func (c *ToggleFieldCmp) Update(msg tea.Msg) (tea.Cmd, bool)

func (ToggleFieldCmp) Value

func (c ToggleFieldCmp) Value() string

func (ToggleFieldCmp) View

func (c ToggleFieldCmp) View() string

Jump to

Keyboard shortcuts

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