From ddbef37158b57f56217317b480e40d58f83a9c24 Mon Sep 17 00:00:00 2001 From: Matt Campbell Date: Sun, 27 Aug 2023 12:45:12 -0500 Subject: [PATCH] feat: Add role for terminals (#282) --- common/src/lib.rs | 5 +++++ consumer/src/text.rs | 2 +- platforms/macos/src/node.rs | 1 + platforms/unix/src/node.rs | 1 + platforms/windows/src/node.rs | 2 +- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/common/src/lib.rs b/common/src/lib.rs index 0efc705e..126ef975 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -249,6 +249,11 @@ pub enum Role { /// `TableView` and its subclasses, so they can be exposed correctly /// on certain platforms. ListGrid, + + /// This is just like a multi-line document, but signals that assistive + /// technologies should implement behavior specific to a VT-100-style + /// terminal. + Terminal, } impl Default for Role { diff --git a/consumer/src/text.rs b/consumer/src/text.rs index 8c479ba8..f5e76be2 100644 --- a/consumer/src/text.rs +++ b/consumer/src/text.rs @@ -838,7 +838,7 @@ impl<'a> Node<'a> { pub fn supports_text_ranges(&self) -> bool { matches!( self.role(), - Role::StaticText | Role::TextField | Role::Document | Role::SpinButton + Role::StaticText | Role::TextField | Role::Document | Role::SpinButton | Role::Terminal ) && self.inline_text_boxes().next().is_some() } diff --git a/platforms/macos/src/node.rs b/platforms/macos/src/node.rs index bc443f7e..9fb718b9 100644 --- a/platforms/macos/src/node.rs +++ b/platforms/macos/src/node.rs @@ -227,6 +227,7 @@ fn ns_role(node_state: &NodeState) -> &'static NSString { Role::DocTip => NSAccessibilityGroupRole, Role::DocToc => NSAccessibilityGroupRole, Role::ListGrid => NSAccessibilityUnknownRole, + Role::Terminal => NSAccessibilityTextAreaRole, } } } diff --git a/platforms/unix/src/node.rs b/platforms/unix/src/node.rs index 601d2139..f2369f51 100644 --- a/platforms/unix/src/node.rs +++ b/platforms/unix/src/node.rs @@ -326,6 +326,7 @@ impl<'a> NodeWrapper<'a> { // TODO: Are there special cases to consider? Role::Presentation | Role::Unknown => AtspiRole::Unknown, Role::ImeCandidate | Role::Keyboard => AtspiRole::RedundantObject, + Role::Terminal => AtspiRole::Terminal, } } diff --git a/platforms/windows/src/node.rs b/platforms/windows/src/node.rs index 1f77e1f4..03533f64 100644 --- a/platforms/windows/src/node.rs +++ b/platforms/windows/src/node.rs @@ -160,7 +160,7 @@ impl<'a> NodeWrapper<'a> { Role::Dialog => UIA_PaneControlTypeId, Role::Directory => UIA_ListControlTypeId, Role::DisclosureTriangle => UIA_ButtonControlTypeId, - Role::Document => UIA_DocumentControlTypeId, + Role::Document | Role::Terminal => UIA_DocumentControlTypeId, Role::EmbeddedObject => UIA_PaneControlTypeId, Role::Emphasis => UIA_TextControlTypeId, Role::Feed => UIA_GroupControlTypeId,