Raxol.Plugins.PluginManager (Raxol v0.2.0)

View Source

Manages plugins for the Raxol terminal emulator. Handles plugin loading, lifecycle management, and event dispatching.

Summary

Functions

Disables a plugin by name.

Enables a plugin by name.

Gets the current API version of the plugin manager.

Gets a plugin by name.

Allows plugins to process or replace cells generated by the renderer. Iterates through enabled plugins that implement handle_cells/3. The callback should return {:ok, updated_plugin_state, cells_to_render, commands}.

Processes a keyboard event through all enabled plugins. Plugins can return commands and choose to halt propagation. Returns {:ok, updated_manager, list_of_commands, :propagate | :halt} or {:error, reason}.

Processes a mouse event through all enabled plugins, providing cell context. Plugins can choose to halt propagation if they handle the event. Returns {:ok, updated_manager, :propagate | :halt} or {:error, reason}.

Notifies all enabled plugins of a terminal resize event.

Gets a list of all loaded plugins.

Loads a plugin module and initializes it with the given configuration.

Loads multiple plugins in the correct dependency order.

Creates a new plugin manager with default configuration.

Processes input through all enabled plugins.

Processes mouse events through all enabled plugins.

Processes output through all enabled plugins. Returns {:ok, manager, transformed_output} if a plugin transforms the output, or {:ok, manager} if no transformation is needed.

Runs render-related hooks for all enabled plugins. Collects any direct output commands (e.g., escape sequences) returned by plugins. Returns {:ok, updated_manager, list_of_output_commands}

Unloads a plugin by name.

Updates the state of a specific plugin within the manager. The update_fun receives the current plugin state and should return the new state.

Types

t()

@type t() :: %Raxol.Plugins.PluginManager{
  api_version: String.t(),
  config: Raxol.Plugins.PluginConfig.t(),
  plugins: %{required(String.t()) => Raxol.Plugins.Plugin.t()}
}

Functions

disable_plugin(manager, name)

Disables a plugin by name.

enable_plugin(manager, name)

Enables a plugin by name.

get_api_version(manager)

Gets the current API version of the plugin manager.

get_plugin(manager, name)

Gets a plugin by name.

handle_cells(manager, cells, emulator_state)

Allows plugins to process or replace cells generated by the renderer. Iterates through enabled plugins that implement handle_cells/3. The callback should return {:ok, updated_plugin_state, cells_to_render, commands}.

Returns {:ok, updated_manager, processed_cells, collected_commands}.

handle_key_event(manager, event, rendered_cells)

Processes a keyboard event through all enabled plugins. Plugins can return commands and choose to halt propagation. Returns {:ok, updated_manager, list_of_commands, :propagate | :halt} or {:error, reason}.

handle_mouse_event(manager, event, rendered_cells)

Processes a mouse event through all enabled plugins, providing cell context. Plugins can choose to halt propagation if they handle the event. Returns {:ok, updated_manager, :propagate | :halt} or {:error, reason}.

handle_resize(manager, width, height)

Notifies all enabled plugins of a terminal resize event.

list_plugins(manager)

Gets a list of all loaded plugins.

load_plugin(manager, module, config \\ %{})

Loads a plugin module and initializes it with the given configuration.

load_plugins(manager, modules)

Loads multiple plugins in the correct dependency order.

new(config \\ %{})

Creates a new plugin manager with default configuration.

process_input(manager, input)

Processes input through all enabled plugins.

process_mouse(manager, event, emulator_state)

Processes mouse events through all enabled plugins.

process_output(manager, output)

Processes output through all enabled plugins. Returns {:ok, manager, transformed_output} if a plugin transforms the output, or {:ok, manager} if no transformation is needed.

run_render_hooks(manager)

Runs render-related hooks for all enabled plugins. Collects any direct output commands (e.g., escape sequences) returned by plugins. Returns {:ok, updated_manager, list_of_output_commands}

unload_plugin(manager, name)

Unloads a plugin by name.

update_plugin(manager, name, update_fun)

Updates the state of a specific plugin within the manager. The update_fun receives the current plugin state and should return the new state.