Commit 41cb12e4 authored by Milian Wolff's avatar Milian Wolff
Browse files

Revert "Introduce HighlightUses for ConfigurableColors"

This reverts commit 6c2ef5e8.
parent e1ec8b74
Pipeline #201498 canceled with stage
in 21 seconds
......@@ -52,7 +52,6 @@ enum class CodeHighlightingType {
MemberVariable,
NamespaceVariable,
GlobalVariable,
HighlightUses,
// Most of these are currently not used:
Argument,
......
......@@ -152,12 +152,6 @@ void ColorCache::updateColorsFromView(KTextEditor::View* view)
return;
}
auto iface = qobject_cast<KTextEditor::ConfigInterface*>(view);
Q_ASSERT(iface);
const auto highlightUsesColor = iface->configValue(QStringLiteral("search-highlight-color")).value<QColor>();
m_defaultColors->attribute(CodeHighlightingType::HighlightUses)->setBackground(highlightUsesColor);
QColor foreground(QColor::Invalid);
QColor background(QColor::Invalid);
......@@ -167,9 +161,14 @@ void ColorCache::updateColorsFromView(KTextEditor::View* view)
background = style->background().color();
}
// FIXME: this is in kateview
// qCDebug(LANGUAGE) << "got foreground:" << foreground.name() << "old is:" << m_foregroundColor.name();
//NOTE: this slot is defined in KatePart > 4.4, see ApiDocs of the ConfigInterface
// the signal is not defined in ConfigInterface, but according to the docs it should be
// can't use new signal slot syntax here, since ConfigInterface is not a QObject
if (KTextEditor::View* view = m_view.data()) {
Q_ASSERT(qobject_cast<KTextEditor::ConfigInterface*>(view));
// we only listen to a single view, i.e. the active one
#if KTEXTEDITOR_VERSION >= QT_VERSION_CHECK(5, 79, 0)
disconnect(view, &KTextEditor::View::configChanged, this, &ColorCache::slotViewSettingsChanged);
......@@ -177,6 +176,7 @@ void ColorCache::updateColorsFromView(KTextEditor::View* view)
disconnect(view, SIGNAL(configChanged()), this, SLOT(slotViewSettingsChanged()));
#endif
}
Q_ASSERT(qobject_cast<KTextEditor::ConfigInterface*>(view));
#if KTEXTEDITOR_VERSION >= QT_VERSION_CHECK(5, 79, 0)
connect(view, &KTextEditor::View::configChanged, this, &ColorCache::slotViewSettingsChanged);
#else
......
......@@ -35,8 +35,7 @@ void ConfigurableHighlightingColors::reset(ColorCache* cache)
KTextEditor::Attribute::Ptr a(new KTextEditor::Attribute);
a->setForeground(cache ? cache->blendGlobalColor(color) : color);
m_attributes[type] = a;
ifDebug(qCDebug(LANGUAGE) << #type << "color: " << #color_ << "->" << a->foreground().color().name());
return a;
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
......@@ -58,12 +57,5 @@ void ConfigurableHighlightingColors::reset(ColorCache* cache)
addColor(CodeHighlightingType::ForwardDeclaration, 0x5C5C5C); // Gray
addColor(CodeHighlightingType::Macro, 0xA41239);
addColor(CodeHighlightingType::MacroFunctionLike, 0x008080);
{
auto highlightUses = addColor(CodeHighlightingType::HighlightUses, 0xffffff);
highlightUses->setDefaultStyle(KTextEditor::dsNormal);
highlightUses->setForeground(highlightUses->selectedForeground());
highlightUses->setBackgroundFillWhitespace(true);
}
}
}
......@@ -42,8 +42,6 @@
#include <language/interfaces/iquickopen.h>
#include <language/highlighting/colorcache.h>
#include <language/highlighting/configurablecolors.h>
#include <language/highlighting/codehighlighting.h>
#include <language/duchain/duchain.h>
#include <language/duchain/ducontext.h>
......@@ -714,10 +712,17 @@ void ContextBrowserPlugin::clearMouseHover()
m_mouseHoverDocument.clear();
}
Attribute::Ptr ContextBrowserPlugin::highlightedUseAttribute() const
Attribute::Ptr ContextBrowserPlugin::highlightedUseAttribute(KTextEditor::View* view) const
{
if (!m_highlightAttribute) {
m_highlightAttribute = ColorCache::self()->defaultColors()->attribute(CodeHighlightingType::HighlightUses);
m_highlightAttribute = Attribute::Ptr(new Attribute());
m_highlightAttribute->setDefaultStyle(KTextEditor::dsNormal);
m_highlightAttribute->setForeground(m_highlightAttribute->selectedForeground());
m_highlightAttribute->setBackgroundFillWhitespace(true);
auto iface = qobject_cast<KTextEditor::ConfigInterface*>(view);
auto background = iface->configValue(QStringLiteral("search-highlight-color")).value<QColor>();
m_highlightAttribute->setBackground(background);
}
return m_highlightAttribute;
}
......@@ -727,9 +732,9 @@ void ContextBrowserPlugin::colorSetupChanged()
m_highlightAttribute = Attribute::Ptr();
}
Attribute::Ptr ContextBrowserPlugin::highlightedSpecialObjectAttribute() const
Attribute::Ptr ContextBrowserPlugin::highlightedSpecialObjectAttribute(KTextEditor::View* view) const
{
return highlightedUseAttribute();
return highlightedUseAttribute(view);
}
void ContextBrowserPlugin::addHighlight(View* view, KDevelop::Declaration* decl)
......@@ -745,7 +750,7 @@ void ContextBrowserPlugin::addHighlight(View* view, KDevelop::Declaration* decl)
// Highlight the declaration
highlights.highlights << decl->createRangeMoving();
highlights.highlights.back()->setAttribute(highlightedUseAttribute());
highlights.highlights.back()->setAttribute(highlightedUseAttribute(view));
highlights.highlights.back()->setZDepth(highlightingZDepth);
// Highlight uses
......@@ -756,7 +761,7 @@ void ContextBrowserPlugin::addHighlight(View* view, KDevelop::Declaration* decl)
const auto& documentUses = fileIt.value();
for (auto& use : documentUses) {
highlights.highlights << PersistentMovingRange::Ptr(new PersistentMovingRange(use, document));
highlights.highlights.back()->setAttribute(highlightedUseAttribute());
highlights.highlights.back()->setAttribute(highlightedUseAttribute(view));
highlights.highlights.back()->setZDepth(highlightingZDepth);
}
}
......@@ -764,7 +769,7 @@ void ContextBrowserPlugin::addHighlight(View* view, KDevelop::Declaration* decl)
if (auto* def = FunctionDefinition::definition(decl)) {
highlights.highlights << def->createRangeMoving();
highlights.highlights.back()->setAttribute(highlightedUseAttribute());
highlights.highlights.back()->setAttribute(highlightedUseAttribute(view));
highlights.highlights.back()->setZDepth(highlightingZDepth);
}
}
......@@ -854,7 +859,7 @@ void ContextBrowserPlugin::updateForView(View* view)
if (allowHighlight) {
highlights.highlights <<
PersistentMovingRange::Ptr(new PersistentMovingRange(specialRange, IndexedString(url)));
highlights.highlights.back()->setAttribute(highlightedSpecialObjectAttribute());
highlights.highlights.back()->setAttribute(highlightedSpecialObjectAttribute(view));
highlights.highlights.back()->setZDepth(highlightingZDepth);
}
if (updateBrowserView)
......
......@@ -108,8 +108,8 @@ public:
void showUses(const KDevelop::DeclarationPointer& declaration) override;
KTextEditor::Attribute::Ptr highlightedUseAttribute() const;
KTextEditor::Attribute::Ptr highlightedSpecialObjectAttribute() const;
KTextEditor::Attribute::Ptr highlightedUseAttribute(KTextEditor::View* view) const;
KTextEditor::Attribute::Ptr highlightedSpecialObjectAttribute(KTextEditor::View* view) const;
public Q_SLOTS:
void showUsesDelayed(const KDevelop::DeclarationPointer& declaration);
......
Supports Markdown
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