Commit 0c8084c6 authored by Dominik Haumann's avatar Dominik Haumann

use search & replace hl from Kate color schema

parent bb4dd018
......@@ -32,6 +32,7 @@
#include <ktexteditor/markinterface.h>
#include <ktexteditor/movinginterface.h>
#include <ktexteditor/movingrange.h>
#include <ktexteditor/configinterface.h>
#include <kaction.h>
#include <kactioncollection.h>
......@@ -430,12 +431,17 @@ void KatePluginSearchView::addMatchMark(KTextEditor::Document* doc, int line, in
if (!doc) return;
KTextEditor::MovingInterface* miface = qobject_cast<KTextEditor::MovingInterface*>(doc);
KTextEditor::ConfigInterface* ciface = qobject_cast<KTextEditor::ConfigInterface*>(doc->activeView());
KTextEditor::Attribute::Ptr attr(new KTextEditor::Attribute());
if (sender() == &m_replacer) {
attr->setBackground(Qt::green); // TODO make this part of the color scheme
QColor replaceColor(Qt::green);
if (ciface) replaceColor = ciface->configValue("replace-highlight-color").value<QColor>();
attr->setBackground(replaceColor);
}
else {
attr->setBackground(Qt::yellow); // TODO make this part of the color scheme
QColor searchColor(Qt::yellow);
if (ciface) searchColor = ciface->configValue("search-highlight-color").value<QColor>();
attr->setBackground(searchColor);
}
KTextEditor::Range range(line, column, line, column+matchLen);
KTextEditor::MovingRange* mr = miface->newMovingRange(range);
......
......@@ -24,6 +24,7 @@
#include <ktexteditor/searchinterface.h>
#include <ktexteditor/movinginterface.h>
#include <ktexteditor/movingrange.h>
#include <ktexteditor/configinterface.h>
#include <assert.h>
#include <kaction.h>
......@@ -146,6 +147,14 @@ void HighlightSelectionPluginView::createHighlights()
// attr->setFontBold(true);
attr->setBackground(Qt::yellow);
// set correct highlight color from Kate's color schema
KTextEditor::ConfigInterface* ciface =
qobject_cast<KTextEditor::ConfigInterface*>(m_view);
if (ciface) {
QColor color = ciface->configValue("search-highlight-color").value<QColor>();
attr->setBackground(color);
}
KTextEditor::Cursor start(0, 0);
KTextEditor::Range searchRange;
......
......@@ -2580,7 +2580,8 @@ void KateView::aboutToHideContextMenu( )
QStringList KateView::configKeys() const
{
return QStringList() << "icon-bar" << "line-numbers" << "dynamic-word-wrap"
<< "background-color" << "selection-color";
<< "background-color" << "selection-color"
<< "search-highlight-color" << "replace-highlight-color";
}
QVariant KateView::configValue(const QString &key)
......@@ -2595,6 +2596,10 @@ QVariant KateView::configValue(const QString &key)
return renderer()->config()->backgroundColor();
else if (key == "selection-color")
return renderer()->config()->selectionColor();
else if (key == "search-highlight-color")
return renderer()->config()->searchHighlightColor();
else if (key == "replace-highlight-color")
return renderer()->config()->replaceHighlightColor();
else if (key == "default-mark-type")
return config()->defaultMarkType();
else if (key == "allow-mark-menu")
......@@ -2611,6 +2616,10 @@ void KateView::setConfigValue(const QString &key, const QVariant &value)
renderer()->config()->setBackgroundColor(value.value<QColor>());
else if (key == "selection-color")
renderer()->config()->setSelectionColor(value.value<QColor>());
else if (key == "search-highlight-color")
renderer()->config()->setSearchHighlightColor(value.value<QColor>());
else if (key == "replace-highlight-color")
renderer()->config()->setReplaceHighlightColor(value.value<QColor>());
} else if ( value.type() == QVariant::Bool ) {
// Note explicit type check above. If we used canConvert, then
// values of type UInt will be trapped here.
......
Markdown is supported
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