Raxol.Core.Box (Raxol Core v2.0.0)

View Source

Box drawing and line rendering utilities for terminal UIs.

This module provides functions for drawing boxes, lines, and filled areas using Unicode box drawing characters.

Supported Box Styles

  • :single - Single line box drawing (─│┌┐└┘)
  • :double - Double line box drawing (═║╔╗╚╝)
  • :rounded - Rounded corners (─│╭╮╰╯)
  • :heavy - Heavy/bold lines (━┃┏┓┗┛)
  • :dashed - Dashed lines (╌╎┌┐└┘)

Examples

# Draw a simple box
buffer = Raxol.Core.Buffer.create_blank_buffer(80, 24)
buffer = Raxol.Core.Box.draw_box(buffer, 5, 3, 20, 10, :single)

# Draw a double-line box with style
buffer = Raxol.Core.Box.draw_box(buffer, 10, 5, 30, 8, :double)

# Draw horizontal and vertical lines
buffer = Raxol.Core.Box.draw_horizontal_line(buffer, 0, 0, 80)
buffer = Raxol.Core.Box.draw_vertical_line(buffer, 0, 0, 24)

Summary

Functions

Draws a box at the specified coordinates with the given style.

Draws a horizontal line at the specified position.

Draws a vertical line at the specified position.

Fills an area with the specified character and style.

Types

box_style()

@type box_style() :: :single | :double | :rounded | :heavy | :dashed

Functions

draw_box(buffer, x, y, width, height, style \\ :single)

Draws a box at the specified coordinates with the given style.

Parameters

  • buffer - The buffer to draw on
  • x - X coordinate (left edge)
  • y - Y coordinate (top edge)
  • width - Width of the box
  • height - Height of the box
  • style - Box style (default: :single)

Examples

buffer = Raxol.Core.Box.draw_box(buffer, 5, 3, 20, 10, :double)

draw_horizontal_line(buffer, x, y, length, char \\ "-")

Draws a horizontal line at the specified position.

Parameters

  • buffer - The buffer to draw on
  • x - X coordinate (starting position)
  • y - Y coordinate (row)
  • length - Length of the line
  • char - Character to use (default: "-")

draw_vertical_line(buffer, x, y, length, char \\ "|")

Draws a vertical line at the specified position.

Parameters

  • buffer - The buffer to draw on
  • x - X coordinate (column)
  • y - Y coordinate (starting position)
  • length - Length of the line
  • char - Character to use (default: "|")

fill_area(buffer, x, y, width, height, char, style \\ %{})

Fills an area with the specified character and style.

Parameters

  • buffer - The buffer to draw on
  • x - X coordinate (left edge)
  • y - Y coordinate (top edge)
  • width - Width of the area
  • height - Height of the area
  • char - Character to fill with
  • style - Style to apply (default: %{})