Raxol.UI.Theming.BorderChars (Raxol v2.9.2)

View Source

Single canonical source for box-drawing glyph sets.

Sibling to Raxol.UI.Theming.Palette, which is deliberately restricted to color values; these are characters, not colors.

Why this module exists

The same glyph sets were written out in three places:

  • Raxol.Core.Box (lib/raxol/core/box_compat.ex) -- single, double, rounded, heavy, dashed
  • Raxol.Core.Renderer.View.ViewTypes.border_chars/0 -- single, double, rounded, bold, dashed, rebuilt on every call
  • Raxol.UI.BorderRenderer.get_border_chars/1 -- single, double, rounded, ascii, none, as function clauses

single, double and rounded were byte-identical in all three. heavy and bold are the same six glyphs under two names. Only dashed genuinely disagreed, so both variants are kept under distinct names rather than one being silently chosen:

  • :dashed -- ╌ / ╎ (double dash), the Raxol.Core.Box form
  • :dashed_fine -- ┄ / ┆ (triple dash), the ViewTypes form

Each caller derives its own accepted style set from this table and keeps the key names it already accepted, so no caller's behaviour changes. That is why :bold and :heavy both resolve here instead of one being renamed.

Summary

Types

The six glyphs that define a rectangular border.

Canonical glyph-set names. :bold is an alias of :heavy.

Functions

Every glyph set, keyed by style name. :bold and :heavy map to the same value.

The glyph set for style, or nil when the style is unknown.

The glyph sets for styles only, keyed by the names given.

Types

chars()

@type chars() :: %{
  top_left: String.t(),
  top_right: String.t(),
  bottom_left: String.t(),
  bottom_right: String.t(),
  horizontal: String.t(),
  vertical: String.t()
}

The six glyphs that define a rectangular border.

style()

@type style() ::
  :single
  | :double
  | :rounded
  | :heavy
  | :bold
  | :dashed
  | :dashed_fine
  | :block
  | :ascii
  | :none

Canonical glyph-set names. :bold is an alias of :heavy.

Functions

all()

@spec all() :: %{required(style()) => chars()}

Every glyph set, keyed by style name. :bold and :heavy map to the same value.

get(style)

@spec get(style() | atom()) :: chars() | nil

The glyph set for style, or nil when the style is unknown.

Callers decide their own fallback: Raxol.Core.Box falls back to :single, Raxol.UI.BorderRenderer to :none.

subset(styles)

@spec subset([style()]) :: %{required(style()) => chars()}

The glyph sets for styles only, keyed by the names given.

Lets a caller expose exactly the style names it already accepted, so collapsing onto this module changes no caller's public surface.

iex> Raxol.UI.Theming.BorderChars.subset([:single, :double]) |> Map.keys()
[:double, :single]