Atui.Rect (Atui v0.1.0)

Copy Markdown View Source

A rectangular region of the terminal, in cell coordinates.

The origin {0, 0} is the top-left cell. Rects are used both to describe a viewport (the whole terminal) and to place a view inside it.

Summary

Functions

Centres a width x height rect inside outer.

The rect inset by n cells on every side (a border's interior).

Builds a rect, clamping the size to zero or more.

A rect at the origin with the given size.

The same rect moved to the origin — what a view sees when it renders.

Types

t()

@type t() :: %Atui.Rect{
  height: non_neg_integer(),
  width: non_neg_integer(),
  x: integer(),
  y: integer()
}

Functions

centered(outer, width, height)

Centres a width x height rect inside outer.

The size is clamped to outer, so a popup larger than the terminal simply fills it instead of spilling over the edges.

inset(rect, n)

The rect inset by n cells on every side (a border's interior).

new(x, y, width, height)

Builds a rect, clamping the size to zero or more.

sized(width, height)

A rect at the origin with the given size.

to_local(rect)

The same rect moved to the origin — what a view sees when it renders.