Skip to main content

Module settings_defs

Module settings_defs 

Source
Expand description

Declarative SettingDef table for the /settings TUI panel.

Task 1 of the settings-panel rewrite. Owns the static metadata (key, tab, group, label, description, widget kind, conditional visibility) for every editable setting plus the typed accessors get_display_value / apply_change. The renderer, the per-widget editors, and the map-editor screens consume this table and never reach into Settings fields directly.

The two MapEditor settings (keybindings, model_roles) are structured-editor territory: their rows expand into per-entry lists (SettingsMapRow) and their commits go through the typed helpers below (set_action_combos, set_model_role, remove_model_role), never through the scalar apply_change.

Constraints carried from the task brief:

  • Settings itself is unchanged — this module adds ACCESS, not persisted state.
  • apply_change for DisabledTools / ModelRoles / Keybindings must bail! so a stray scalar call is loud, never a silent no-op (their structured editors own those fields).

Structs§

SettingDef
Declarative metadata for a single setting row.

Enums§

SettingKey
Stable identifier for every editable setting in the panel.
SettingWidget
Widget kind used to edit the row. The renderer dispatches on this.
SettingsMapRow
Row-kind metadata for the map-editor expansions, index-aligned with the items emitted by settings_overlay_items (crate::tui_vt::slash::registry).
SettingsTab
Top-level tab the row renders under.

Constants§

SETTING_DEFS
The full table. Order matters: defs_for_tab preserves it and the renderer renders groups contiguously, so visually related rows must sit next to each other (and a new group must start with a fresh header row).

Functions§

apply_change
Apply a scalar edit.
defs_for_tab
Return every def that belongs to tab, in declaration order, with each row’s condition evaluated against s.
get_display_value
Render the row’s current value as a string. The renderer uses this for both the right-hand summary cell and (for Cycle widgets) the “next value” preview.
remove_model_role
Remove one model_roles entry. Returns whether the role existed. Unlike keybindings there is no last-entry guard — an empty model_roles is a perfectly valid state.
set_action_combos
Record action’s full effective combo list in settings.keybindings. When the list is identical to the built-in default the override entry is removed instead, so the persisted map stays minimal (Keymap::from_settings re-seeds defaults anyway).
set_model_role
Insert or update one model_roles entry.
toggle_disabled_tool
Toggle-helper used by the DisabledTools multiselect editor (Task 5). enabled = true removes the tool from the disabled set; enabled = false adds it if absent.