ExRatatui.Layout.Padding (ExRatatui v0.11.0)

Copy Markdown View Source

Constructors for %ExRatatui.Widgets.Block{} padding tuples.

Block's :padding field is a {left, right, top, bottom} tuple of non-negative integers. Writing those out by hand is noisy for the common symmetric cases — these helpers mirror ratatui's Padding constructors and return the tuple Block already accepts, so they drop straight into padding:.

%Block{padding: ExRatatui.Layout.Padding.uniform(1)}
%Block{padding: ExRatatui.Layout.Padding.symmetric(2, 1)}

Every helper returns a plain {l, r, t, b} tuple — there is no struct and no runtime cost beyond building the tuple.

Summary

Functions

Padding on left + right only; top + bottom are zero.

Explicit per-side padding. The identity constructor — included so a call site can stay in the Padding.* namespace for all four cases.

Horizontal padding on left + right, vertical padding on top + bottom.

The same padding on all four sides.

Padding on top + bottom only; left + right are zero.

Types

Functions

horizontal(n)

@spec horizontal(non_neg_integer()) :: t()

Padding on left + right only; top + bottom are zero.

Examples

iex> ExRatatui.Layout.Padding.horizontal(2)
{2, 2, 0, 0}

new(left, right, top, bottom)

Explicit per-side padding. The identity constructor — included so a call site can stay in the Padding.* namespace for all four cases.

Examples

iex> ExRatatui.Layout.Padding.new(1, 2, 3, 4)
{1, 2, 3, 4}

symmetric(horizontal, vertical)

@spec symmetric(non_neg_integer(), non_neg_integer()) :: t()

Horizontal padding on left + right, vertical padding on top + bottom.

Examples

iex> ExRatatui.Layout.Padding.symmetric(3, 1)
{3, 3, 1, 1}

uniform(n)

@spec uniform(non_neg_integer()) :: t()

The same padding on all four sides.

Examples

iex> ExRatatui.Layout.Padding.uniform(2)
{2, 2, 2, 2}

vertical(n)

@spec vertical(non_neg_integer()) :: t()

Padding on top + bottom only; left + right are zero.

Examples

iex> ExRatatui.Layout.Padding.vertical(1)
{0, 0, 1, 1}