Raxol.Core.Renderer (Raxol Core v2.0.0)
View SourcePure functional renderer for Raxol buffers.
This module provides efficient rendering and diffing capabilities without requiring GenServers or stateful components.
Performance Targets
render_to_string/1completes in < 1ms for 80x24 bufferrender_diff/2completes in < 2ms for 80x24 buffer- Memory efficient (minimal allocations)
Examples
# Render buffer to ASCII string
buffer = Raxol.Core.Buffer.create_blank_buffer(80, 24)
output = Raxol.Core.Renderer.render_to_string(buffer)
# Calculate diff between two buffers
old_buffer = Raxol.Core.Buffer.create_blank_buffer(80, 24)
new_buffer = Raxol.Core.Buffer.write_at(old_buffer, 0, 0, "Changed")
diff = Raxol.Core.Renderer.render_diff(old_buffer, new_buffer)
Summary
Functions
Calculates the minimal diff between two buffers.
Renders a buffer to an ASCII string representation.
Functions
@spec render_diff(Raxol.Core.Buffer.t(), Raxol.Core.Buffer.t()) :: [map()]
Calculates the minimal diff between two buffers.
This is useful for efficient terminal updates where only changed cells need to be redrawn.
Parameters
old_buffer- The previous buffer statenew_buffer- The new buffer state
Returns
A list of changes representing the minimal set of updates needed to transform old_buffer into new_buffer.
Each change is a map with:
:x- Column coordinate:y- Row coordinate:char- New character:style- New style
@spec render_to_string(Raxol.Core.Buffer.t()) :: String.t()
Renders a buffer to an ASCII string representation.
Primarily used for testing and debugging. For production rendering, use more efficient methods.
Parameters
buffer- The buffer to render
Returns
A string representation of the buffer suitable for terminal display.