class RatatuiRuby::Layout::Position

A position in terminal coordinates.

Layout code passes x/y pairs between functions. Bundling them into separate variables is verbose and prone to ordering mistakes.

This class wraps column and row into a single immutable object. Pass it around, destructure it, or convert from a Rect.

Use it for cursor positioning, mouse coordinates, or anywhere you need to represent a single point on the terminal grid.

Example

pos = Layout::Position.new(x: 10, y: 5)
puts "Cursor at column #{pos.x}, row #{pos.y}"

# Extract from a Rect
rect = Layout::Rect.new(x: 10, y: 5, width: 80, height: 24)
pos = rect.as_position # => Position(x: 10, y: 5)