Raxol.Effects.HoverHighlight (Raxol v2.6.0)

View Source

Visual hover feedback for terminal widgets.

Highlights the widget region under the mouse cursor with a border glow, fill tint, or underline. Integrates with the MCP FocusLens to provide visual feedback when mouse tracking is active.

Example

highlight = HoverHighlight.new()
highlight = HoverHighlight.set_target(highlight, %{x: 5, y: 2, width: 20, height: 3})
buffer = HoverHighlight.apply(highlight, buffer)

Configuration

config = %{
  color: :cyan,
  style: :border,      # :border | :fill | :underline
  intensity: 0.6,       # 0.0-1.0 peak intensity
  fade_ms: 200,         # ms to fade after mouse leaves
  enabled: true
}

Summary

Functions

Apply the hover highlight to a buffer.

Clear the highlight immediately (no fade).

Create a new hover highlight effect.

Enable or disable the effect.

Set the target widget bounds. Pass nil to start fade-out.

Update configuration.

Whether anything would render right now.

Types

bounds()

@type bounds() :: %{
  x: non_neg_integer(),
  y: non_neg_integer(),
  width: non_neg_integer(),
  height: non_neg_integer()
}

config()

@type config() :: %{
  optional(:color) => atom(),
  optional(:style) => :border | :fill | :underline,
  optional(:intensity) => float(),
  optional(:fade_ms) => non_neg_integer(),
  optional(:enabled) => boolean()
}

position()

@type position() :: {integer(), integer()}

t()

@type t() :: %Raxol.Effects.HoverHighlight{
  active: boolean(),
  config: config(),
  fade_start: integer() | nil,
  target: bounds() | nil,
  widget_id: String.t() | nil
}

Functions

apply(highlight, buffer)

@spec apply(t(), Raxol.Core.Buffer.t()) :: Raxol.Core.Buffer.t()

Apply the hover highlight to a buffer.

clear(highlight)

@spec clear(t()) :: t()

Clear the highlight immediately (no fade).

new(config \\ %{})

@spec new(config()) :: t()

Create a new hover highlight effect.

set_enabled(highlight, enabled)

@spec set_enabled(t(), boolean()) :: t()

Enable or disable the effect.

set_target(highlight, bounds, widget_id)

@spec set_target(t(), bounds() | nil, String.t() | nil) :: t()

Set the target widget bounds. Pass nil to start fade-out.

update_config(highlight, new_config)

@spec update_config(t(), config()) :: t()

Update configuration.

visible?(map)

@spec visible?(t()) :: boolean()

Whether anything would render right now.