Raxol.Terminal.AdvancedFeatures (Raxol v2.0.1)
View SourceImplements advanced terminal features for modern terminal emulators.
This module provides support for:
- OSC 8 Hyperlinks - Clickable links in terminal output
- Synchronized Output (DEC 2026) - Flicker-free rendering
- Focus Events - Terminal focus/blur detection
- Enhanced Bracketed Paste - Improved paste handling
- Window Manipulation - Advanced terminal control
These features enable rich, interactive terminal applications with modern UX patterns.
Summary
Functions
Enables synchronized output mode for flicker-free rendering.
Creates a clickable hyperlink using OSC 8 escape sequences.
Creates multiple hyperlinks with shared parameters.
Disables bracketed paste mode.
Disables terminal focus events.
Enables enhanced bracketed paste mode.
Enables terminal focus events.
Disables synchronized output mode and flushes buffered content.
Gets current terminal capabilities and features.
Gets the current terminal window size.
Parses focus event sequences.
Parses bracketed paste sequences.
Sets the terminal window title.
Detects if the current terminal supports OSC 8 hyperlinks.
Detects if the terminal supports synchronized output.
Executes a function with synchronized output enabled.
Types
@type hyperlink_id() :: String.t()
@type hyperlink_params() :: %{ optional(:id) => hyperlink_id(), optional(:tooltip) => String.t(), optional(:params) => map() }
@type url() :: String.t()
Functions
@spec begin_synchronized_output() :: :ok
Enables synchronized output mode for flicker-free rendering.
When enabled, terminal output is buffered until explicitly flushed, preventing screen flickering during complex updates.
Examples
AdvancedFeatures.begin_synchronized_output()
# ... perform multiple terminal updates ...
AdvancedFeatures.end_synchronized_output()
@spec create_hyperlink(String.t(), url(), hyperlink_params()) :: String.t()
Creates a clickable hyperlink using OSC 8 escape sequences.
Parameters
text- The text to display as clickableurl- The URL to open when clickedoptions- Additional hyperlink options
Examples
iex> AdvancedFeatures.create_hyperlink("Visit GitHub", "https://github.com")
"\e]8;;https://github.com\e\\Visit GitHub\e]8;;\e\\"
iex> AdvancedFeatures.create_hyperlink("Click me", "https://example.com", %{
...> id: "link1",
...> tooltip: "Opens example.com"
...> })
@spec create_hyperlinks([{String.t(), url()}], hyperlink_params()) :: [String.t()]
Creates multiple hyperlinks with shared parameters.
Examples
links = [
{"GitHub", "https://github.com"},
{"GitLab", "https://gitlab.com"}
]
AdvancedFeatures.create_hyperlinks(links, %{tooltip: "Git repository"})
@spec disable_bracketed_paste() :: :ok
Disables bracketed paste mode.
@spec disable_focus_events() :: :ok
Disables terminal focus events.
@spec enable_bracketed_paste() :: :ok
Enables enhanced bracketed paste mode.
This prevents pasted content from being interpreted as terminal commands and provides better handling of multiline pastes.
@spec enable_focus_events() :: :ok
Enables terminal focus events.
When enabled, the terminal will send escape sequences when it gains or loses focus, allowing applications to respond to focus changes.
@spec end_synchronized_output() :: :ok
Disables synchronized output mode and flushes buffered content.
@spec get_terminal_capabilities() :: %{ hyperlinks: boolean(), synchronized_output: boolean(), focus_events: boolean(), bracketed_paste: boolean(), window_manipulation: boolean(), terminal_type: String.t(), term_variable: String.t() }
Gets current terminal capabilities and features.
@spec get_window_size() :: {:ok, {non_neg_integer(), non_neg_integer()}} | {:error, term()}
Gets the current terminal window size.
Returns {:ok, {width, height}} or {:error, reason}.
Parses focus event sequences.
Returns:
{:focus_in}- Terminal gained focus{:focus_out}- Terminal lost focus{:unknown, data}- Unrecognized sequence
Parses bracketed paste sequences.
Returns:
{:paste_start}- Beginning of pasted content{:paste_end}- End of pasted content{:paste_content, data}- Pasted content
@spec set_window_title(String.t()) :: :ok
Sets the terminal window title.
@spec supports_hyperlinks?() :: boolean()
Detects if the current terminal supports OSC 8 hyperlinks.
@spec supports_synchronized_output?() :: boolean()
Detects if the terminal supports synchronized output.
Executes a function with synchronized output enabled.
Examples
AdvancedFeatures.with_synchronized_output(fn ->
Log.info("Line 1")
Log.info("Line 2")
# These will appear atomically
end)