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 trueStructs§
- A11y
- Wires a terminal app into the Linux AT-SPI accessibility bus.
- Action
Request - 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 aTreeBuilderwithTreeBuilder::subtree. - Tree
Builder - Builds a
TreeUpdateby hand, one frame at a time. - TreeId
- The stable identity of a tree.
- Tree
Info - The data associated with an accessibility tree that’s global to the tree and not associated with any particular node.
- Tree
Update - A serializable representation of an atomic change to a tree.
Enums§
Traits§
- Accessible
- Opt-in extension point for a stateless widget to describe its own accessibility subtree.
- Stateful
Accessible - Same as
Accessible, for widgets whose accessible state lives in a separateStatetype (mirrors Ratatui’sStatefulWidgetsplit).
Functions§
- gauge_
nodes - Builds a single
ProgressIndicatornode.ratiois clamped to0.0..=1.0and reported as0..=100. - group_
nodes - Wraps child subtrees in a single labeled
Groupnode, the way to attach a name to alist_nodes/table_nodes/tabs_nodesresult, or to bundle several widgets under one heading. - items_
nodes - Builds a subtree for any flat, selectable collection:
container_rolewraps oneitem_rolenode per entry. - list_
nodes - Builds an unlabeled
Listsubtree, oneListItemper entry. Wrap it ingroup_nodesto give the list itself a name. - node_id
- Derives a stable
NodeIdfrom an app-chosen key. - table_
nodes - Builds
Tablesubtree: an optional header row, then oneRowofCells per data row. - tabs_
nodes - Builds a
TabListsubtree, oneTabper title. - text_
nodes - Builds a single
Paragraphnode from source text. Pass the source string, not a reflowed/wrapped render of it a screen reader does its own line breaking.