Raxol.Terminal.ScreenBuffer.DataAdapter (Raxol Terminal v2.6.0)

Copy Markdown View Source

Data structure adapter for ScreenBuffer operations.

Provides bidirectional conversion between the two buffer formats:

  • ScreenBuffer.Core format: :cells (list of lists of Cell structs)
  • LineOperations format: :lines (map with integer keys to line lists)

This adapter allows seamless interoperability between different buffer operation layers without requiring architectural changes.

Summary

Functions

Convert buffer from cells format to lines format.

Create empty cells structure for initialization.

Create an empty line with the specified width and style.

Get a line from buffer regardless of format.

Check if buffer uses cells format (list of lists).

Check if buffer uses lines format (map).

Convert buffer from lines format back to cells format.

Set a line in buffer regardless of format.

Execute an operation function with the buffer temporarily in lines format.

Functions

cells_to_lines(buffer)

Convert buffer from cells format to lines format.

Transforms buffer.cells (list of lists) into a :lines map where keys are row indices and values are cell lists.

create_empty_cells(width, height, default_style)

Create empty cells structure for initialization.

create_empty_line(width, default_style)

Create an empty line with the specified width and style.

get_line(buffer, y, default)

Get a line from buffer regardless of format.

has_cells_format?(buffer)

Check if buffer uses cells format (list of lists).

has_lines_format?(buffer)

Check if buffer uses lines format (map).

lines_to_cells(buffer, lines_map)

Convert buffer from lines format back to cells format.

Transforms :lines map back into buffer.cells (list of lists).

set_line(buffer, y, line)

Set a line in buffer regardless of format.

with_lines_format(buffer, operation_fn)

Execute an operation function with the buffer temporarily in lines format.

This is the key function that allows LineOperations to work with ScreenBuffer.Core structures without permanent conversion.

The operation function can return either:

  • A modified buffer map
  • A tuple where the second element is the modified buffer map