Raxol.Plugins.EventHandler (Raxol v0.4.0)
View SourceHandles dispatching various events (input, resize, mouse, etc.) to plugins.
Provides a generic mechanism to iterate through enabled plugins and invoke
specific callback functions defined by the Raxol.Plugins.Plugin
behaviour.
Updates the plugin manager state based on the results returned by the plugins.
Summary
Functions
Dispatches an 'input' event to all enabled plugins implementing handle_input/2
.
Dispatches a key event (map) to enabled plugins implementing handle_input/2
.
NOTE: Uses handle_input/2
as per the original plugin manager logic. Consider adding
Dispatches a mouse event (new format with propagation control) to enabled plugins implementing handle_mouse/3
.
Dispatches a 'mouse' event (older format) to all enabled plugins implementing handle_mouse/3
.
This corresponds to the previous plugin manager's process_mouse/3 function.
Dispatches an 'output' event to all enabled plugins implementing handle_output/2
.
Accumulates transformed output.
Dispatches a 'resize' event to all enabled plugins implementing handle_resize/3
.
Types
@type accumulator() :: any()
@type callback_name() :: atom()
@type event_args() :: [any()]
@type handler_payload() :: accumulator() | {:error, term()}
@type handler_result() :: {:cont | :halt, handler_payload()}
Functions
@spec handle_input(Raxol.Plugins.Manager.Core.t(), binary()) :: {:ok, Raxol.Plugins.Manager.Core.t()} | {:error, any()}
Dispatches an 'input' event to all enabled plugins implementing handle_input/2
.
@spec handle_key_event(Raxol.Plugins.Manager.Core.t(), map(), map()) :: {:ok, Raxol.Plugins.Manager.Core.t(), [any()], :propagate | :halt} | {:error, any()}
Dispatches a key event (map) to enabled plugins implementing handle_input/2
.
NOTE: Uses handle_input/2
as per the original plugin manager logic. Consider adding
a dedicated `handle_key_event` callback to the Plugin behaviour later.
Accumulates commands and handles propagation control.
@spec handle_mouse_event(Raxol.Plugins.Manager.Core.t(), map(), map()) :: {:ok, Raxol.Plugins.Manager.Core.t(), :propagate | :halt} | {:error, any()}
Dispatches a mouse event (new format with propagation control) to enabled plugins implementing handle_mouse/3
.
@spec handle_mouse_legacy(Raxol.Plugins.Manager.Core.t(), tuple(), map()) :: {:ok, Raxol.Plugins.Manager.Core.t()} | {:error, any()}
Dispatches a 'mouse' event (older format) to all enabled plugins implementing handle_mouse/3
.
This corresponds to the previous plugin manager's process_mouse/3 function.
@spec handle_output(Raxol.Plugins.Manager.Core.t(), binary()) :: {:ok, Raxol.Plugins.Manager.Core.t(), binary()} | {:error, any()}
Dispatches an 'output' event to all enabled plugins implementing handle_output/2
.
Accumulates transformed output.
@spec handle_resize(Raxol.Plugins.Manager.Core.t(), integer(), integer()) :: {:ok, Raxol.Plugins.Manager.Core.t()} | {:error, any()}
Dispatches a 'resize' event to all enabled plugins implementing handle_resize/3
.