Skip to main content

Module terminal_bg

Module terminal_bg 

Source
Expand description

OSC 11 terminal-background-colour detection.

Queries the active terminal for its background colour and decides light vs. dark. Used at startup when Config::ui.theme == Auto to pick the right colour palette. On terminals that don’t respond (macOS Terminal.app, Windows conhost), returns None and the caller falls back to the legacy dark palette.

Must be called with raw mode active — otherwise the response is line-buffered by the kernel and never reaches us within the timeout.

Functions§

detect_light
Query the terminal for its background colour and decide light vs. dark. Returns Some(true) for light, Some(false) for dark, None when the terminal didn’t respond within timeout.