Skip to main content

Module help_registry

Module help_registry 

Source
Expand description

Central registry for contextual help content.

Maps widget IDs to structured help entries with hierarchical resolution (widget → container → app). Widgets register their help content via HelpRegistry::register, and consumers look up help for a given widget via HelpRegistry::get or HelpRegistry::resolve (which walks the hierarchy).

§Invariants

  1. Each HelpId maps to at most one HelpContent at any given time.
  2. resolve walks parents until it finds content or reaches the root; it never cycles (parent chains are acyclic by construction—set_parent rejects cycles).
  3. Lazy providers are called at most once per lookup; results are cached in the registry for subsequent lookups.

§Example

use ftui_widgets::help_registry::{HelpRegistry, HelpContent, HelpId, Keybinding};

let mut reg = HelpRegistry::new();
let widget_id = HelpId(42);

reg.register(widget_id, HelpContent {
    short: "Save the current file".into(),
    long: Some("Writes the buffer to disk, creating the file if needed.".into()),
    keybindings: vec![Keybinding::new("Ctrl+S", "Save")],
    see_also: vec![],
});

assert_eq!(reg.get(widget_id).unwrap().short, "Save the current file");

Structs§

HelpContent
Structured help content for a widget.
HelpId
Unique identifier for a help-registered widget.
HelpRegistry
Central registry mapping widget IDs to help content.
Keybinding
A keyboard shortcut associated with a widget.