module RatatuiRuby::Labs::A11y
A11Y lab: exports widget tree as XML.
Writes an XML representation of the widget tree to a temporary file every frame when enabled.
Constants
- OUTPUT_PATH
-
Path to the XML output file in the system temp directory.
Public Class Methods
Source
# File lib/ratatui_ruby/labs/a11y.rb, line 22 def dump_widget_tree(widget, _area = nil) ensure_rexml_loaded doc = REXML::Document.new doc.add(REXML::XMLDecl.new("1.0", "UTF-8")) doc.add(build_element(widget)) write_document(doc) end
Dumps the widget tree to XML (single widget for tree mode).
Source
# File lib/ratatui_ruby/labs/a11y.rb, line 44 def dump_widgets(widgets_with_areas) ensure_rexml_loaded Labs.warn_once!("Labs::A11y (RR_LABS=A11Y)") # Reset counter each frame for stable IDs @widget_id_counter = 0 doc = REXML::Document.new doc.add(REXML::XMLDecl.new("1.0", "UTF-8")) frame = REXML::Element.new("RatatuiFrame") widgets_with_areas.each do |widget, area| frame.add(build_element_with_area(widget, area)) end doc.add(frame) write_document(doc) end
Dumps multiple widgets captured from Frame API mode.
Source
# File lib/ratatui_ruby/labs/a11y.rb, line 34 def startup_message <<~MSG A11Y Lab enabled! Widget tree will be written to: #{OUTPUT_PATH} Press Enter to launch the TUI... MSG end