class RatatuiRuby::Layout

Divides an area into smaller chunks.

Terminal screens vary in size. Hardcoded positions break when the window resizes. You need a way to organize space dynamically.

This class manages geometry. It splits a given area into multiple sections based on a list of constraints.

Use layouts to build responsive grids. Stack sections vertically for a sidebar-main structure. Partition them horizontally for headers and footers. Let the layout engine do the math.

Examples

# A simple vertical split (Sidebar / Main)
Layout.new(
  direction: :horizontal,
  constraints: [
    Constraint.length(20), # Sidebar
    Constraint.min(0)      # Main content
  ]
)

# Flex layout (Centering a block)
Layout.new(
  direction: :vertical,
  flex: :center,
  constraints: [Constraint.length(10)], # A 10-row block centered vertically
  children: [modal_block]
)