From defa0a30db505fcff75dcfbc08dca9886dc2eaf2 Mon Sep 17 00:00:00 2001 From: sebthom Date: Wed, 7 Feb 2024 23:58:41 +0100 Subject: [PATCH] feat: process css themes background-color directive --- .../tm4e/ui/themes/css/CSSTokenProvider.java | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/themes/css/CSSTokenProvider.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/themes/css/CSSTokenProvider.java index a8bf939e9..1be36ac27 100644 --- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/themes/css/CSSTokenProvider.java +++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/themes/css/CSSTokenProvider.java @@ -53,27 +53,20 @@ public List getStyles() { public CSSTokenProvider(final InputStream in) { CSSParser parser = null; + final var colors = ColorManager.getInstance(); try { parser = new CSSParser(in); for (final IStyle style : parser.getStyles()) { - final RGB color = style.getColor(); - if (color != null) { - int s = SWT.NORMAL; - if (style.isBold()) { - s = s | SWT.BOLD; - } - if (style.isItalic()) { - s = s | SWT.ITALIC; - } - if (style.isUnderline()) { - s = s | TextAttribute.UNDERLINE; - } - if (style.isStrikeThrough()) { - s = s | TextAttribute.STRIKETHROUGH; - } - tokenMaps.put(style, - new Token(new TextAttribute(ColorManager.getInstance().getColor(color), null, s))); - } + final @Nullable RGB styleFGColor = style.getColor(); + final @Nullable RGB styleBGColor = style.getBackgroundColor(); + tokenMaps.put(style, new Token(new TextAttribute( + styleFGColor == null ? null : colors.getColor(styleFGColor), + styleBGColor == null ? null : colors.getColor(styleBGColor), + SWT.NORMAL + | (style.isBold() ? SWT.BOLD : 0) + | (style.isItalic() ? SWT.ITALIC : 0) + | (style.isUnderline() ? TextAttribute.UNDERLINE : 0) + | (style.isStrikeThrough() ? TextAttribute.STRIKETHROUGH : 0)))); } } catch (final Exception ex) { TMUIPlugin.logError(ex);