Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: process css themes background-color directive #687

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading