Package: groovy.console.ui

## [Groovy] Class ThemeManager

- groovy.console.ui.ThemeManager

-     class ThemeManager
      extends Object

  Manages theme state (light/dark/system) for GroovyConsole.

  Since:
    6.0.0

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static enum` | `ThemeManager.ThemeMode` | Available theme selection modes for the console.

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `String` | `customDarkPath`
    `String` | `customLightPath`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ThemeManager()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `static void` | `addThemeChangeListener(Runnable listener)` Registers a listener notified after the console theme changes.
    `` | `static void` | `applyTheme(ThemeManager.ThemeMode mode)` Applies and persists the supplied theme mode.
    `` | `static ThemeManager.ThemeMode` | `cycleMode()` Cycles through light, dark, and system theme modes.
    `` | `static ThemeManager.ThemeMode` | `getCurrentMode()` Returns the configured theme mode, defaulting to ThemeMode.SYSTEM.
    `` | `static String` | `getCustomDarkPath()` Returns the configured custom dark-theme file path, if any.
    `` | `static String` | `getCustomLightPath()` Returns the configured custom light-theme file path, if any.
    `` | `static Color` | `getInputBackground()` Returns the active theme's editor background colour.
    `` | `static Color` | `getMenuIconForeground()` Foreground color for menu-item icons — OS-tinted on the mac screen menu bar, app-tinted otherwise.
    `` | `static Color` | `getOutputBackground()` Returns the active theme's output background colour.
    `` | `static Map` | `getStyleAttrs(String key)` Returns the attributes for a single theme style key as a plain map (foreground/background Colors plus bold/italic/underline Booleans).
    `` | `static Map` | `getStyles(String fontFamily)` Builds the Swing style map for the active theme and font family.
    `` | `static String` | `getThemeLabel()` Returns a user-facing label for the current theme mode.
    `` | `static boolean` | `isDark()` Returns whether the active console theme currently resolves to dark.
    `` | `static boolean` | `isMenuDark()` True iff menu-item icons will paint against a dark background.
    `` | `static boolean` | `isMenuDrawnByOS()` On macOS with `apple.laf.useScreenMenuBar=true` the menu bar is drawn by the OS rather than FlatLaf, so menu-item icons need to track the OS appearance instead of the app theme to stay legible.
    `` | `static boolean` | `isSystemDarkMode()` Returns whether the operating system appearance currently resolves to dark.
    `` | `static boolean` | `isUsingCustomTheme()` True iff the theme currently in use is loaded from a user-supplied file.
    `` | `static void` | `notifyThemeChanged()` Notifies all registered listeners that the theme has changed.
    `` | `static Map` | `parseTheme(Reader reader)` Parses a .theme file (java.util.Properties format with our value sub-syntax) into a structured theme: { inputBackground, outputBackground, styles: name?attrs }.
    `` | `static boolean` | `refreshSystemDarkMode()` Re-probe OS appearance, update the cache, and report whether it changed.
    `` | `static void` | `reloadThemes()` Clear the parsed-theme cache so next lookup re-reads from disk/classpath.
    `` | `static void` | `removeThemeChangeListener(Runnable listener)` Removes a previously registered theme-change listener.
    `` | `static void` | `setCustomDarkPath(String path)` Persists the custom dark-theme file path or clears it when blank.
    `` | `static void` | `setCustomLightPath(String path)` Persists the custom light-theme file path or clears it when blank.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Property Detail

    - #### String customDarkPath

    - #### String customLightPath

  - ### Constructor Detail

    - #### ThemeManager()

  - ### Method Detail

    - #### static void addThemeChangeListener(Runnable listener)

      Registers a listener notified after the console theme changes.

    - #### static void applyTheme(ThemeManager.ThemeMode mode)

      Applies and persists the supplied theme mode.

    - #### static ThemeManager.ThemeMode cycleMode()

      Cycles through light, dark, and system theme modes.

    - #### static ThemeManager.ThemeMode getCurrentMode()

      Returns the configured theme mode, defaulting to ThemeMode.SYSTEM.

    - #### static String getCustomDarkPath()

      Returns the configured custom dark-theme file path, if any.

    - #### static String getCustomLightPath()

      Returns the configured custom light-theme file path, if any.

    - #### static Color getInputBackground()

      Returns the active theme's editor background colour.

    - #### static Color getMenuIconForeground()

      Foreground color for menu-item icons — OS-tinted on the mac screen menu bar, app-tinted otherwise.

    - #### static Color getOutputBackground()

      Returns the active theme's output background colour.

    - #### static Map getStyleAttrs(String key)

      Returns the attributes for a single theme style key as a plain map (foreground/background Colors plus bold/italic/underline Booleans). Consumed by SmartDocumentFilter so ANTLR-token-driven highlighting picks up the same theme values as the regex-based GroovyFilter styles. Returns an empty map if the theme doesn't define the key.

    - #### static Map getStyles(String fontFamily)

      Builds the Swing style map for the active theme and font family.

    - #### static String getThemeLabel()

      Returns a user-facing label for the current theme mode.

    - #### static boolean isDark()

      Returns whether the active console theme currently resolves to dark.

    - #### static boolean isMenuDark()

      True iff menu-item icons will paint against a dark background.

    - #### static boolean isMenuDrawnByOS()

      On macOS with `apple.laf.useScreenMenuBar=true` the menu bar is drawn by the OS rather than FlatLaf, so menu-item icons need to track the OS appearance instead of the app theme to stay legible.

    - #### static boolean isSystemDarkMode()

      Returns whether the operating system appearance currently resolves to dark.

    - #### static boolean isUsingCustomTheme()

      True iff the theme currently in use is loaded from a user-supplied file.

    - #### static void notifyThemeChanged()

      Notifies all registered listeners that the theme has changed.

    - #### static Map parseTheme(Reader reader)

      Parses a .theme file (java.util.Properties format with our value sub-syntax) into a structured theme: { inputBackground, outputBackground, styles: name?attrs }. Each attrs map may contain foreground/background Colors and bold/italic/underline flags. Unknown keys are silently ignored so theme files stay forward-compatible.

    - #### static boolean refreshSystemDarkMode()

      Re-probe OS appearance, update the cache, and report whether it changed.

    - #### static void reloadThemes()

      Clear the parsed-theme cache so next lookup re-reads from disk/classpath.

    - #### static void removeThemeChangeListener(Runnable listener)

      Removes a previously registered theme-change listener.

    - #### static void setCustomDarkPath(String path)

      Persists the custom dark-theme file path or clears it when blank.

    - #### static void setCustomLightPath(String path)

      Persists the custom light-theme file path or clears it when blank.