Class: RosettAi::Ui::AccessibleTui
- Defined in:
- lib/rosett_ai/ui/accessible_tui.rb
Overview
Accessible TUI adapter for screen-reader-friendly output.
Produces linear, sequential text without box-drawing characters or ANSI escape sequences. Auto-selected when assistive technology is detected (ORCA_RUNNING, BRLTTY_TTY).
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
-
#announce(message, priority: :polite) ⇒ void
Announce a message to the user via the UI backend.
-
#display_table(headers, rows) ⇒ void
Render a table in the UI backend.
-
#render(content) ⇒ void
Render content in the UI backend.
-
#show_spinner(message) ⇒ void
Display a spinner during a long-running operation.
Methods inherited from Tui
Methods inherited from Base
#accessible?, #prompt_user, #text_direction
Constructor Details
This class inherits a constructor from RosettAi::Ui::Tui
Instance Method Details
#announce(message, priority: :polite) ⇒ void
This method returns an undefined value.
Announce a message to the user via the UI backend.
58 59 60 61 |
# File 'lib/rosett_ai/ui/accessible_tui.rb', line 58 def announce(, priority: :polite) prefix = priority == :assertive ? '[ASSERTIVE]' : '[POLITE]' warn("#{prefix} #{}") end |
#display_table(headers, rows) ⇒ void
This method returns an undefined value.
Render a table in the UI backend.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rosett_ai/ui/accessible_tui.rb', line 28 def display_table(headers, rows) widths = compute_column_widths(headers, rows) header_line = format_row(headers, widths) separator = widths.map { |w| '-' * w }.join(' ') $stdout.puts(header_line) $stdout.puts(separator) rows.each { |row| $stdout.puts(format_row(row, widths)) } end |
#render(content) ⇒ void
This method returns an undefined value.
Render content in the UI backend.
19 20 21 |
# File 'lib/rosett_ai/ui/accessible_tui.rb', line 19 def render(content) $stdout.puts(RosettAi::TextSanitizer.strip_ansi(String(content))) end |
#show_spinner(message) ⇒ void
This method returns an undefined value.
Display a spinner during a long-running operation.
43 44 45 46 47 48 49 50 51 |
# File 'lib/rosett_ai/ui/accessible_tui.rb', line 43 def show_spinner() $stdout.puts("Processing: #{}...") result = yield $stdout.puts('Done.') result rescue StandardError => e $stdout.puts('Failed.') raise e end |