summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Humpula <michal.humpula@seznam.cz>2014-01-19 21:56:23 (GMT)
committerMichal Humpula <michal.humpula@seznam.cz>2014-01-19 22:14:09 (GMT)
commit01a8dd4edd9d38cb56a0422fa352b297500f4890 (patch)
tree54192f3317beb04014102af91d6f87160dc02423
parentb369c600d09b6f9fa3519c956b091db7864c18ed (diff)
vi-mode: don't launch commands trough commandBar
-rw-r--r--src/vimode/katevinormalmode.cpp30
-rw-r--r--src/vimode/katevinormalmode.h1
2 files changed, 19 insertions, 12 deletions
diff --git a/src/vimode/katevinormalmode.cpp b/src/vimode/katevinormalmode.cpp
index f58c714..45376ef 100644
--- a/src/vimode/katevinormalmode.cpp
+++ b/src/vimode/katevinormalmode.cpp
@@ -40,6 +40,7 @@
#include "katevimotion.h"
#include "katevinormalmode.h"
#include "katevivisualmode.h"
+#include "katecmd.h"
#include <ktexteditor/attribute.h>
#include <QApplication>
@@ -1753,14 +1754,12 @@ bool KateViNormalMode::commandSwitchToNextView()
bool KateViNormalMode::commandSplitHoriz()
{
- m_view->cmdLineBar()->execute(QLatin1String("split"));
- return true;
+ return executeKateCommand(QLatin1String("split"));
}
bool KateViNormalMode::commandSplitVert()
{
- m_view->cmdLineBar()->execute(QLatin1String("vsplit"));
- return true;
+ return executeKateCommand(QLatin1String("vsplit"));
}
bool KateViNormalMode::commandSwitchToNextTab()
@@ -1771,8 +1770,7 @@ bool KateViNormalMode::commandSwitchToNextTab()
command = command + QLatin1Char(' ') + QString::number(getCount());
}
- m_view->cmdLineBar()->execute(command);
- return true;
+ return executeKateCommand(command);
}
bool KateViNormalMode::commandSwitchToPrevTab()
@@ -1783,8 +1781,7 @@ bool KateViNormalMode::commandSwitchToPrevTab()
command = command + QLatin1Char(' ') + QString::number(getCount());
}
- m_view->cmdLineBar()->execute(command);
- return true;
+ return executeKateCommand(command);
}
bool KateViNormalMode::commandFormatLine()
@@ -1837,14 +1834,12 @@ bool KateViNormalMode::commandReplayMacro()
bool KateViNormalMode::commandCloseNocheck()
{
- m_view->cmdLineBar()->execute(QLatin1String("q!"));
- return true;
+ return executeKateCommand(QLatin1String("q!"));
}
bool KateViNormalMode::commandCloseWrite()
{
- m_view->cmdLineBar()->execute(QLatin1String("wq"));
- return true;
+ return executeKateCommand(QLatin1String("wq"));
}
bool KateViNormalMode::commandCollapseLocal()
@@ -3949,3 +3944,14 @@ void KateViNormalMode::undoEnded()
m_isUndo = false;
}
+bool KateViNormalMode::executeKateCommand(const QString &command)
+{
+ KTextEditor::Command *p = KateCmd::self()->queryCommand(command);
+
+ if (!p) {
+ return false;
+ }
+
+ QString msg;
+ return p->exec(m_view, command, msg);
+}
diff --git a/src/vimode/katevinormalmode.h b/src/vimode/katevinormalmode.h
index 503b203..b836e2d 100644
--- a/src/vimode/katevinormalmode.h
+++ b/src/vimode/katevinormalmode.h
@@ -298,6 +298,7 @@ protected:
void joinLines(unsigned int from, unsigned int to) const;
void reformatLines(unsigned int from, unsigned int to) const;
+ bool executeKateCommand(const QString &command);
KateViRange textObjectComma(bool inner) const;
void shrinkRangeAroundCursor(KateViRange &toShrink, const KateViRange &rangeToShrinkTo) const;