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

List:       kde-commits
Subject:    [ktexteditor] src: Move MatchHighlighter into its own source files.
From:       Simon St James <kdedevel () etotheipiplusone ! com>
Date:       2016-06-17 8:18:10
Message-ID: E1bDoyg-0002ZN-EI () scm ! kde ! org
[Download RAW message or body]

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

Move MatchHighlighter into its own source files.

M  +1    -0    src/CMakeLists.txt
M  +2    -39   src/vimode/emulatedcommandbar/emulatedcommandbar.cpp
M  +1    -13   src/vimode/emulatedcommandbar/emulatedcommandbar.h

http://commits.kde.org/ktexteditor/77d57fbc62c0ffe3a62220fb3185e47ac8fb0c6f

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a6056c0..7263ba7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -276,6 +276,7 @@ if (BUILD_VIMODE)
     vimode/keyparser.cpp
     vimode/globalstate.cpp
     vimode/emulatedcommandbar/emulatedcommandbar.cpp
+    vimode/emulatedcommandbar/matchhighlighter.cpp
     vimode/commandrangeexpressionparser.cpp
     vimode/keymapper.cpp
     vimode/marks.cpp
diff --git a/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp \
b/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp index 5108b56..ff46fe5 100644
--- a/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp
+++ b/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp
@@ -20,7 +20,6 @@
 
 #include <vimode/emulatedcommandbar/emulatedcommandbar.h>
 
-#include "kateconfig.h"
 #include "katedocument.h"
 #include "kateglobal.h"
 #include "../commandrangeexpressionparser.h"
@@ -29,6 +28,7 @@
 #include <vimode/keyparser.h>
 #include <vimode/inputmodemanager.h>
 #include <vimode/modes/normalvimode.h>
+#include "matchhighlighter.h"
 
 #include <vimode/cmds.h>
 #include <vimode/modes/visualvimode.h>
@@ -1140,7 +1140,7 @@ void EmulatedCommandBar::SearchMode::setBarBackground ( \
EmulatedCommandBar::Sear  m_edit->setPalette(barBackground);
 }
 
-EmulatedCommandBar::CommandMode::CommandMode ( EmulatedCommandBar* \
emulatedCommandBar, EmulatedCommandBar::MatchHighlighter* matchHighlighter, \
KTextEditor::ViewPrivate* view,  QLineEdit* edit, InteractiveSedReplaceMode \
*interactiveSedReplaceMode, Completer* completer) \
+EmulatedCommandBar::CommandMode::CommandMode ( EmulatedCommandBar* \
emulatedCommandBar, MatchHighlighter* matchHighlighter, KTextEditor::ViewPrivate* \
view,  QLineEdit* edit, InteractiveSedReplaceMode *interactiveSedReplaceMode, \
Completer* completer)  : ActiveMode ( emulatedCommandBar, matchHighlighter ),
       m_edit(edit),
       m_view(view),
@@ -1511,40 +1511,3 @@ KTextEditor::Command* \
EmulatedCommandBar::CommandMode::queryCommand ( const QStr  return \
m_cmdDict.value(cmd.left(f));  
 }
-
-EmulatedCommandBar::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);
-}
-
-EmulatedCommandBar::MatchHighlighter::~MatchHighlighter()
-{
-    delete m_highlightedMatch;
-}
-
-void EmulatedCommandBar::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 EmulatedCommandBar::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/emulatedcommandbar.h \
b/src/vimode/emulatedcommandbar/emulatedcommandbar.h index 1dee727..7e46917 100644
--- a/src/vimode/emulatedcommandbar/emulatedcommandbar.h
+++ b/src/vimode/emulatedcommandbar/emulatedcommandbar.h
@@ -25,7 +25,6 @@
 #include <vimode/cmds.h>
 
 #include <ktexteditor/range.h>
-#include <ktexteditor/attribute.h>
 #include <ktexteditor/movingrange.h>
 #include "../searcher.h"
 
@@ -42,6 +41,7 @@ class QStringListModel;
 
 namespace KateVi
 {
+class MatchHighlighter;
 
 /**
  * A KateViewBarWidget that attempts to emulate some of the features of Vim's own \
command bar, @@ -85,18 +85,6 @@ private:
 
     void hideAllWidgetsExcept(QWidget* widgetToKeepVisible);
 
-    class MatchHighlighter
-    {
-    public:
-        MatchHighlighter(KTextEditor::ViewPrivate* view);
-        ~MatchHighlighter();
-        void updateMatchHighlight(const KTextEditor::Range &matchRange);
-        void updateMatchHighlightAttrib(); //  TODO - make a private slot.
-    private:
-        KTextEditor::ViewPrivate *m_view;
-        KTextEditor::Attribute::Ptr m_highlightMatchAttribute;
-        KTextEditor::MovingRange *m_highlightedMatch;
-    };
     QScopedPointer<MatchHighlighter> m_matchHighligher;
 
     struct CompletionStartParams


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

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