[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ktexteditor] src/vimode/emulatedcommandbar: Add the "update match highlight attributes when config 
From:       Simon St James <kdedevel () etotheipiplusone ! com>
Date:       2016-06-17 8:18:10
Message-ID: E1bDoyg-0002ZN-FB () scm ! kde ! org
[Download RAW message or body]

Git commit 177b6d9bed12a9032135f4db9761289d67ee992e by Simon St James.
Committed on 17/06/2016 at 08:14.
Pushed by sstjames into branch 'master'.

Add the "update match highlight attributes when config changed" code into \
MatchHighlighter.

M  +0    -8    src/vimode/emulatedcommandbar/emulatedcommandbar.cpp
M  +0    -3    src/vimode/emulatedcommandbar/emulatedcommandbar.h
A  +44   -0    src/vimode/emulatedcommandbar/matchhighlighter.cpp     [License: \
UNKNOWN]  * A  +32   -0    src/vimode/emulatedcommandbar/matchhighlighter.h     \
[License: UNKNOWN]  *

The files marked with a * at the end have a non valid license. Please read: \
http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are \
listed at that page.


http://commits.kde.org/ktexteditor/177b6d9bed12a9032135f4db9761289d67ee992e

diff --git a/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp \
b/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp index ff46fe5..ffe72ae 100644
--- a/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp
+++ b/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp
@@ -324,9 +324,6 @@ EmulatedCommandBar::EmulatedCommandBar(InputModeManager \
*viInputModeManager, QWi  layout->addWidget(m_waitingForRegisterIndicator);
 
     m_matchHighligher.reset(new MatchHighlighter(m_view));
-    //  TODO - ultimately, move this connect into MatchHighlighter.
-    connect(m_view, SIGNAL(configChanged()),
-            this, SLOT(updateMatchHighlightAttrib()));
 
     m_interactiveSedReplaceMode.reset(new InteractiveSedReplaceMode(this, \
m_matchHighligher.data()));  layout->addWidget(m_interactiveSedReplaceMode->label());
@@ -414,11 +411,6 @@ void EmulatedCommandBar::closed()
     m_currentMode = nullptr;
 }
 
-void EmulatedCommandBar::updateMatchHighlightAttrib()
-{
-    m_matchHighligher->updateMatchHighlightAttrib();
-}
-
 void EmulatedCommandBar::switchToMode ( EmulatedCommandBar::ActiveMode* newMode )
 {
     if (m_currentMode)
diff --git a/src/vimode/emulatedcommandbar/emulatedcommandbar.h \
b/src/vimode/emulatedcommandbar/emulatedcommandbar.h index 7e46917..ec28640 100644
--- a/src/vimode/emulatedcommandbar/emulatedcommandbar.h
+++ b/src/vimode/emulatedcommandbar/emulatedcommandbar.h
@@ -318,11 +318,8 @@ private:
     QTimer *m_exitStatusMessageDisplayHideTimer;
     QLabel *m_exitStatusMessageDisplay;
     long m_exitStatusMessageHideTimeOutMS = 4000;
-private:
-
 private Q_SLOTS:
     void editTextChanged(const QString &newText);
-    void updateMatchHighlightAttrib();
     void startHideExitStatusMessageTimer();
 };
 
diff --git a/src/vimode/emulatedcommandbar/matchhighlighter.cpp \
b/src/vimode/emulatedcommandbar/matchhighlighter.cpp new file mode 100644
index 0000000..a05b6c8
--- /dev/null
+++ b/src/vimode/emulatedcommandbar/matchhighlighter.cpp
@@ -0,0 +1,44 @@
+#include "matchhighlighter.h"
+
+#include "kateview.h"
+#include "katedocument.h"
+#include "kateconfig.h"
+
+using namespace KateVi;
+
+MatchHighlighter::MatchHighlighter ( KTextEditor::ViewPrivate* view )
+: m_view(view)
+{ updateMatchHighlightAttrib();
+    m_highlightedMatch = \
m_view->doc()->newMovingRange(KTextEditor::Range::invalid(), \
Kate::TextRange::DoNotExpand); +    m_highlightedMatch->setView(m_view); // Show only \
in this view. +    m_highlightedMatch->setAttributeOnlyForViews(true);
+    // Use z depth defined in moving ranges interface.
+    m_highlightedMatch->setZDepth(-10000.0);
+    m_highlightedMatch->setAttribute(m_highlightMatchAttribute);
+    connect(m_view, SIGNAL(configChanged()),
+            this, SLOT(updateMatchHighlightAttrib()));
+}
+
+MatchHighlighter::~MatchHighlighter()
+{
+    delete m_highlightedMatch;
+}
+
+void MatchHighlighter::updateMatchHighlight ( const KTextEditor::Range& matchRange )
+{
+    // Note that if matchRange is invalid, the highlight will not be shown, so we
+    // don't need to check for that explicitly.
+    m_highlightedMatch->setRange(matchRange);
+}
+
+void MatchHighlighter::updateMatchHighlightAttrib()
+{
+    const QColor &matchColour = \
m_view->renderer()->config()->searchHighlightColor(); +    if \
(!m_highlightMatchAttribute) { +        m_highlightMatchAttribute = new \
KTextEditor::Attribute; +    }
+    m_highlightMatchAttribute->setBackground(matchColour);
+    KTextEditor::Attribute::Ptr mouseInAttribute(new KTextEditor::Attribute());
+    m_highlightMatchAttribute->setDynamicAttribute(KTextEditor::Attribute::ActivateMouseIn, \
mouseInAttribute); +    \
m_highlightMatchAttribute->dynamicAttribute(KTextEditor::Attribute::ActivateMouseIn)->setBackground(matchColour);
 +}
diff --git a/src/vimode/emulatedcommandbar/matchhighlighter.h \
b/src/vimode/emulatedcommandbar/matchhighlighter.h new file mode 100644
index 0000000..e160ea8
--- /dev/null
+++ b/src/vimode/emulatedcommandbar/matchhighlighter.h
@@ -0,0 +1,32 @@
+#ifndef KATEVI_EMULATED_COMMAND_BAR_MATCHHIGHLIGHTER_H
+#define KATEVI_EMULATED_COMMAND_BAR_MATCHHIGHLIGHTER_H
+
+#include <ktexteditor/attribute.h>
+
+#include <QObject>
+
+namespace KTextEditor
+{
+    class ViewPrivate;
+    class Range;
+    class MovingRange;
+}
+
+namespace KateVi
+{
+class MatchHighlighter : public QObject
+{
+    Q_OBJECT
+public:
+    MatchHighlighter(KTextEditor::ViewPrivate* view);
+    ~MatchHighlighter();
+    void updateMatchHighlight(const KTextEditor::Range &matchRange);
+private Q_SLOTS:
+    void updateMatchHighlightAttrib();
+private:
+    KTextEditor::ViewPrivate *m_view;
+    KTextEditor::Attribute::Ptr m_highlightMatchAttribute;
+    KTextEditor::MovingRange *m_highlightedMatch;
+};
+}
+#endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic