Raxol.Protocols.Renderable protocol (Raxol v2.0.1)
View SourceProtocol for rendering data structures to terminal output.
This protocol provides a unified interface for rendering different types of data to the terminal. Any data structure that needs to be displayed in the terminal can implement this protocol.
Examples
defimpl Raxol.Protocols.Renderable, for: MyStruct do
def render(data, opts) do
# Return rendered string
end
def render_metadata(data) do
%{width: 80, height: 24, colors: true}
end
end
Summary
Functions
Renders the data structure to terminal output.
Gets rendering metadata for the data structure.
Types
@type t() :: term()
All the types that implement this protocol.
Functions
Renders the data structure to terminal output.
Options
:width- Maximum width for rendering (default: 80):height- Maximum height for rendering (default: 24):colors- Whether to include color codes (default: true):style- Style map to apply during rendering:theme- Theme to use for rendering
Returns
A binary string containing the rendered output with ANSI codes.
Gets rendering metadata for the data structure.
This helps the renderer understand the requirements and capabilities of the data being rendered.
Returns
A map containing:
:width- Preferred or required width:height- Preferred or required height:colors- Whether colors are used:scrollable- Whether content is scrollable:interactive- Whether content is interactive