### Fetch Elixir project dependencies Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/01_getting_started/quick_start.md Fetches and installs the defined dependencies for your Elixir project, including Raxol. ```bash mix deps.get ``` -------------------------------- ### Setup Raxol Project Dependencies and Database Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/03_components_and_layout/components/visualization/testing-guide.md Commands to fetch Elixir dependencies, compile the project, install Node.js dependencies for the VS Code extension, and set up the PostgreSQL test database for Raxol. ```bash mix deps.get mix compile cd extensions/vscode npm install mix ecto.create mix ecto.migrate ``` -------------------------------- ### Start Raxol application in IEx Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/01_getting_started/quick_start.md Starts a Raxol application directly within an IEx session for quick testing and development. ```elixir iex> Raxol.Core.Runtime.Lifecycle.start_application(MyRaxolApp.Application) ``` -------------------------------- ### Configure Raxol application in mix.exs Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/01_getting_started/quick_start.md Configures the main application module in `mix.exs` to ensure the Raxol application starts correctly when the project is launched. ```elixir def application do [ extra_applications: [:logger], mod: {MyRaxolApp.Application, []} ] end ``` -------------------------------- ### Start All Raxol Metrics System Components Source: https://github.com/hydepwns/raxol/blob/master/lib/raxol/core/metrics/README.md Provides a basic setup example demonstrating how to concurrently start all core components of the Raxol Metrics System: Unified Collector, Aggregator, Visualizer, and Alert Manager. ```Elixir # Start all components {:ok, collector} = Raxol.Core.Metrics.UnifiedCollector.start_link() {:ok, aggregator} = Raxol.Core.Metrics.Aggregator.start_link() {:ok, visualizer} = Raxol.Core.Metrics.Visualizer.start_link() {:ok, alert_manager} = Raxol.Core.Metrics.AlertManager.start_link() ``` -------------------------------- ### Create a new Elixir Mix project Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/01_getting_started/quick_start.md Initializes a new Elixir project and navigates into its directory. This is an optional step if you already have a project. ```bash mix new my_raxol_app cd my_raxol_app ``` -------------------------------- ### Run Raxol Component Showcase Example Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/05_development_and_testing/DevelopmentSetup.md Executes a specific Elixir example script that showcases Raxol components, useful for development and testing individual features. ```bash mix run examples/snippets/showcase/component_showcase.exs ``` -------------------------------- ### Raxol Application Keyboard Shortcut Implementation (Elixir) Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/03_components_and_layout/keyboard_shortcuts_guide.md Provides a complete Elixir application example demonstrating the setup of UX refinement, registration of multiple shortcuts (save, quit), and handling of key events within an `handle_event` callback. ```Elixir defmodule MyApp do use Raxol.App alias Raxol.Core.KeyboardShortcuts def start_link(_opts) do # Setup UXRefinement.init() UXRefinement.enable_feature(:keyboard_shortcuts) # Register shortcuts KeyboardShortcuts.register_shortcut(:save, "Ctrl+S", &save/0, context: :editor, priority: :high ) KeyboardShortcuts.register_shortcut(:quit, "Ctrl+Q", &quit/0) # Start app Raxol.Core.Runtime.Lifecycle.start_application(MyApp) end @impl true def handle_event({:key, key_event}, _from, state) do case KeyboardShortcuts.handle_key_event(key_event, state) do {:ok, :handled, new_state} -> {:noreply, new_state} {:ok, :not_handled, state} -> handle_other_key_input(key_event, state) {:error, _reason, state} -> {:noreply, state} end end end ``` -------------------------------- ### Integrate Raxol application into supervision tree Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/01_getting_started/quick_start.md Defines an Elixir application module to start the Raxol application as part of a supervision tree, ensuring its lifecycle is managed by the OTP supervisor. ```elixir defmodule MyRaxolApp.Application do use Application def start(_type, _args) do children = [ {Raxol.Core.Runtime.Application, app: MyRaxolApp.Application} ] opts = [strategy: :one_for_one, name: MyRaxolApp.Supervisor] Supervisor.start_link(children, opts) end end ``` -------------------------------- ### Install Elixir Dependencies Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/05_development_and_testing/DevelopmentSetup.md Fetches and installs all necessary Elixir dependencies for the Raxol project using Mix, ensuring all required libraries are available. ```bash mix deps.get ``` -------------------------------- ### Install Raxol on Debian/Ubuntu via APT Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/01_getting_started/install.md After successfully setting up the Raxol APT repository, these commands update your local package lists and then install the `raxol` package using `apt`. This completes the installation process on Debian-based systems. ```bash sudo apt update sudo apt install raxol ``` -------------------------------- ### Define Raxol application with Raxol.View functions Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/01_getting_started/quick_start.md Defines a Raxol application module using `Raxol.View` and component functions for UI definition. It includes `init/1` for initial state, `update/2` for state changes, and `render/1` for UI rendering. ```elixir defmodule MyRaxolApp.Application do use Raxol.Core.Runtime.Application use Raxol.View import Raxol.View.Elements @impl true def init(_context), do: %{count: 0} @impl true def update(:increment, state), do: %{state | count: state.count + 1} def update(_, state), do: state @impl true def render(assigns) do view do box border: :single, padding: 1 do text content: "Count: #{assigns.count}", color: :cyan, attributes: [:bold] button label: "Increment", on_click: :increment end end end end ``` -------------------------------- ### Install Raxol on macOS using Homebrew Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/01_getting_started/install.md This command uses Homebrew, the popular package manager for macOS, to install Raxol from the official tap. It provides a simple and recommended method for macOS users to get Raxol set up. ```bash brew install hydepwns/raxol/raxol ``` -------------------------------- ### Comprehensive Mouse Handler Example in Elixir Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/02_core_concepts/terminal/MouseHandling.md A complete Elixir example demonstrating the initialization, configuration, event handling (click, motion, wheel), and selection management (start, update, get) of the Raxol.Terminal.Mouse component within a module. ```elixir defmodule MyTerminal do alias Raxol.Terminal.Mouse def example do # Create a new mouse handler mouse = Mouse.new() # Configure mouse handling mouse = mouse |> Mouse.enable_tracking() |> Mouse.set_mode(:normal) # Handle mouse events {:ok, action} = Mouse.handle_event(mouse, {:click, 10, 20, :left}) mouse = Mouse.handle_motion(mouse, 15, 25) # Work with selections mouse = mouse |> Mouse.start_selection(10, 10) |> Mouse.update_selection(20, 10) # Get selected text {:ok, selected_text} = Mouse.get_selection(mouse) # Handle scroll events mouse = Mouse.handle_wheel(mouse, 1, :vertical) end end ``` -------------------------------- ### Fetch Elixir Mix Dependencies Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/01_getting_started/install.md After adding Raxol to your `mix.exs` file, run this command in your terminal to download and install the declared dependencies. This step is crucial for making Raxol available in your Elixir project. ```bash mix deps.get ``` -------------------------------- ### Elixir Test Setup Helpers Source: https://github.com/hydepwns/raxol/blob/master/docs/testing/tools.md Defines Elixir functions to configure the test environment, including setting application environment variables, and placeholders for database and plugin setup. ```elixir defmodule Raxol.Test.Utils.SetupHelpers do def setup_test_environment do Application.put_env(:raxol, :test_mode, true) setup_test_database() setup_test_plugins() end def setup_test_database do # Setup test database end def setup_test_plugins do # Setup test plugins end end ``` -------------------------------- ### Elixir Test Setup and Cleanup Helpers Source: https://github.com/hydepwns/raxol/blob/master/docs/testing/test_writing_guide.md This snippet defines a module `Raxol.Test.SetupHelpers` for encapsulating common test environment setup and cleanup logic in Elixir. These functions can be reused across multiple test modules to ensure consistent and isolated test environments. ```Elixir defmodule Raxol.Test.SetupHelpers do def setup_test_environment do # Setup test environment end def cleanup_test_environment do # Cleanup test environment end end ``` -------------------------------- ### Install Raxol on Windows using Winget Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/01_getting_started/install.md This command utilizes the Windows Package Manager (winget) to install Raxol on Windows systems. It offers a simple and efficient command-line method for installing applications on Windows. ```bash winget install raxol ``` -------------------------------- ### Raxol.Core.Config.Manager API Reference Source: https://github.com/hydepwns/raxol/blob/master/docs/CONFIGURATION.md API documentation for the Raxol.Core.Config.Manager module, detailing functions for configuration management including starting the manager, getting, setting, updating, deleting, and reloading configuration values. ```APIDOC Raxol.Core.Config.Manager: start_link/1: Start manager get/2: Get value set/3: Set value update/3: Update value delete/2: Delete value get_all/0: Get all values reload/0: Reload config ``` -------------------------------- ### Run Raxol Examples Source: https://github.com/hydepwns/raxol/blob/master/examples/snippets/README.md Commands to run basic and showcase examples of Raxol applications from the command line using `mix run`. The output is piped to `cat` for display. ```bash mix run examples/basic/counter.exs | cat mix run examples/showcase/component_showcase.exs | cat ``` -------------------------------- ### Elixir Test State Management with Setup Blocks Source: https://github.com/hydepwns/raxol/blob/master/docs/testing/test_writing_guide.md This snippet demonstrates how to manage state within Elixir tests using `setup` blocks. It shows how to initialize state before a test runs and then use that state within the test to verify state updates, ensuring test isolation and reproducibility. ```Elixir setup do state = initial_state() {:ok, %{state: state}} end test "updates state correctly", %{state: state} do new_state = update_state(state) assert state_changed_correctly?(state, new_state) end ``` -------------------------------- ### Run Elixir Documentation Browser Example Source: https://github.com/hydepwns/raxol/blob/master/examples/snippets/advanced/README.md Demonstrates a browser for exploring Elixir module documentation, showcasing scrolling, asynchronous updates, and managing multiple views. ```elixir mix run examples/advanced/documentation_browser.exs | cat ``` -------------------------------- ### Elixir Function Documentation with @doc Source: https://github.com/hydepwns/raxol/blob/master/docs/components/style_guide.md Shows how to document individual functions in Elixir using `@doc`. This example details the purpose of an event handler, its parameters, return values, and includes a practical usage example to guide developers. ```elixir @doc """ Handles component events. ## Parameters * `event` - The event to handle * `state` - Current component state ## Returns * `{new_state, commands}` - Updated state and commands ## Examples handle_event(%{type: :click}, state) """ ``` -------------------------------- ### Define Raxol application with HEEx Sigil Source: https://github.com/hydepwns/raxol/blob/master/examples/guides/01_getting_started/quick_start.md Defines a Raxol application module using the `~H` HEEx sigil for UI definition. It includes `init/1` for initial state, `update/2` for state changes, and `render/1` for UI rendering. ```elixir defmodule MyRaxolApp.Application do use Raxol.Core.Runtime.Application @impl true def init(_context), do: %{count: 0} @impl true def update(:increment, state), do: %{state | count: state.count + 1} def update(_, state), do: state @impl true def render(assigns) do ~H""" Count: <%= @count %>