| 73 | } |
| 74 | |
| 75 | KTextEditor::Attribute::Ptr CodeHighlighting::attributeForType(CodeHighlightingType type, |
| 76 | CodeHighlightingContext context, |
| 77 | const QColor& color) const |
| 78 | { |
| 79 | QMutexLocker lock(&m_dataMutex); |
| 80 | KTextEditor::Attribute::Ptr a; |
| 81 | switch (context) { |
| 82 | case CodeHighlightingContext::Definition: |
| 83 | a = m_definitionAttributes[type]; |
| 84 | break; |
| 85 | |
| 86 | case CodeHighlightingContext::Declaration: |
| 87 | a = m_declarationAttributes[type]; |
| 88 | break; |
| 89 | |
| 90 | case CodeHighlightingContext::Reference: |
| 91 | a = m_referenceAttributes[type]; |
| 92 | break; |
| 93 | } |
| 94 | |
| 95 | if (!a || color.isValid()) { |
| 96 | a = KTextEditor::Attribute::Ptr(new KTextEditor::Attribute(*ColorCache::self()->defaultColors()->attribute( |
| 97 | type))); |
| 98 | |
| 99 | if (context == CodeHighlightingContext::Definition || context == CodeHighlightingContext::Declaration) { |
| 100 | if (ICore::self()->languageController()->completionSettings()->boldDeclarations()) { |
| 101 | a->setFontBold(); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | if (color.isValid()) { |
| 106 | a->setForeground(color); |
| 107 | // a->setBackground(QColor(mix(0xffffff-color, backgroundColor(), 255-backgroundTinting))); |
| 108 | } else { |
| 109 | switch (context) { |
| 110 | case CodeHighlightingContext::Definition: |
| 111 | m_definitionAttributes.insert(type, a); |
| 112 | break; |
| 113 | case CodeHighlightingContext::Declaration: |
| 114 | m_declarationAttributes.insert(type, a); |
| 115 | break; |
| 116 | case CodeHighlightingContext::Reference: |
| 117 | m_referenceAttributes.insert(type, a); |
| 118 | break; |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | return a; |
| 124 | } |
| 125 | |
| 126 | ColorMap emptyColorMap() |
| 127 | { |
no test coverage detected