Packages
Multi-surface application runtime for Elixir. One TEA module renders to terminal, browser (LiveView), SSH, and MCP (agents). 30+ widgets, flexbox + CSS grid, AI agent runtime, distributed swarm with CRDTs, time-travel debugging, session recording, sandboxed REPL, and agentic commerce.
Current section
Files
Jump to
Current section
Files
lib/raxol/terminal/tooltip.ex
defmodule Raxol.Terminal.Tooltip do
@moduledoc """
Tooltip display functionality for terminal UI.
This module provides tooltip rendering capabilities for terminal applications,
allowing contextual help text to appear on hover or focus.
"""
use Raxol.Core.Behaviours.BaseManager
alias Raxol.Core.Runtime.Log
@doc """
Shows a tooltip with the given text at the current cursor position.
## Parameters
- `text` - The text to display in the tooltip
## Examples
Raxol.Terminal.Tooltip.show("Click to submit")
"""
@spec show(String.t()) :: :ok
def show(text) when is_binary(text) do
GenServer.cast(__MODULE__, {:show, text})
end
@doc """
Hides the currently displayed tooltip.
## Examples
Raxol.Terminal.Tooltip.hide()
"""
@spec hide() :: :ok
def hide do
GenServer.cast(__MODULE__, :hide)
end
@doc """
Starts the tooltip server.
"""
# BaseManager provides start_link/1 with proper option handling
# BaseManager callbacks
@impl Raxol.Core.Behaviours.BaseManager
def init_manager(_opts) do
{:ok, %{visible: false, text: "", position: {0, 0}}}
end
@impl Raxol.Core.Behaviours.BaseManager
def handle_manager_cast({:show, text}, state) do
# In a real implementation, this would render the tooltip
Log.debug("Showing tooltip: #{text}")
{:noreply, %{state | visible: true, text: text}}
end
def handle_manager_cast(:hide, state) do
Log.debug("Hiding tooltip")
{:noreply, %{state | visible: false, text: ""}}
end
@impl Raxol.Core.Behaviours.BaseManager
def handle_manager_call(:get_state, _from, state) do
{:reply, state, state}
end
end