Raxol.UI.Accessibility.ScreenReader (Raxol v2.0.1)

View Source

Comprehensive screen reader support system for Raxol terminal applications.

This module provides full accessibility compliance including:

  • NVDA, JAWS, VoiceOver, and Orca screen reader support
  • ARIA attributes and semantic markup generation
  • Live region management for dynamic content updates
  • Keyboard navigation and focus management
  • Accessible names and descriptions
  • Screen reader optimization for terminal interfaces
  • Speech synthesis integration for audio feedback
  • Braille display support through platform APIs
  • Multi-language accessibility support

Features

Screen Reader Integration

  • Automatic ARIA markup generation for UI components
  • Live region announcements for status changes
  • Landmark navigation (main, navigation, complementary)
  • Skip links for keyboard navigation efficiency
  • Accessible form labeling and validation feedback

Terminal-Specific Accessibility

  • Virtual cursor navigation for terminal content
  • Character-by-character reading mode
  • Color and formatting description for visual elements
  • Command completion and syntax assistance
  • Error message verbalization with context

Usage

# Initialize screen reader support
{:ok, sr} = ScreenReader.start_link(
  screen_reader: :auto_detect,  # or :nvda, :jaws, :voiceover, :orca
  language: "en-US",
  speech_rate: 200,
  enable_braille: true
)

# Register UI component for accessibility
ScreenReader.register_component(sr, "main-terminal", %{
  role: "application",
  label: "Terminal Application",
  description: "Interactive terminal interface",
  landmarks: ["main", "navigation"]
})

# Announce dynamic content changes
ScreenReader.announce(sr, "Command completed successfully", :polite)
ScreenReader.announce(sr, "Error: File not found", :assertive)

# Set focus and update accessible state
ScreenReader.set_focus(sr, "command-input")
ScreenReader.update_property(sr, "status-bar", %{
  live: "polite",
  text: "Ready - 15:32"
})

Summary

Functions

Announces text to screen readers with specified priority.

Provides keyboard shortcut information for screen readers.

Returns a specification to start this module under a supervisor.

Enables or disables specific accessibility features.

Creates ARIA live region markup for HTML output.

Generates skip link navigation for keyboard users.

Describes visual formatting to screen reader users.

Gets the current accessibility state of a component.

Reads content at cursor position with specified verbosity.

Registers a UI component for screen reader accessibility.

Updates the focus to a specific component.

Sets reading mode for terminal content (character/word/line).

Updates an accessibility property of a component.

Validates WCAG 2.1 compliance for a component configuration.

Types

announcement_priority()

@type announcement_priority() :: :off | :polite | :assertive

aria_role()

@type aria_role() ::
  :application
  | :document
  | :dialog
  | :navigation
  | :main
  | :complementary
  | :banner
  | :contentinfo
  | :button
  | :textbox
  | :listbox
  | :list
  | :listitem
  | :table
  | :row
  | :cell
  | :columnheader
  | :rowheader

component_config()

@type component_config() :: %{
  role: aria_role(),
  label: String.t(),
  description: String.t() | nil,
  landmarks: [String.t()],
  live: announcement_priority() | nil,
  keyboard_shortcuts: %{required(atom()) => String.t()},
  accessible_name: String.t() | nil,
  accessible_description: String.t() | nil
}

config()

@type config() :: %{
  screen_reader: screen_reader_type(),
  language: String.t(),
  speech_rate: integer(),
  speech_pitch: integer(),
  speech_volume: float(),
  enable_braille: boolean(),
  enable_audio_cues: boolean(),
  verbosity_level: :minimal | :normal | :verbose,
  keyboard_echo: boolean(),
  character_echo: boolean(),
  word_echo: boolean()
}

focus_target()

@type focus_target() :: String.t()

screen_reader_type()

@type screen_reader_type() :: :nvda | :jaws | :voiceover | :orca | :auto_detect

Functions

announce(sr \\ __MODULE__, text, priority \\ :polite)

Announces text to screen readers with specified priority.

announce_shortcuts(sr \\ __MODULE__, component_id)

Provides keyboard shortcut information for screen readers.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

configure_feature(sr \\ __MODULE__, feature, enabled)

Enables or disables specific accessibility features.

create_live_region(id, priority, initial_text \\ "")

Creates ARIA live region markup for HTML output.

create_skip_links(targets)

Generates skip link navigation for keyboard users.

describe_formatting(sr \\ __MODULE__, element_id, formatting)

Describes visual formatting to screen reader users.

get_accessibility_state(sr \\ __MODULE__, component_id)

Gets the current accessibility state of a component.

handle_manager_info(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.

read_at_cursor(sr \\ __MODULE__, verbosity \\ :normal)

Reads content at cursor position with specified verbosity.

register_component(sr \\ __MODULE__, component_id, component_config)

Registers a UI component for screen reader accessibility.

set_focus(sr \\ __MODULE__, component_id)

Updates the focus to a specific component.

set_reading_mode(sr \\ __MODULE__, mode)

Sets reading mode for terminal content (character/word/line).

start_link(init_opts \\ [])

update_property(sr \\ __MODULE__, component_id, properties)

Updates an accessibility property of a component.

validate_wcag_compliance(component_config)

Validates WCAG 2.1 compliance for a component configuration.