Skip to main content

Crate tui_a11y

Crate tui_a11y 

Source
Expand description

Experimental Linux accessibility support for terminal UIs, via AT-SPI and AccessKit.

Terminal UI frameworks render characters at cell positions; they have no concept of focus, selection, or semantic roles, and no retained widget tree to derive them from. This crate doesn’t try to infer any of that from a rendered screen buffer. Instead, the app declares a small, separate accessibility tree by hand see TreeBuilder and this crate serves it over AT-SPI via A11y.

§Quick start

use tui_a11y::{A11y, Role, TreeBuilder, node_id};

let window_id = node_id("window");
let mut tree = TreeBuilder::new();
tree.node(window_id, Role::Window, "My app", []);
tree.root(window_id);

let mut a11y = A11y::new(tree.build());

// ...in your render loop, after every draw:
let mut tree = TreeBuilder::new();
tree.node(window_id, Role::Window, "My app", []);
tree.root(window_id);
a11y.update(tree.build());

§The IsEnabled gotcha

A11y::new only actually registers on the AT-SPI bus once the desktop reports org.a11y.Status.IsEnabled = true which happens automatically once a screen reader like Orca is running, but is otherwise off by default on most Linux desktops. There is no error and no log line when it’s off: A11y::update just quietly does nothing. first:

gsettings set org.gnome.desktop.interface toolkit-accessibility true

Structs§

A11y
Wires a terminal app into the Linux AT-SPI accessibility bus.
ActionRequest
Node
A single accessible object. A complete UI is represented as a tree of these.
NodeId
The stable identity of a Node, unique within the node’s tree.
SubTree
A self-contained chunk of accessibility nodes, produced by one of the adapter functions (list_nodes, table_nodes, …) and merged into a TreeBuilder with TreeBuilder::subtree.
TreeBuilder
Builds a TreeUpdate by hand, one frame at a time.
TreeId
The stable identity of a tree.
TreeInfo
The data associated with an accessibility tree that’s global to the tree and not associated with any particular node.
TreeUpdate
A serializable representation of an atomic change to a tree.

Enums§

Action
An action to be taken on an accessibility node.
Role
The type of an accessibility node.

Traits§

Accessible
Opt-in extension point for a stateless widget to describe its own accessibility subtree.
StatefulAccessible
Same as Accessible, for widgets whose accessible state lives in a separate State type (mirrors Ratatui’s StatefulWidget split).

Functions§

gauge_nodes
Builds a single ProgressIndicator node. ratio is clamped to 0.0..=1.0 and reported as 0..=100.
group_nodes
Wraps child subtrees in a single labeled Group node, the way to attach a name to a list_nodes/table_nodes/tabs_nodes result, or to bundle several widgets under one heading.
items_nodes
Builds a subtree for any flat, selectable collection: container_role wraps one item_role node per entry.
list_nodes
Builds an unlabeled List subtree, one ListItem per entry. Wrap it in group_nodes to give the list itself a name.
node_id
Derives a stable NodeId from an app-chosen key.
table_nodes
Builds Table subtree: an optional header row, then one Row of Cells per data row.
tabs_nodes
Builds a TabList subtree, one Tab per title.
text_nodes
Builds a single Paragraph node from source text. Pass the source string, not a reflowed/wrapped render of it a screen reader does its own line breaking.