Module: RatatuiRuby::Frame::A11yCapture

Included in:
RatatuiRuby::Frame
Defined in:
lib/ratatui_ruby/labs/frame_a11y_capture.rb

Overview

A11Y Lab Integration

When the A11Y lab is enabled, we capture widgets as they are rendered and write the tree to XML when flush_a11y_capture is called.

Instance Method Summary collapse

Instance Method Details

#flush_a11y_captureObject

Called at end of draw block to flush captured widgets



39
40
41
42
43
44
45
# File 'lib/ratatui_ruby/labs/frame_a11y_capture.rb', line 39

def flush_a11y_capture
  widgets = @a11y_widgets
  return unless Labs.enabled?(:a11y) && widgets&.any?

  Labs::A11y.dump_widgets(widgets)
  @a11y_widgets = nil
end

#render_stateful_widget(widget, area, state) ⇒ Object

Intercepts render_stateful_widget to capture widgets for A11Y export.

Parameters:

  • widget (widget)

    The widget being rendered

  • area (Layout::Rect)

    The area to render into

  • state (Object)

    The widget state



30
31
32
33
34
35
36
# File 'lib/ratatui_ruby/labs/frame_a11y_capture.rb', line 30

def render_stateful_widget(widget, area, state)
  if Labs.enabled?(:a11y)
    widgets = (@a11y_widgets ||= []) #: Array[[(_CustomWidget | widget), Layout::Rect]]
    widgets << [widget, area]
  end
  super
end

#render_widget(widget, area) ⇒ Object

Intercepts render_widget to capture widgets for A11Y export.

Parameters:

  • widget (widget)

    The widget being rendered

  • area (Layout::Rect)

    The area to render into



18
19
20
21
22
23
24
# File 'lib/ratatui_ruby/labs/frame_a11y_capture.rb', line 18

def render_widget(widget, area)
  if Labs.enabled?(:a11y)
    widgets = (@a11y_widgets ||= []) #: Array[[(_CustomWidget | widget), Layout::Rect]]
    widgets << [widget, area]
  end
  super
end