Skip to main content

Module api

Module api 

Expand description

Windows API abstraction layer for console and system operations.

This module provides a trait-based abstraction over Windows APIs to enable mocking in tests and centralize Windows-specific functionality.

Structs§

ConsolePaletteSnapshot
The console’s captured 16-entry palette plus its default text attribute (kept so the tint can locate the default text/background entries in color_table).
DefaultWindowsApi
Default implementation of WindowsApi that calls actual Windows APIs.

Constants§

KEY_EVENT
u16 representation of a KEY_EVENT.

Traits§

WindowsApi
Trait for Windows API operations to enable mocking in tests.

Functions§

arrange_console
Changes size and position of the current console window using the provided API.
build_command_line
Build command line string for Windows process creation
build_command_line_wide
Build a UTF-16, null-terminated command line directly from OsStr inputs.
clear_screen
Empties the console screen output buffer of the current console window using the provided API.
get_console_input_buffer
Returns a [HANDLE] to the [STD_INPUT_HANDLE] of the current process.
get_console_output_buffer
Returns a [HANDLE] to the [STD_OUTPUT_HANDLE] of the current process.
get_console_title
Returns the title of the current console window using the provided API.
is_windows_10
Detects if the current windows installation is Windows 10 or not using the provided API.
read_console_input
Returns a single [INPUT_RECORD] read from the current process stdinput using the provided API.
read_keyboard_input
Returns a single [INPUT_RECORD_0] where EventType == KEY_EVENT using the provided API.
set_console_border_color
Sets the border color of the current console window using the provided APIs.
set_console_color
Sets the back- and foreground color of the current console window using the provided API.
set_console_palette
Installs palette as the console’s 16-entry color table, leaving the rest of the buffer info as it currently is, and forces a repaint.
snapshot_console_palette
Snapshots the console’s 16-entry RGB palette and default text attribute for a later restore and for locating the default foreground/background entries the tint recolors.
tinted_palette
Derive the tinted palette for a state color: the captured palette with the console’s default-foreground and default-background entries remapped to the colors the legacy tint attribute’s foreground and background nibbles select. Recoloring palette entries (never the per-cell attributes) leaves VT/24-bit cells - which store their color outside the palette - untouched, so the full configured color applies without hiding the child’s own colored output.
utf16_buffer_to_string
Converts a UTF-16 buffer to a Rust String, filtering out null characters.