TermUI.Focus.Indicator (TermUI v0.2.0)

View Source

Focus indicator styles for visual focus feedback.

Provides default and customizable styles for indicating which component has focus.

Usage

# Get default focus style
style = Indicator.default_style()

# Get focus style for component
style = Indicator.get_style(:my_button, opts)

# Apply focus styling to a cell
cell = Indicator.apply_focus_style(cell)

Summary

Functions

Checks if focus indicators should animate.

Returns the default focus indicator style.

Gets focus border color.

Gets the focus indicator style for a component.

Gets a predefined theme by name.

Returns predefined focus indicator themes.

Creates a Style struct from focus indicator style.

Types

border_style()

@type border_style() :: :none | :single | :double | :rounded | :thick

indicator_style()

@type indicator_style() :: %{
  border: border_style() | nil,
  fg: TermUI.Renderer.Style.color() | nil,
  bg: TermUI.Renderer.Style.color() | nil,
  bold: boolean()
}

Functions

animate?()

@spec animate?() :: boolean()

Checks if focus indicators should animate.

Some terminals support blinking or pulsing focus indicators.

Returns

Boolean indicating animation support.

default_style()

@spec default_style() :: indicator_style()

Returns the default focus indicator style.

Default style uses a highlighted border color.

focus_border_color()

@spec focus_border_color() :: atom()

Gets focus border color.

Returns the color to use for focused component borders.

Returns

Color atom (e.g., :cyan, :blue).

get_style(component_id, opts \\ [])

@spec get_style(
  term(),
  keyword()
) :: indicator_style()

Gets the focus indicator style for a component.

Merges default style with component-specific overrides.

Parameters

  • component_id - Component to get style for
  • opts - Options:
    • :styles - Map of component_id => indicator_style

Returns

Focus indicator style map.

get_theme(theme_name)

@spec get_theme(atom()) :: indicator_style()

Gets a predefined theme by name.

Parameters

  • theme_name - Name of the theme

Returns

Indicator style for the theme, or default if not found.

themes()

@spec themes() :: %{required(atom()) => indicator_style()}

Returns predefined focus indicator themes.

Available Themes

  • :default - Cyan border with bold
  • :subtle - Dim border color change
  • :bold - Bright yellow with background
  • :minimal - No border, just cursor

Returns

Map of theme name to indicator style.

to_render_style(indicator)

@spec to_render_style(indicator_style()) :: TermUI.Renderer.Style.t()

Creates a Style struct from focus indicator style.

Parameters

  • indicator - Focus indicator style map

Returns

A Style struct suitable for rendering.