TermUI.Focus.Indicator (TermUI v0.2.0)
View SourceFocus 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
@type border_style() :: :none | :single | :double | :rounded | :thick
@type indicator_style() :: %{ border: border_style() | nil, fg: TermUI.Renderer.Style.color() | nil, bg: TermUI.Renderer.Style.color() | nil, bold: boolean() }
Functions
@spec animate?() :: boolean()
Checks if focus indicators should animate.
Some terminals support blinking or pulsing focus indicators.
Returns
Boolean indicating animation support.
@spec default_style() :: indicator_style()
Returns the default focus indicator style.
Default style uses a highlighted 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).
@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 foropts- Options::styles- Map of component_id => indicator_style
Returns
Focus indicator style map.
@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.
@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.
@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.