File: configurablecolors.cpp

package info (click to toggle)
kdevelop 4%3A5.6.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 57,892 kB
  • sloc: cpp: 278,773; javascript: 3,558; python: 3,385; sh: 1,317; ansic: 689; xml: 273; php: 95; makefile: 40; lisp: 13; sed: 12
file content (89 lines) | stat: -rw-r--r-- 3,358 bytes parent folder | download
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
84
85
86
87
88
89
/*
 * This file is part of KDevelop
 *
 * Copyright 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
 * Copyright 2006 Hamish Rodda <rodda@kde.org>
 * Copyright 2009 Milian Wolff <mail@milianw.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#include "configurablecolors.h"

#include "codehighlighting.h"
#include "colorcache.h"

#include <debug.h>

#define ifDebug(x)

namespace KDevelop {
KTextEditor::Attribute::Ptr ConfigurableHighlightingColors::defaultAttribute() const
{
    return m_defaultAttribute;
}

void ConfigurableHighlightingColors::setDefaultAttribute(const KTextEditor::Attribute::Ptr& defaultAttrib)
{
    m_defaultAttribute = defaultAttrib;
}

KTextEditor::Attribute::Ptr ConfigurableHighlightingColors::attribute(int number) const
{
    return m_attributes[number];
}

void ConfigurableHighlightingColors::addAttribute(int number, const KTextEditor::Attribute::Ptr& attribute)
{
    m_attributes[number] = attribute;
}

ConfigurableHighlightingColors::ConfigurableHighlightingColors()
{
    KTextEditor::Attribute::Ptr a(new KTextEditor::Attribute);
    setDefaultAttribute(a);
}

#define ADD_COLOR(type, color_) \
    { \
        KTextEditor::Attribute::Ptr a(new KTextEditor::Attribute); \
        a->setForeground(QColor(cache->blendGlobalColor(color_)));  \
        addAttribute(CodeHighlighting::type, a);  \
        ifDebug(qCDebug(LANGUAGE) << # type << "color: " << # color_ << "->" << a->foreground().color().name(); ) \
    }

CodeHighlightingColors::CodeHighlightingColors(ColorCache* cache) : ConfigurableHighlightingColors()
{
    // 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.
    ADD_COLOR(ClassType, 0x005912) //Dark green
    ADD_COLOR(TypeAliasType, 0x35938d)
    ADD_COLOR(EnumType, 0x6c101e) //Dark red
    ADD_COLOR(EnumeratorType, 0x862a38) //Greyish red
    ADD_COLOR(FunctionType, 0x21005A) //Navy blue
    ADD_COLOR(MemberVariableType, 0x443069) //Dark Burple (blue/purple)
    ADD_COLOR(LocalClassMemberType, 0xae7d00) //Light orange
    ADD_COLOR(InheritedClassMemberType, 0x705000) //Dark orange
    ADD_COLOR(LocalVariableType, 0x0C4D3C)
    ADD_COLOR(FunctionVariableType, 0x300085) //Less dark navy blue
    ADD_COLOR(NamespaceVariableType, 0x9F3C5F) //Rose
    ADD_COLOR(GlobalVariableType, 0x12762B) //Grass green
    ADD_COLOR(NamespaceType, 0x6B2840) //Dark rose
    ADD_COLOR(ErrorVariableType, 0x8b0019) //Pure red
    ADD_COLOR(ForwardDeclarationType, 0x5C5C5C) //Gray
    ADD_COLOR(MacroType, 0xA41239)
    ADD_COLOR(MacroFunctionLikeType, 0x008080)
}
}