Raxol.Core.UserPreferences (Raxol Core v2.8.0)

Copy Markdown View Source

Manages user preferences for the terminal emulator.

Acts as a GenServer holding the preferences state and handles persistence.

Uses Raxol.Core.Utils.Debounce for debounced save operations, avoiding redundant disk writes when multiple preference changes occur in quick succession.

Summary

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

default_preferences()

Returns the default preferences map: theme, terminal, accessibility and keybindings sections.

raxol_core does not depend on raxol_terminal, so the :terminal section is read from application config, first match wins:

  1. config :raxol_core, :default_terminal_preferences, value, for a consumer that wants its own defaults;
  2. :default_terminal_preferences in the :raxol_terminal application env, which raxol_terminal ships in its .app file as {Raxol.Terminal.Config.Defaults, :generate_default_config, []};
  3. otherwise %{} (raxol_core on its own).

value is a map or an {module, function, args} whose call returns a map. Anything else, including an MFA whose function is not exported, logs a warning and yields %{}.

get(key_or_path, pid_or_name \\ __MODULE__)

get_all(pid_or_name \\ __MODULE__)

get_theme_id(pid_or_name \\ __MODULE__)

Returns the current theme id as an atom, defaulting to :default if not set or invalid.

handle_manager_cast(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.

reset_to_defaults_for_test!(pid_or_name \\ __MODULE__)

save!(pid_or_name \\ __MODULE__)

set(key_or_path, value, pid_or_name \\ __MODULE__)

set_preferences(preferences, pid_or_name \\ __MODULE__)

start_link(init_opts \\ [])