class ThemeManager
extends Object
Manages theme state (light/dark/system) for GroovyConsole.
| Modifiers | Name | Description |
|---|---|---|
static enum |
ThemeManager.ThemeMode |
Available theme selection modes for the console. |
| Type | Name and description |
|---|---|
String |
customDarkPath |
String |
customLightPath |
| Constructor and description |
|---|
ThemeManager() |
| 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#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. |
Registers a listener notified after the console theme changes.
Applies and persists the supplied theme mode.
Cycles through light, dark, and system theme modes.
Returns the configured theme mode, defaulting to ThemeMode#SYSTEM#SYSTEM.
Returns the configured custom dark-theme file path, if any.
Returns the configured custom light-theme file path, if any.
Returns the active theme's editor background colour.
Foreground color for menu-item icons — OS-tinted on the mac screen menu bar, app-tinted otherwise.
Returns the active theme's output background colour.
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.
Builds the Swing style map for the active theme and font family.
Returns a user-facing label for the current theme mode.
Returns whether the active console theme currently resolves to dark.
True iff menu-item icons will paint against a dark background.
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.
Returns whether the operating system appearance currently resolves to dark.
True iff the theme currently in use is loaded from a user-supplied file.
Notifies all registered listeners that the theme has changed.
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.
Re-probe OS appearance, update the cache, and report whether it changed.
Clear the parsed-theme cache so next lookup re-reads from disk/classpath.
Removes a previously registered theme-change listener.
Persists the custom dark-theme file path or clears it when blank.
Persists the custom light-theme file path or clears it when blank.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.