Skip to main content

get_effective_theme_variant

Function get_effective_theme_variant 

Source
pub fn get_effective_theme_variant(variant: ThemeVariant) -> ThemeVariant
Expand description

Function to resolve the effective theme variant. Get the effective color scheme based on variant and terminal detection.

Resolves a ThemeVariant to its effective value. For Dark and Light variants, returns them unchanged. For Auto, attempts to detect the terminal’s color scheme.

§Arguments

§Returns

The effective ThemeVariant after resolution. Note that Auto will be resolved to either Dark or Light.

§Features

When the termenv feature is enabled, auto-detection will use the terminal environment to determine the color scheme. Without this feature, Auto defaults to Dark.

§Example

use ratatui_toolkit::markdown_widget::extensions::theme::{ThemeVariant, get_effective_theme_variant};

// Explicit variant is returned unchanged
assert_eq!(
    get_effective_theme_variant(ThemeVariant::Dark),
    ThemeVariant::Dark
);

// Auto resolves to Dark or Light based on terminal
let effective = get_effective_theme_variant(ThemeVariant::Auto);
assert!(matches!(effective, ThemeVariant::Dark | ThemeVariant::Light));