1 /*
2 SPDX-FileCopyrightText: 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
3 SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org>
4 SPDX-FileCopyrightText: 2009 Milian Wolff <mail@milianw.de>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8
9 #include "configurablecolors.h"
10
11 #include "codehighlighting.h"
12 #include "colorcache.h"
13
14 #include <debug.h>
15
16 #define ifDebug(x)
17
18 namespace KDevelop {
defaultAttribute() const19 KTextEditor::Attribute::Ptr ConfigurableHighlightingColors::defaultAttribute() const
20 {
21 return m_defaultAttribute;
22 }
23
setDefaultAttribute(const KTextEditor::Attribute::Ptr & defaultAttrib)24 void ConfigurableHighlightingColors::setDefaultAttribute(const KTextEditor::Attribute::Ptr& defaultAttrib)
25 {
26 m_defaultAttribute = defaultAttrib;
27 }
28
attribute(int number) const29 KTextEditor::Attribute::Ptr ConfigurableHighlightingColors::attribute(int number) const
30 {
31 return m_attributes[number];
32 }
33
addAttribute(int number,const KTextEditor::Attribute::Ptr & attribute)34 void ConfigurableHighlightingColors::addAttribute(int number, const KTextEditor::Attribute::Ptr& attribute)
35 {
36 m_attributes[number] = attribute;
37 }
38
ConfigurableHighlightingColors()39 ConfigurableHighlightingColors::ConfigurableHighlightingColors()
40 {
41 KTextEditor::Attribute::Ptr a(new KTextEditor::Attribute);
42 setDefaultAttribute(a);
43 }
44
45 #define ADD_COLOR(type, color_) \
46 { \
47 KTextEditor::Attribute::Ptr a(new KTextEditor::Attribute); \
48 a->setForeground(QColor(cache->blendGlobalColor(color_))); \
49 addAttribute(CodeHighlighting::type, a); \
50 ifDebug(qCDebug(LANGUAGE) << # type << "color: " << # color_ << "->" << a->foreground().color().name(); ) \
51 }
52
CodeHighlightingColors(ColorCache * cache)53 CodeHighlightingColors::CodeHighlightingColors(ColorCache* cache) : ConfigurableHighlightingColors()
54 {
55 // 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.
56 ADD_COLOR(ClassType, 0x005912) //Dark green
57 ADD_COLOR(TypeAliasType, 0x35938d)
58 ADD_COLOR(EnumType, 0x6c101e) //Dark red
59 ADD_COLOR(EnumeratorType, 0x862a38) //Greyish red
60 ADD_COLOR(FunctionType, 0x21005A) //Navy blue
61 ADD_COLOR(MemberVariableType, 0x443069) //Dark Burple (blue/purple)
62 ADD_COLOR(LocalClassMemberType, 0xae7d00) //Light orange
63 ADD_COLOR(InheritedClassMemberType, 0x705000) //Dark orange
64 ADD_COLOR(LocalVariableType, 0x0C4D3C)
65 ADD_COLOR(FunctionVariableType, 0x300085) //Less dark navy blue
66 ADD_COLOR(NamespaceVariableType, 0x9F3C5F) //Rose
67 ADD_COLOR(GlobalVariableType, 0x12762B) //Grass green
68 ADD_COLOR(NamespaceType, 0x6B2840) //Dark rose
69 ADD_COLOR(ErrorVariableType, 0x8b0019) //Pure red
70 ADD_COLOR(ForwardDeclarationType, 0x5C5C5C) //Gray
71 ADD_COLOR(MacroType, 0xA41239)
72 ADD_COLOR(MacroFunctionLikeType, 0x008080)
73 }
74 }
75