settings

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package settings is the settings overlay: a scrollable list of preferences grouped under headings, cycled left/right, applied live, and saved on Enter.

The overlay owns the field table, the scroll geometry, the key handling and the row→field mapping its mouse hit-test needs. What it does *not* own is what a change means: cycling "Symbols as tree" has to rebuild the symbols view, "Address width" invalidates every row cache, and "Theme" rebuilds the whole palette. Those effects reach across the entire shell, so they stay there and this package reaches them through Host.

Index

Constants

View Source
const FieldCount = 16

FieldCount is the number of settings rows; it must match the Metas table and the shell's CycleSetting switch.

Variables

View Source
var DisasmTargets = []string{"entry", "main", "start", "text", "lowest"}

DisasmTargets is the cycle for the "Disasm target" setting.

View Source
var Metas = [FieldCount]Meta{
	{"Appearance", "Theme", "colour palette for the whole UI"},
	{"Appearance", "Panel background", "solid fill behind the view panels"},
	{"Appearance", "Wrap long lines", "soft-wrap rows wider than the window"},
	{"Startup", "Open in view", "the view shown when a file loads"},
	{"Startup", "Disasm target", "where Disasm lands: entry/main/start/text/lowest"},
	{"Lists & trees", "Symbols as tree", "group symbols by their source path"},
	{"Lists & trees", "Sources as tree", "nest source files into folders"},
	{"Lists & trees", "Libraries as tree", "group libraries by directory"},
	{"Lists & trees", "Start collapsed", "open trees folded to the top level"},
	{"Symbols & names", "Abbreviate args", "shorten long demangled signatures"},
	{"Symbols & names", "Demangle symbols", "show foo::bar() vs raw _ZN3foo…"},
	{"Disassembly", "Show raw bytes", "the machine-code byte column"},
	{"Disassembly", "Show annotations", "inline target, reloc & string notes"},
	{"Disassembly", "Byte spacing", "space-separated vs packed bytes"},
	{"Addresses & hex", "Address width", "narrow 64-bit addrs when the top half is 0"},
	{"Addresses & hex", "Hex bytes / row", "bytes per row in the Hex & Raw views"},
}
View Source
var ViewNames = []string{
	"info", "sections", "symbols", "disasm", "hex", "raw", "strings", "libs", "sources",
}

ViewNames is the cycle for the "Open in view" setting.

Functions

func CycleHexBytesPerRow

func CycleHexBytesPerRow(cur, dir int) int

CycleHexBytesPerRow steps the bytes-per-row preference through 8 → 16 → 32.

func CycleIndex

func CycleIndex(list []string, cur string, dir int) int

CycleIndex returns the index of cur in list stepped by dir (wrapping); a value not in the list is treated as index 0.

func GroupLead

func GroupLead(i int) bool

GroupLead reports whether field i begins a new group (so its header row is drawn before it).

func RowHeight

func RowHeight(i int) int

RowHeight is the rendered height of field i for the scroll geometry: the value row, plus a header line when it leads a group, plus a blank separator before every group but the first.

func ThemeList

func ThemeList(defaultTheme string) []string

ThemeList is the cycle for the "Theme" setting: the four built-in names first, then every curated Chroma style.

theme.Names() is generated from the same manifest that decides which style XMLs get embedded, so every entry here has a real highlighter behind it. The three built-ins that are also Chroma styles (nord, solarized-dark, solarized-light) are deduplicated so they appear once, as built-ins.

Types

type Host

type Host interface {
	modal.Host
	// SettingValue returns field i's current value as a display string.
	SettingValue(i int) string
	// CycleSetting steps field i by dir and applies the change across the shell.
	CycleSetting(i, dir int)
	// PersistSettings writes the config file and reports the outcome via
	// SetStatus. It does not close the overlay; the caller does.
	PersistSettings()
}

Host is what the settings overlay needs from the shell. It is wider than modal.Host because reading and applying a setting touches shell state the overlay must not own.

type Meta

type Meta struct {
	Group, Label, Desc string
}

Meta describes one setting for display: which group it belongs to (so the modal can draw section headers), its label and a one-line explanation. The slice order matches the field index, and groups are contiguous so a header is drawn once per block.

type State

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

State is the settings overlay. The zero value is closed.

func (*State) Activate

func (s *State) Activate(host Host) tea.Cmd

Activate is the mouse double-click action: step the selected field forward.

func (*State) Active

func (s *State) Active() bool

func (*State) ClickRow

func (s *State) ClickRow(listRow int) bool

ClickRow selects the field on a clicked content row. Rows do not map 1:1 to fields — group headers and separators are interleaved — so the row→field mapping recorded during Render is consulted instead of modal.ClickIndex.

func (*State) Close

func (s *State) Close()

func (*State) Cur

func (s *State) Cur() int

Cur returns the selected field index.

func (*State) List

func (s *State) List() (sel *int, top, n int, wrap, ok bool)

List exposes the field list to the shell's shared mouse handling. Selection wraps: the settings list cycles top-to-bottom, unlike the flat result lists.

func (*State) ListRow

func (s *State) ListRow() int

func (*State) Open

func (s *State) Open()

func (*State) Render

func (s *State) Render(ctx modal.Context, host Host) string

func (*State) SetCur

func (s *State) SetCur(i int)

SetCur selects a field directly (used by tests and the mouse hit-test).

func (*State) Update

func (s *State) Update(host Host, key string) tea.Cmd

Update handles one keypress.

Jump to

Keyboard shortcuts

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