TermUI.Platform (TermUI v0.2.0)
View SourcePlatform detection and abstraction for cross-platform terminal support.
Provides unified API for platform-specific operations, automatically selecting the appropriate implementation for the current OS.
Summary
Functions
Returns platform-specific information as a map.
Returns true if running on Linux (native, not WSL).
Returns true if running on macOS.
Returns the OS version as a tuple.
Returns the current platform identifier.
Returns true if the platform supports the given feature.
Returns the terminal size as {rows, cols}.
Returns true if running on Unix (Linux, macOS, FreeBSD).
Returns true if running on Windows.
Returns true if running in Windows Subsystem for Linux (WSL).
Types
@type platform() :: :linux | :macos | :windows | :freebsd | :unknown
@type version() :: {non_neg_integer(), non_neg_integer(), non_neg_integer()} | nil
Functions
@spec info() :: map()
Returns platform-specific information as a map.
@spec linux?() :: boolean()
Returns true if running on Linux (native, not WSL).
@spec macos?() :: boolean()
Returns true if running on macOS.
@spec os_version() :: version()
Returns the OS version as a tuple.
Examples
iex> TermUI.Platform.os_version()
{5, 15, 0}
iex> TermUI.Platform.os_version()
{14, 0, 0}
@spec platform() :: platform()
Returns the current platform identifier.
Examples
iex> TermUI.Platform.platform()
:linux
iex> TermUI.Platform.platform()
:macos
Returns true if the platform supports the given feature.
Features
:signals- POSIX signal handling:pty- Pseudo-terminal support:terminfo- Terminfo database:vt_sequences- VT escape sequences
@spec terminal_size() :: {pos_integer(), pos_integer()}
Returns the terminal size as {rows, cols}.
Falls back to default {24, 80} if unable to detect.
@spec unix?() :: boolean()
Returns true if running on Unix (Linux, macOS, FreeBSD).
@spec windows?() :: boolean()
Returns true if running on Windows.
@spec wsl?() :: boolean()
Returns true if running in Windows Subsystem for Linux (WSL).