settings

package
v0.704.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 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
	// Locked marks a field whose configuration key an extension has taken
	// over. The write path refuses the save regardless, so this exists to say
	// so before the user types rather than after: the row is drawn with a lock
	// marker and editing it does nothing.
	//
	// It is deliberately separate from ReadOnly and Disabled. Those describe
	// the field itself — a value that is derived, a control that does not
	// apply in this configuration. Locked describes something outside the
	// field, is set from the live lock list on every rebuild, and can appear
	// and disappear while Pando runs.
	Locked bool

	// ManagedNote replaces the generic lock marker with a caller-supplied
	// label ("Managed by the operator"), so a managed row says who owns the
	// value instead of only that somebody does.
	//
	// It is rendered only when Locked is set: a note on an editable field would
	// tell the user a value is not theirs while still letting them change it.
	ManagedNote string
}

func (Field) BoolValue

func (f Field) BoolValue() bool

func (Field) DisplayValue

func (f Field) DisplayValue(editing bool) string

func (Field) Editable added in v0.703.4

func (f Field) Editable() bool

Editable reports whether the field accepts input. It is the single question the section asks before opening an editor or emitting a save.

func (Field) LockMarker added in v0.703.4

func (f Field) LockMarker() string

LockMarker is the text drawn before the value of a locked field: the caller-supplied note when there is one, and the generic marker otherwise. It returns "" for a field that is not locked.

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