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
- Variables
- func CycleHexBytesPerRow(cur, dir int) int
- func CycleIndex(list []string, cur string, dir int) int
- func GroupLead(i int) bool
- func RowHeight(i int) int
- func ThemeList(defaultTheme string) []string
- type Host
- type Meta
- type State
- func (s *State) Activate(host Host) tea.Cmd
- func (s *State) Active() bool
- func (s *State) ClickRow(listRow int) bool
- func (s *State) Close()
- func (s *State) Cur() int
- func (s *State) List() (sel *int, top, n int, wrap, ok bool)
- func (s *State) ListRow() int
- func (s *State) Open()
- func (s *State) Render(ctx modal.Context, host Host) string
- func (s *State) SetCur(i int)
- func (s *State) Update(host Host, key string) tea.Cmd
Constants ¶
const FieldCount = 16
FieldCount is the number of settings rows; it must match the Metas table and the shell's CycleSetting switch.
Variables ¶
var DisasmTargets = []string{"entry", "main", "start", "text", "lowest"}
DisasmTargets is the cycle for the "Disasm target" setting.
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"},
}
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 ¶
CycleHexBytesPerRow steps the bytes-per-row preference through 8 → 16 → 32.
func CycleIndex ¶
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 ¶
GroupLead reports whether field i begins a new group (so its header row is drawn before it).
func RowHeight ¶
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 ¶
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 ¶
Activate is the mouse double-click action: step the selected field forward.
func (*State) ClickRow ¶
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) List ¶
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.