Skip to main content

Crate ftui_a11y

Crate ftui_a11y 

Source
Expand description

Accessibility layer for FrankenTUI.

§Role in FrankenTUI

ftui-a11y defines the accessibility tree infrastructure that lets widgets describe themselves to screen readers and other assistive technology. It is Phase 1 of the accessibility initiative: the core types and trait contract.

§Architecture

 Widget ──impl Accessible──> Vec<A11yNodeInfo>
                                    │
                             A11yTreeBuilder::add_node()
                                    │
                             A11yTreeBuilder::build()
                                    │
                               A11yTree (immutable snapshot)
                                    │
                             A11yTree::diff(&prev)
                                    │
                              A11yTreeDiff
                                    │
             screen-reader mirror + live announcements
                                    │
                         (future: platform bridge)

§How it fits in the system

  • ftui-core: provides Rect for node bounding boxes.
  • ftui-widgets: widgets will impl Accessible in a future phase.
  • ftui-render: the render pass will collect nodes via the builder.
  • Platform bridges (future Phase 3): consume A11yTreeDiff, screen-reader mirror text, and bounded live announcements to push updates to AccessKit / platform APIs.

§Quick start

use ftui_a11y::node::{A11yNodeInfo, A11yRole};
use ftui_a11y::tree::A11yTreeBuilder;
use ftui_core::geometry::Rect;

// Build a small tree.
let mut builder = A11yTreeBuilder::new();
let root = A11yNodeInfo::new(1, A11yRole::Window, Rect::new(0, 0, 80, 24))
    .with_name("My App")
    .with_children(vec![2]);
let button = A11yNodeInfo::new(2, A11yRole::Button, Rect::new(10, 5, 8, 1))
    .with_name("OK")
    .with_parent(1);
builder.add_node(root);
builder.add_node(button);
builder.set_root(1);
builder.set_focused(Some(2));
let tree = builder.build();

assert_eq!(tree.node_count(), 2);
assert_eq!(tree.focused().unwrap().name.as_deref(), Some("OK"));

Re-exports§

pub use preferences::AccessibilityPreferences;
pub use preferences::ContrastProfile;
pub use preferences::MotionFilteredAnnouncements;
pub use preferences::MotionProfile;

Modules§

node
Core accessibility node types.
preferences
Accessibility preference flags and the deterministic behavior policies derived from them (reduced motion, high contrast, forced colors).
tree
Accessibility tree construction and diffing.

Traits§

Accessible
Trait for widgets that provide accessibility metadata.