Skip to content

Commit

Permalink
feat: process css themes background-color directive
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Feb 8, 2024
1 parent 86ccde3 commit defa0a3
Showing 1 changed file with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,20 @@ public List<IStyle> 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);
Expand Down

0 comments on commit defa0a3

Please sign in to comment.