defmodule RaxolExamples.SimpleTerminalLive do @moduledoc """ Simple terminal LiveView example. Shows basic terminal rendering with periodic updates. ## Usage Add to your router: live "/terminal", RaxolExamples.SimpleTerminalLive """ use Phoenix.LiveView alias Raxol.Core.{Buffer, Box} alias Raxol.LiveView.TerminalComponent @impl true def mount(_params, _session, socket) do # Create initial buffer buffer = create_initial_buffer() # Schedule periodic updates if connected?(socket) do Process.send_after(self(), :tick, 1000) end {:ok, assign(socket, buffer: buffer, counter: 0, cursor_pos: {2, 10} )} end @impl true def render(assigns) do ~H"""
A minimal Phoenix LiveView terminal component
Counter: <%= @counter %>
Terminal updates automatically every second. Click on the terminal or press keys to interact.