1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
/*
SPDX-FileCopyrightText: 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org>
SPDX-FileCopyrightText: 2009 Milian Wolff <mail@milianw.de>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "configurablecolors.h"
#include "colorcache.h"
#include <debug.h>
#include <KTextEditor/View>
#include <KSyntaxHighlighting/Theme>
#define ifDebug(x)
namespace KDevelop {
ConfigurableHighlightingColors::ConfigurableHighlightingColors()
{
reset(nullptr, nullptr);
}
ConfigurableHighlightingColors::~ConfigurableHighlightingColors() = default;
KTextEditor::Attribute::Ptr ConfigurableHighlightingColors::attribute(CodeHighlightingType type) const
{
return m_attributes[type];
}
void ConfigurableHighlightingColors::reset(ColorCache* cache, KTextEditor::View* view)
{
m_attributes.clear();
auto createAttribute = [&](CodeHighlightingType type) {
KTextEditor::Attribute::Ptr a(new KTextEditor::Attribute);
m_attributes[type] = a;
return a;
};
auto addColor = [&](CodeHighlightingType type, QRgb color_) {
auto a = createAttribute(type);
auto color = QColor::fromRgb(color_);
a->setForeground(cache ? cache->blendGlobalColor(color) : color);
ifDebug(qCDebug(LANGUAGE) << #type << "color: " << #color_ << "->" << a->foreground().color().name());
};
// TODO: The set of colors doesn't work very well. Many colors simply too dark (even on the maximum "Global colorization intensity" they hardly distinguishable from grey) and look alike.
addColor(CodeHighlightingType::Class, 0x005912); // Dark green
addColor(CodeHighlightingType::TypeAlias, 0x35938d);
addColor(CodeHighlightingType::Enum, 0x6c101e); // Dark red
addColor(CodeHighlightingType::Enumerator, 0x862a38); // Greyish red
addColor(CodeHighlightingType::Function, 0x21005A); // Navy blue
addColor(CodeHighlightingType::MemberVariable, 0x443069); // Dark Burple (blue/purple)
addColor(CodeHighlightingType::LocalClassMember, 0xae7d00); // Light orange
addColor(CodeHighlightingType::LocalMemberFunction, 0xae7d00);
addColor(CodeHighlightingType::InheritedClassMember, 0x705000); // Dark orange
addColor(CodeHighlightingType::InheritedMemberFunction, 0x705000);
addColor(CodeHighlightingType::LocalVariable, 0x0C4D3C);
addColor(CodeHighlightingType::FunctionVariable, 0x300085); // Less dark navy blue
addColor(CodeHighlightingType::NamespaceVariable, 0x9F3C5F); // Rose
addColor(CodeHighlightingType::GlobalVariable, 0x12762B); // Grass green
addColor(CodeHighlightingType::Namespace, 0x6B2840); // Dark rose
addColor(CodeHighlightingType::ForwardDeclaration, 0x5C5C5C); // Gray
addColor(CodeHighlightingType::Macro, 0xA41239);
addColor(CodeHighlightingType::MacroFunctionLike, 0x008080);
{
auto highlightUses = createAttribute(CodeHighlightingType::HighlightUses);
highlightUses->setDefaultStyle(KTextEditor::dsNormal);
highlightUses->setForeground(highlightUses->selectedForeground());
highlightUses->setBackground(highlightUses->selectedBackground());
highlightUses->setBackgroundFillWhitespace(true);
if (view) {
const auto searchHighlight = view->theme().editorColor(KSyntaxHighlighting::Theme::SearchHighlight);
highlightUses->setBackground(QColor::fromRgb(searchHighlight));
}
}
{
auto error = createAttribute(CodeHighlightingType::Error);
error->setDefaultStyle(KTextEditor::dsError);
}
}
}
|