Commit 48ca7e8f authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Use selected fg color from theme

parent 864c6977
......@@ -34,11 +34,12 @@ void SemanticHighlighting::themeChange(KTextEditor::Editor *e)
const auto theme = e->theme();
QColor f = QColor::fromRgba(theme.textColor(Style::Function));
QColor fs = QColor::fromRgba(theme.selectedTextColor(Style::Function));
if (!fixedAttrs[0]) {
fixedAttrs[0] = new KTextEditor::Attribute();
}
fixedAttrs[0]->setForeground(f);
fixedAttrs[0]->setSelectedForeground(f);
fixedAttrs[0]->setSelectedForeground(fs);
fixedAttrs[0]->setFontBold(theme.isBold(Style::Function));
fixedAttrs[0]->setFontItalic(theme.isItalic(Style::Function));
......@@ -51,6 +52,7 @@ void SemanticHighlighting::themeChange(KTextEditor::Editor *e)
// coded values here for some of the themes we have
// and for others we just read the "Variable" text-style.
QColor v;
QColor vs;
bool italic = false;
static const char MonokaiVP[] = "#fd971f";
static const char DraculaVP[] = "#ffb86c";
......@@ -58,58 +60,67 @@ void SemanticHighlighting::themeChange(KTextEditor::Editor *e)
static const char AyuMirageVP[] = "#d4bfff";
if (theme.name() == QStringLiteral("Monokai")) {
v = QColor(MonokaiVP);
vs = v;
italic = true;
} else if (theme.name() == QStringLiteral("Dracula")) {
v = QColor(DraculaVP);
vs = v;
italic = true;
} else if (theme.name() == QStringLiteral("ayu Light") || theme.name() == QStringLiteral("ayu Dark")) {
v = QColor(AyuDarkLightVP);
vs = v;
} else if (theme.name() == QStringLiteral("ayu Mirage")) {
v = QColor(AyuMirageVP);
vs = v;
} else {
v = QColor::fromRgba(theme.textColor(Style::Variable));
italic = theme.isItalic(Style::Variable);
vs = QColor::fromRgba(theme.selectedTextColor(Style::Variable));
}
fixedAttrs[1]->setForeground(v);
fixedAttrs[1]->setSelectedForeground(v);
fixedAttrs[1]->setSelectedForeground(vs);
fixedAttrs[1]->setFontBold(theme.isBold(Style::Variable));
fixedAttrs[1]->setFontItalic(italic);
}
QColor c = QColor::fromRgba(theme.textColor(Style::Constant));
QColor cs = QColor::fromRgba(theme.selectedTextColor(Style::Constant));
if (!fixedAttrs[2]) {
fixedAttrs[2] = new KTextEditor::Attribute();
}
fixedAttrs[2]->setForeground(c);
fixedAttrs[2]->setSelectedForeground(c);
fixedAttrs[2]->setSelectedForeground(cs);
fixedAttrs[2]->setFontBold(theme.isBold(Style::Constant));
fixedAttrs[2]->setFontItalic(theme.isItalic(Style::Constant));
QColor k = QColor::fromRgba(theme.textColor(Style::Keyword));
QColor ks = QColor::fromRgba(theme.selectedTextColor(Style::Keyword));
if (!fixedAttrs[3]) {
fixedAttrs[3] = new KTextEditor::Attribute();
}
fixedAttrs[3]->setForeground(k);
fixedAttrs[3]->setSelectedForeground(k);
fixedAttrs[3]->setSelectedForeground(ks);
fixedAttrs[3]->setFontBold(theme.isBold(Style::Keyword));
fixedAttrs[3]->setFontItalic(theme.isItalic(Style::Keyword));
QColor cm = QColor::fromRgba(theme.textColor(Style::Comment));
QColor cms = QColor::fromRgba(theme.selectedTextColor(Style::Comment));
if (!fixedAttrs[4]) {
fixedAttrs[4] = new KTextEditor::Attribute();
}
fixedAttrs[4]->setForeground(cm);
fixedAttrs[4]->setSelectedForeground(cm);
fixedAttrs[4]->setSelectedForeground(cms);
fixedAttrs[4]->setFontBold(theme.isBold(Style::Comment));
fixedAttrs[4]->setFontItalic(theme.isItalic(Style::Comment));
QColor p = QColor::fromRgba(theme.textColor(Style::Preprocessor));
QColor ps = QColor::fromRgba(theme.selectedTextColor(Style::Preprocessor));
if (!fixedAttrs[5]) {
fixedAttrs[5] = new KTextEditor::Attribute();
}
fixedAttrs[5]->setForeground(p);
fixedAttrs[5]->setSelectedForeground(p);
fixedAttrs[5]->setSelectedForeground(ps);
fixedAttrs[5]->setFontBold(theme.isBold(Style::Preprocessor));
fixedAttrs[5]->setFontItalic(theme.isItalic(Style::Preprocessor));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment