Raxol.Core.Box (Raxol Core v2.0.0)
View SourceBox 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
Functions
@spec draw_box( Raxol.Core.Buffer.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), box_style() ) :: Raxol.Core.Buffer.t()
Draws a box at the specified coordinates with the given style.
Parameters
buffer- The buffer to draw onx- X coordinate (left edge)y- Y coordinate (top edge)width- Width of the boxheight- Height of the boxstyle- Box style (default::single)
Examples
buffer = Raxol.Core.Box.draw_box(buffer, 5, 3, 20, 10, :double)
@spec draw_horizontal_line( Raxol.Core.Buffer.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), String.t() ) :: Raxol.Core.Buffer.t()
Draws a horizontal line at the specified position.
Parameters
buffer- The buffer to draw onx- X coordinate (starting position)y- Y coordinate (row)length- Length of the linechar- Character to use (default: "-")
@spec draw_vertical_line( Raxol.Core.Buffer.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), String.t() ) :: Raxol.Core.Buffer.t()
Draws a vertical line at the specified position.
Parameters
buffer- The buffer to draw onx- X coordinate (column)y- Y coordinate (starting position)length- Length of the linechar- Character to use (default: "|")
@spec fill_area( Raxol.Core.Buffer.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), String.t(), map() ) :: Raxol.Core.Buffer.t()
Fills an area with the specified character and style.
Parameters
buffer- The buffer to draw onx- X coordinate (left edge)y- Y coordinate (top edge)width- Width of the areaheight- Height of the areachar- Character to fill withstyle- Style to apply (default: %{})