[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kate/frameworks] part: when in vi-mode override menu find actions
From: Michal Humpula <michal.humpula () seznam ! cz>
Date: 2014-01-02 13:15:02
Message-ID: E1Vyi74-00049i-D1 () scm ! kde ! org
[Download RAW message or body]
Git commit 11faa72076c0b2a093852cedfa02acd45f71e38b by Michal Humpula.
Committed on 02/01/2014 at 13:05.
Pushed by michalhumpula into branch 'frameworks'.
when in vi-mode override menu find actions
M +44 -20 part/view/kateview.cpp
M +10 -0 part/vimode/kateviinputmodemanager.cpp
M +10 -0 part/vimode/kateviinputmodemanager.h
M +72 -0 part/vimode/katevimodebase.cpp
M +7 -1 part/vimode/katevimodebase.h
M +0 -57 part/vimode/katevinormalmode.cpp
M +0 -4 part/vimode/katevinormalmode.h
http://commits.kde.org/kate/11faa72076c0b2a093852cedfa02acd45f71e38b
diff --git a/part/view/kateview.cpp b/part/view/kateview.cpp
index c09d4fe..b619f95 100644
--- a/part/view/kateview.cpp
+++ b/part/view/kateview.cpp
@@ -1535,10 +1535,8 @@ void KateView::toggleViInputMode()
void KateView::showViModeEmulatedCommandBar()
{
- if (viInputMode()) {
- bottomViewBar()->addBarWidget(viModeEmulatedCommandBar());
- bottomViewBar()->showBarWidget(viModeEmulatedCommandBar());
- }
+ bottomViewBar()->addBarWidget(viModeEmulatedCommandBar());
+ bottomViewBar()->showBarWidget(viModeEmulatedCommandBar());
}
void KateView::updateViModeBarMode()
@@ -1572,42 +1570,68 @@ KateViInputModeManager* \
KateView::resetViInputModeManager()
void KateView::find()
{
- const bool INIT_HINT_AS_INCREMENTAL = false;
- KateSearchBar * const bar = searchBar(INIT_HINT_AS_INCREMENTAL);
- bar->enterIncrementalMode();
- bottomViewBar()->addBarWidget(bar);
- bottomViewBar()->showBarWidget(bar);
- bar->setFocus();
+ if (viInputMode()) {
+ showViModeEmulatedCommandBar();
+ viModeEmulatedCommandBar()->init(KateViEmulatedCommandBar::SearchForward);
+ } else {
+ const bool INIT_HINT_AS_INCREMENTAL = false;
+ KateSearchBar * const bar = searchBar(INIT_HINT_AS_INCREMENTAL);
+ bar->enterIncrementalMode();
+ bottomViewBar()->addBarWidget(bar);
+ bottomViewBar()->showBarWidget(bar);
+ bar->setFocus();
+ }
}
void KateView::findSelectedForwards()
{
- KateSearchBar::nextMatchForSelection(this, \
KateSearchBar::SearchForward); + if (viInputMode()) {
+ getViInputModeManager()->findNext();
+ } else {
+ KateSearchBar::nextMatchForSelection(this, \
KateSearchBar::SearchForward); + }
}
void KateView::findSelectedBackwards()
{
- KateSearchBar::nextMatchForSelection(this, \
KateSearchBar::SearchBackward); + if (viInputMode()) {
+ getViInputModeManager()->findPrevious();
+ } else {
+ KateSearchBar::nextMatchForSelection(this, \
KateSearchBar::SearchBackward); + }
}
void KateView::replace()
{
- const bool INIT_HINT_AS_POWER = true;
- KateSearchBar * const bar = searchBar(INIT_HINT_AS_POWER);
- bar->enterPowerMode();
- bottomViewBar()->addBarWidget(bar);
- bottomViewBar()->showBarWidget(bar);
- bar->setFocus();
+ if (viInputMode()) {
+ showViModeEmulatedCommandBar();
+ viModeEmulatedCommandBar()->init(KateViEmulatedCommandBar::SearchForward);
+ } else {
+ const bool INIT_HINT_AS_POWER = true;
+ KateSearchBar * const bar = searchBar(INIT_HINT_AS_POWER);
+ bar->enterPowerMode();
+ bottomViewBar()->addBarWidget(bar);
+ bottomViewBar()->showBarWidget(bar);
+ bar->setFocus();
+ }
}
void KateView::findNext()
{
- searchBar()->findNext();
+ if (viInputMode()) {
+ getViInputModeManager()->findNext();
+ } else {
+ searchBar()->findNext();
+ }
}
void KateView::findPrevious()
{
- searchBar()->findPrevious();
+ if (viInputMode()) {
+ getViInputModeManager()->findPrevious();
+ } else {
+ searchBar()->findPrevious();
+ }
}
void KateView::slotSelectionChanged ()
diff --git a/part/vimode/kateviinputmodemanager.cpp \
b/part/vimode/kateviinputmodemanager.cpp index dabcf14..b11d499 100644
--- a/part/vimode/kateviinputmodemanager.cpp
+++ b/part/vimode/kateviinputmodemanager.cpp
@@ -333,6 +333,16 @@ void KateViInputModeManager::repeatLastChange()
m_isReplayingLastChange = false;
}
+void KateViInputModeManager::findNext()
+{
+ getCurrentViModeHandler()->findNext();
+}
+
+void KateViInputModeManager::findPrevious()
+{
+ getCurrentViModeHandler()->findPrev();
+}
+
void KateViInputModeManager::startRecordingMacro(QChar macroRegister)
{
Q_ASSERT(!m_isRecordingMacro);
diff --git a/part/vimode/kateviinputmodemanager.h \
b/part/vimode/kateviinputmodemanager.h index 11de896..c69db66 100644
--- a/part/vimode/kateviinputmodemanager.h
+++ b/part/vimode/kateviinputmodemanager.h
@@ -184,6 +184,16 @@ public:
*/
void repeatLastChange();
+ /**
+ * find next occurence of last search
+ */
+ void findNext();
+
+ /**
+ * find previous occurence of last search
+ */
+ void findPrevious();
+
class Completion
{
public:
diff --git a/part/vimode/katevimodebase.cpp \
b/part/vimode/katevimodebase.cpp index ef62717..533df62 100644
--- a/part/vimode/katevimodebase.cpp
+++ b/part/vimode/katevimodebase.cpp
@@ -1509,3 +1509,75 @@ void KateViModeBase::switchView(Direction direction) \
{ KateViewConfig::global()->setViInputMode(true);
}
}
+
+// FIXME: should honour the provided count
+KateViRange KateViModeBase::motionFindPrev()
+{
+ QString pattern = m_viInputModeManager->getLastSearchPattern();
+ bool backwards = m_viInputModeManager->lastSearchBackwards();
+ const bool caseSensitive = \
m_viInputModeManager->lastSearchCaseSensitive(); + const bool \
placeCursorAtEndOfMatch = \
m_viInputModeManager->lastSearchPlacesCursorAtEndOfMatch(); +
+ KateViRange match = findPatternForMotion( pattern, !backwards, \
caseSensitive, m_view->cursorPosition(), getCount() ); +
+ if (!placeCursorAtEndOfMatch)
+ {
+ return KateViRange(match.startLine, match.startColumn, \
ViMotion::ExclusiveMotion); + }
+ else
+ {
+ return KateViRange(match.endLine, match.endColumn - 1, \
ViMotion::ExclusiveMotion); + }
+}
+
+KateViRange KateViModeBase::motionFindNext()
+{
+ QString pattern = m_viInputModeManager->getLastSearchPattern();
+ bool backwards = m_viInputModeManager->lastSearchBackwards();
+ const bool caseSensitive = \
m_viInputModeManager->lastSearchCaseSensitive(); + const bool \
placeCursorAtEndOfMatch = \
m_viInputModeManager->lastSearchPlacesCursorAtEndOfMatch(); +
+ KateViRange match = findPatternForMotion( pattern, backwards, \
caseSensitive, m_view->cursorPosition(), getCount() ); +
+ if (!placeCursorAtEndOfMatch)
+ {
+ return KateViRange(match.startLine, match.startColumn, \
ViMotion::ExclusiveMotion); + }
+ else
+ {
+ return KateViRange(match.endLine, match.endColumn - 1, \
ViMotion::ExclusiveMotion); + }
+}
+
+void KateViModeBase::goToPos( const KateViRange &r )
+{
+ Cursor c;
+ c.setLine( r.endLine );
+ c.setColumn( r.endColumn );
+
+ if ( r.jump ) {
+ m_viInputModeManager->addJump(m_view->cursorPosition());
+ }
+
+ if ( c.line() >= doc()->lines() ) {
+ c.setLine( doc()->lines()-1 );
+ }
+
+ updateCursor( c );
+}
+
+void KateViModeBase::findNext()
+{
+ const KateViRange r = motionFindNext();
+ if (r.valid) {
+ goToPos(r);
+ }
+}
+
+void KateViModeBase::findPrev()
+{
+ const KateViRange r = motionFindPrev();
+ if (r.valid) {
+ goToPos(r);
+ }
+}
diff --git a/part/vimode/katevimodebase.h b/part/vimode/katevimodebase.h
index 964ceb3..61e9abb 100644
--- a/part/vimode/katevimodebase.h
+++ b/part/vimode/katevimodebase.h
@@ -89,6 +89,12 @@ class KATEPART_TESTS_EXPORT KateViModeBase : public \
QObject void message( const QString &msg );
Range findPattern( const QString& pattern, bool backwards, bool \
caseSensitive, const Cursor& startFrom, int count = -1 /* i.e use \
getCount() */ ) const; +
+ void findNext();
+ void findPrev();
+
+ KateViRange motionFindNext();
+ KateViRange motionFindPrev();
protected:
// helper methods
void yankToClipBoard(QChar chosen_register, QString text);
@@ -119,12 +125,12 @@ class KATEPART_TESTS_EXPORT KateViModeBase : public \
QObject
void addToNumberUnderCursor( int count );
+ virtual void goToPos( const KateViRange &r );
KateViRange goLineUp();
KateViRange goLineDown();
KateViRange goLineUpDown( int lines);
KateViRange goVisualLineUpDown(int lines);
-
unsigned int linesDisplayed() { return \
m_viewInternal->linesDisplayed(); }
void scrollViewLines( int l ) { m_viewInternal->scrollViewLines( l ); \
}
diff --git a/part/vimode/katevinormalmode.cpp \
b/part/vimode/katevinormalmode.cpp index 587eb23..e00976c 100644
--- a/part/vimode/katevinormalmode.cpp
+++ b/part/vimode/katevinormalmode.cpp
@@ -493,23 +493,6 @@ void \
KateViNormalMode::beginMonitoringDocumentChanges()
this, SLOT(textRemoved(KTextEditor::Document*,KTextEditor::Range)));
}
-void KateViNormalMode::goToPos( const KateViRange &r )
-{
- Cursor c;
- c.setLine( r.endLine );
- c.setColumn( r.endColumn );
-
- if ( r.jump ) {
- addCurrentPositionToJumpList();
- }
-
- if ( c.line() >= doc()->lines() ) {
- c.setLine( doc()->lines()-1 );
- }
-
- updateCursor( c );
-}
-
void KateViNormalMode::executeCommand( const KateViCommand* cmd )
{
const ViMode originalViMode = m_viInputModeManager->getCurrentViMode();
@@ -2417,46 +2400,6 @@ KateViRange \
KateViNormalMode::motionRepeatlastTFBackward() return \
KateViRange::invalid(); }
-// FIXME: should honour the provided count
-KateViRange KateViNormalMode::motionFindPrev()
-{
- QString pattern = m_viInputModeManager->getLastSearchPattern();
- bool backwards = m_viInputModeManager->lastSearchBackwards();
- const bool caseSensitive = \
m_viInputModeManager->lastSearchCaseSensitive();
- const bool placeCursorAtEndOfMatch = \
m_viInputModeManager->lastSearchPlacesCursorAtEndOfMatch();
-
- KateViRange match = findPatternForMotion( pattern, !backwards, \
caseSensitive, m_view->cursorPosition(), getCount() );
-
- if (!placeCursorAtEndOfMatch)
- {
- return KateViRange(match.startLine, match.startColumn, \
ViMotion::ExclusiveMotion);
- }
- else
- {
- return KateViRange(match.endLine, match.endColumn - 1, \
ViMotion::ExclusiveMotion);
- }
-}
-
-KateViRange KateViNormalMode::motionFindNext()
-{
- QString pattern = m_viInputModeManager->getLastSearchPattern();
- bool backwards = m_viInputModeManager->lastSearchBackwards();
- const bool caseSensitive = \
m_viInputModeManager->lastSearchCaseSensitive();
- const bool placeCursorAtEndOfMatch = \
m_viInputModeManager->lastSearchPlacesCursorAtEndOfMatch();
-
- KateViRange match = findPatternForMotion( pattern, backwards, \
caseSensitive, m_view->cursorPosition(), getCount() );
-
- if (!placeCursorAtEndOfMatch)
- {
- return KateViRange(match.startLine, match.startColumn, \
ViMotion::ExclusiveMotion);
- }
- else
- {
- return KateViRange(match.endLine, match.endColumn - 1, \
ViMotion::ExclusiveMotion);
- }
-}
-
-
KateViRange KateViNormalMode::motionToLineFirst()
{
KateViRange r( getCount()-1, 0, ViMotion::InclusiveMotion );
diff --git a/part/vimode/katevinormalmode.h \
b/part/vimode/katevinormalmode.h index 7de5630..869841d 100644
--- a/part/vimode/katevinormalmode.h
+++ b/part/vimode/katevinormalmode.h
@@ -205,9 +205,6 @@ class KATEPART_TESTS_EXPORT KateViNormalMode : public \
KateViModeBase KateViRange motionToCharBackward();
KateViRange motionRepeatlastTF();
KateViRange motionRepeatlastTFBackward();
- KateViRange motionFindNext();
- KateViRange motionFindPrev();
-
KateViRange motionToEOL();
KateViRange motionToColumn0();
@@ -283,7 +280,6 @@ class KATEPART_TESTS_EXPORT KateViNormalMode : public \
KateViModeBase void resetParser();
void initializeCommands();
QRegExp generateMatchingItemRegex();
- virtual void goToPos( const KateViRange &r );
void executeCommand( const KateViCommand* cmd );
OperationMode getOperationMode() const;
// The 'current position' is the current cursor position for \
non-linewise pastes, and the current
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic