TermUI.Platform.Windows (TermUI v0.2.0)

View Source

Windows-specific terminal handling stubs.

Full Windows support requires NIFs or ports to call Win32 APIs. This module provides stubs with clear error messages for future implementation.

Requirements for Full Support

  • Windows 10 build 1511+ for VT sequence support
  • SetConsoleMode with ENABLE_VIRTUAL_TERMINAL_PROCESSING
  • SetConsoleMode with ENABLE_VIRTUAL_TERMINAL_INPUT
  • GetConsoleScreenBufferInfo for terminal size
  • Console event handling for resize/focus

Future Implementation

Would require NIF wrapping:

  • kernel32.dll SetConsoleMode
  • kernel32.dll GetConsoleMode
  • kernel32.dll GetConsoleScreenBufferInfo
  • Console event loop for input

Summary

Functions

Returns hints for Windows-specific capability detection.

Disables VT sequence processing.

Enables VT sequence processing for the console.

Returns Windows-specific terminal information.

Checks if the current Windows version meets minimum requirements.

Returns the minimum Windows version required for full support.

Returns terminal size on Windows.

Checks if Windows VT sequence support is available.

Returns the Windows version.

Functions

capability_hints()

@spec capability_hints() :: map()

Returns hints for Windows-specific capability detection.

disable_vt_processing()

@spec disable_vt_processing() :: :ok

Disables VT sequence processing.

Note: Stub implementation.

enable_vt_processing()

@spec enable_vt_processing() :: {:ok, :stub} | {:error, String.t()}

Enables VT sequence processing for the console.

Note: Stub implementation. Would need NIF to call SetConsoleMode.

info()

@spec info() :: map()

Returns Windows-specific terminal information.

Note: Currently returns stub data as full implementation requires NIFs.

meets_minimum_version?()

@spec meets_minimum_version?() :: boolean()

Checks if the current Windows version meets minimum requirements.

minimum_version()

@spec minimum_version() :: {non_neg_integer(), non_neg_integer(), non_neg_integer()}

Returns the minimum Windows version required for full support.

terminal_size()

@spec terminal_size() :: {pos_integer(), pos_integer()}

Returns terminal size on Windows.

Note: Stub using Erlang's :io module. For accurate results, would need GetConsoleScreenBufferInfo via NIF.

vt_support_available?()

@spec vt_support_available?() :: boolean()

Checks if Windows VT sequence support is available.

Note: Currently a stub. Would need to call GetConsoleMode to check.

windows_version()

@spec windows_version() ::
  {non_neg_integer(), non_neg_integer(), non_neg_integer()} | nil

Returns the Windows version.