Raxol.System.Platform (Raxol v2.0.1)

View Source

Platform-specific functionality and detection for Raxol.

This module handles detection of the current platform, providing platform-specific information, and managing platform-dependent operations.

Summary

Functions

Detects which graphics protocols are supported by the current terminal.

Returns the current platform as an atom.

Returns the executable name for the current platform.

Returns the file extension for the current platform.

Gathers detailed information about the current platform.

Returns the platform name as a string.

Detects if the feature is supported on the current platform.

Functions

detect_graphics_support()

@spec detect_graphics_support() :: %{
  kitty_graphics: boolean(),
  sixel_graphics: boolean(),
  iterm2_graphics: boolean(),
  terminal_type: atom(),
  capabilities: %{
    max_image_size: non_neg_integer(),
    supports_animation: boolean(),
    supports_transparency: boolean(),
    supports_chunked_transmission: boolean(),
    max_image_width: non_neg_integer(),
    max_image_height: non_neg_integer()
  }
}

Detects which graphics protocols are supported by the current terminal.

Returns

A map with graphics protocol support information:

  • :kitty_graphics - boolean indicating Kitty graphics protocol support
  • :sixel_graphics - boolean indicating Sixel graphics support
  • :iterm2_graphics - boolean indicating iTerm2 inline images support
  • :terminal_type - detected terminal type atom
  • :capabilities - map of additional detected capabilities

Examples

iex> Platform.detect_graphics_support()
%{
  kitty_graphics: true,
  sixel_graphics: false,
  iterm2_graphics: false,
  terminal_type: :kitty,
  capabilities: %{max_image_size: 100000000}
}

get_current_platform()

@spec get_current_platform() :: :linux | :macos | :windows

Returns the current platform as an atom.

Returns

  • :macos - macOS (Darwin)
  • :linux - Linux variants
  • :windows - Windows

Examples

iex> Platform.get_current_platform()
:macos

get_executable_name()

@spec get_executable_name() :: String.t()

Returns the executable name for the current platform.

Returns

  • "raxol.exe" - Windows platforms
  • "raxol" - Unix platforms (macOS, Linux)

Examples

iex> Platform.get_executable_name()
"raxol"

get_platform_extension()

@spec get_platform_extension() :: String.t()

Returns the file extension for the current platform.

Returns

  • "zip" - Windows platforms
  • "tar.gz" - Unix platforms (macOS, Linux)

Examples

iex> Platform.get_platform_extension()
"tar.gz"

get_platform_info()

@spec get_platform_info() :: %{
  :name => :linux | :macos | :windows,
  :version => String.t() | nil,
  :architecture => String.t(),
  :terminal => String.t(),
  optional(:console_type) => String.t(),
  optional(:distribution) => String.t(),
  optional(:apple_silicon) => boolean(),
  optional(:wayland) => boolean(),
  optional(:windows_terminal) => boolean(),
  optional(:wsl) => boolean(),
  optional(:terminal_app) => String.t()
}

Gathers detailed information about the current platform.

Returns

A map containing platform details including:

  • :name - Platform name (e.g., "macOS", "Linux", "Windows")
  • :version - OS version if available
  • :architecture - CPU architecture (e.g., "x86_64", "arm64")
  • :terminal - Current terminal information if available

Examples

iex> Platform.get_platform_info()
%{
  name: "macOS",
  version: "12.6",
  architecture: "arm64",
  terminal: "iTerm.app"
}

get_platform_name()

@spec get_platform_name() :: String.t()

Returns the platform name as a string.

Returns

  • "macos" - macOS (Darwin)
  • "linux" - Linux variants
  • "windows" - Windows

Examples

iex> Platform.get_platform_name()
"macos"

supports_feature?(feature)

@spec supports_feature?(atom()) :: boolean()

Detects if the feature is supported on the current platform.

Parameters

  • feature - Feature name as an atom (e.g., :true_color, :unicode, :mouse, :kitty_graphics)

Returns

  • true - Feature is supported on the current platform
  • false - Feature is not supported or support is uncertain

Examples

iex> Platform.supports_feature?(:true_color)
true

iex> Platform.supports_feature?(:kitty_graphics)
false