Website Menu Verification

Verifies the inline menu example on the RatatuiRuby website.

This example exists as a documentation regression test. It ensures the website’s inline viewport menu demo remains functional.

Usage

choices = ["Production", "Staging", "Development"]
index = 0

RatatuiRuby.run(viewport: :inline, height: 5) do |tui|
  loop do
    tui.draw do |frame|
      items = choices.map.with_index do |c, i|
        prefix = i == index ? "● " : "β—‹ "
        "#{prefix}#{c}"
      end
      widget = tui.paragraph(
        text: items.join("\n"),
        block: tui.block(
          borders: :all,
          title: "Select Environment",
          titles: [{ content: "↑/↓ Enter | Ctrl+C", position: :bottom, alignment: :right }]
        )
      )
      frame.render_widget(widget, frame.area)
    end

    case tui.poll_event
    in { type: :key, code: "up" }
      index = (index - 1) % choices.size
    in { type: :key, code: "down" }
      index = (index + 1) % choices.size
    in { type: :key, code: "enter" } | { type: :key, code: "c", modifiers: ["ctrl"] }
      area = tui.viewport_area
      RatatuiRuby.cursor_position = [0, area.y + area.height]
      break
    else nil
    end
  end
end

puts
puts "Deploying to #{choices[index]}..."

Features Demonstrated