Raxol.Core.Renderer.View (Raxol v0.3.0)
View SourceMain facade module for the Raxol view system. Provides a unified interface for creating and managing views.
Summary
Functions
Wraps a view with a border using a block style.
Wraps a view with a border using a bold style.
Creates a new border around a view.
Macro for creating a border around a view with a do-block for children.
Creates a new box view with padding and optional border.
Wraps a view with a border using a double line style.
Creates a new flex container.
Creates a new grid layout.
Macro for creating a grid layout with a do-block for children.
Creates a new view with the specified type and options.
Creates a new panel view (box with border and children).
Wraps a view with a border using a rounded style.
Creates a new row layout.
Macro for creating a row layout with a do-block for children.
Creates a new scrollable view.
Macro for creating a scrollable view with a do-block for children.
Wraps a view with a border using a simple style.
Creates a new text view.
Wraps a view with a border, optionally with a title and style.
Functions
Wraps a view with a border using a block style.
Parameters
view- The view to wrap with a borderopts- Options for the border:title- Optional title to display in the border:align- Title alignment (:left,:center,:right)
Examples
View.block_border(view)
View.block_border(view, title: "Title")
Wraps a view with a border using a bold style.
Parameters
view- The view to wrap with a borderopts- Options for the border:title- Optional title to display in the border:align- Title alignment (:left,:center,:right)
Examples
View.bold_border(view)
View.bold_border(view, title: "Title")
Creates a new border around a view.
Options
:style- Border style:title- Title for the border:fg- Foreground color:bg- Background color
Examples
View.border(view, style: :single)
View.border(view, title: "Title", style: :double)
Macro for creating a border around a view with a do-block for children.
Examples
View.border_wrap style: [:bold] do
[View.text("A"), View.text("B")]
end
View.border_wrap :single, style: [:bold] do
[View.text("A"), View.text("B")]
end
Creates a new box view with padding and optional border.
Parameters
opts- Options for the box:padding- Padding around the content (default: 0):border- Border style (:none,:single,:double,:rounded,:bold,:block,:simple)
Examples
View.box(padding: 2)
View.box(padding: 2, border: :single)
Wraps a view with a border using a double line style.
Parameters
view- The view to wrap with a borderopts- Options for the border:title- Optional title to display in the border:align- Title alignment (:left,:center,:right)
Examples
View.double_border(view)
View.double_border(view, title: "Title")
Creates a new flex container.
Options
:direction- Flex direction (:row or :column):children- Child views:align- Alignment of children:justify- Justification of children:gap- Gap between children:wrap- Whether to wrap children
Examples
View.flex(direction: :column, children: [text("Hello"), text("World")])
View.flex(align: :center, gap: 2, wrap: true)
Creates a new grid layout.
Options
:columns- Number of columns or list of column sizes:rows- Number of rows or list of row sizes:gap- Gap between grid items:align- Alignment of items within cells:justify- Justification of items within cells:children- Child views
Examples
View.grid(columns: 3, rows: 2)
View.grid(columns: [1, 2, 1], rows: ["auto", "1fr"])
Macro for creating a grid layout with a do-block for children.
Examples
View.grid columns: 3 do
[View.text("A"), View.text("B"), View.text("C")]
end
Creates a new view with the specified type and options.
Options
:type- The type of view to create:position- Position of the view {x, y}:z_index- Z-index for layering:size- Size of the view {width, height}:style- Style options for the view:fg- Foreground color:bg- Background color:border- Border style:padding- Padding around the view:margin- Margin around the view:children- Child views:content- Content for the view
Examples
View.new(:box, size: {80, 24})
View.new(:text, content: "Hello", fg: :red)
Creates a new panel view (box with border and children).
Options
:children- Child views:border- Border style (default: :single):padding- Padding inside the panel (default: 1):style- Additional style options:title- Optional title for the panel:fg- Foreground color:bg- Background color
Examples
View.panel(children: [View.text("Hello")])
View.panel(border: :double, title: "Panel")
Wraps a view with a border using a rounded style.
Parameters
view- The view to wrap with a borderopts- Options for the border:title- Optional title to display in the border:align- Title alignment (:left,:center,:right)
Examples
View.rounded_border(view)
View.rounded_border(view, title: "Title")
Creates a new row layout.
Options
:children- Child views:align- Alignment of children:justify- Justification of children:gap- Gap between children
Examples
View.row(children: [text("Hello"), text("World")])
View.row(align: :center, gap: 2)
Macro for creating a row layout with a do-block for children.
Examples
View.row style: [:bold] do
[View.text("A"), View.text("B")]
end
Creates a new scrollable view.
Options
:viewport- Viewport size {width, height}:offset- Initial scroll offset {x, y}:scrollbars- Whether to show scrollbars:fg- Foreground color:bg- Background color
Examples
View.scroll(view, viewport: {80, 24})
View.scroll(view, offset: {0, 10}, scrollbars: true)
Macro for creating a scrollable view with a do-block for children.
Examples
View.scroll_wrap viewport: {80, 24} do
[View.text("A"), View.text("B")]
end
Wraps a view with a border using a simple style.
Parameters
view- The view to wrap with a borderopts- Options for the border:title- Optional title to display in the border:align- Title alignment (:left,:center,:right)
Examples
View.simple_border(view)
View.simple_border(view, title: "Title")
Creates a new text view.
Options
:content- The text content:fg- Foreground color:bg- Background color:style- Text style options:align- Text alignment:wrap- Text wrapping mode
Examples
View.text("Hello", fg: :red)
View.text("World", style: [bold: true, underline: true])
Wraps a view with a border, optionally with a title and style.
Parameters
view- The view to wrap with a borderopts- Options for the border:title- Optional title to display in the border:style- Border style (:single,:double,:rounded,:bold,:block,:simple):align- Title alignment (:left,:center,:right)
Examples
View.border_wrap(view, style: :single)
View.border_wrap(view, title: "Title", style: :double)