Skip to main content

Module palette

Module palette 

Source
Expand description

Surface-neutral command palette, focus model, accessibility metadata, and diagnostics presentation (VIEW4.06).

These are the interaction semantics SHARED by every view surface – the TUI (the sim-view-tty consumer) and the Web UI alike. The module is deliberately surface-neutral: it emits ordinary Scene values and Intent values and reads them back, but it never spells ANSI, DOM, or ARIA. A terminal renderer turns a focus annotation into a highlight; a browser turns the same annotation into a :focus ring and the A11y record into ARIA attributes. The core Scene carries only open metadata, so neither surface’s vocabulary leaks into the shared model.

Four facilities live here:

§Example

use sim_kernel::Symbol;
use sim_lib_view::palette::{Command, CommandKind, palette_intent, palette_scene};

let cmd = Command {
    id: Symbol::new("run"),
    label: "Run validation".to_owned(),
    kind: CommandKind::Invoke,
};
// The overlay lists the command and validates as a Scene.
let scene = palette_scene(std::slice::from_ref(&cmd), "run");
assert!(sim_lib_scene::validate_scene(&scene).is_ok());
// The chosen command reduces to a validated Intent.
let intent = palette_intent(&cmd, "main", 7).unwrap();
assert!(sim_lib_intent::validate_intent(&intent).is_ok());

Structs§

A11y
An accessibility record carried as open metadata on a scene node.
Command
One palette command: a stable id, a human label, and the kind of Intent it reduces to.

Enums§

CommandKind
How a Command reduces to an Intent when chosen.
FocusDir
A direction to advance focus in move_focus.

Constants§

A11Y_KEY
The map key under which with_a11y stores the accessibility record.
FOCUS_KEY
The map key under which the focus model stores the focused node id.

Functions§

a11y_of
Reads the accessibility record attached by with_a11y, if present and well-formed.
diagnostics_scene
Presents a Draft’s diagnostics as a deterministic scene/overlay.
filter_commands
Selects the commands whose label contains filter, case-insensitively, preserving input order.
focused_id
Reads the focused node id annotated by with_focus, if any.
move_focus
Advances focus deterministically through ids_in_order, wrapping at the ends, and returns the re-annotated scene.
palette_intent
Reduces a chosen Command to its matching validated Intent for pane at tick.
palette_scene
Builds a scene/overlay listing the commands matching filter.
with_a11y
Attaches an a11y metadata map (role/label/description/urgency) to node.
with_focus
Annotates scene with focused_id as open focus metadata.