Raxol.Core.Renderer.View.Utils.ViewUtils (Raxol v0.5.0)
View SourceProvides utility functions for common view operations in the Raxol view system.
Summary
Functions
Applies foreground and background colors to text.
Applies styles to a string of text.
Calculates the dimensions of a view based on its content and constraints.
Converts a color name to its ANSI color code.
Merges two views, with the second view's properties taking precedence.
Normalizes spacing values for padding and margin. Accepts various input formats and converts them to a standardized format.
Functions
Applies foreground and background colors to text.
Examples
apply_colors("Hello", fg: :red, bg: :blue)
apply_colors("World", fg: {255, 0, 0}, bg: {0, 0, 255})
Applies styles to a string of text.
Options
:bold
- Makes text bold:underline
- Underlines text:italic
- Makes text italic:strikethrough
- Adds strikethrough to text
Calculates the dimensions of a view based on its content and constraints.
Converts a color name to its ANSI color code.
Merges two views, with the second view's properties taking precedence.
Normalizes spacing values for padding and margin. Accepts various input formats and converts them to a standardized format.
Examples
normalize_spacing(5) # {5, 5, 5, 5}
normalize_spacing({10, 20}) # {10, 20, 10, 20}
normalize_spacing({1, 2, 3, 4}) # {1, 2, 3, 4}