Raxol.Plugins.CellProcessor (Raxol v0.3.0)
View SourceHandles the processing of rendered cells, allowing plugins to modify or replace them. Especially targets placeholder cells generated by the rendering pipeline.
Summary
Functions
Processes a list of cells, allowing relevant plugins to handle placeholders.
Functions
@spec process(Raxol.Plugins.PluginManager.t(), [map()], map()) :: {:ok, Raxol.Plugins.PluginManager.t(), [map()], [binary()]} | {:error, any()}
Processes a list of cells, allowing relevant plugins to handle placeholders.
Iterates through the list of cells. If a cell is a placeholder (e.g.,
%{type: :placeholder, value: :image, ...}
), it identifies the responsible
plugin (based on placeholder_value
) and calls that plugin's handle_cells/3
callback.
The plugin's callback receives the placeholder cell map, the current emulator state, and its own current plugin state. It should return:
{:ok, updated_plugin_state, list_of_replacement_cells, list_of_commands}
: The placeholder is replaced bylist_of_replacement_cells
, and the plugin's state is updated.list_of_commands
are collected.{:cont, updated_plugin_state}
: The plugin declines to handle the placeholder. Its state is updated, but the placeholder is effectively removed (replaced by []).{:error, reason}
: An error occurred.
Regular cells (non-placeholders) are passed through unchanged.
Returns {:ok, updated_manager_state, final_cell_list, collected_commands}
where
updated_manager_state
reflects any changes to plugin states.