[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ktexteditor] src/vimode: Continue moving Command-related stuff into CommandMode.
From: Simon St James <kdedevel () etotheipiplusone ! com>
Date: 2016-06-17 8:18:10
Message-ID: E1bDoyg-0002ZN-1v () scm ! kde ! org
[Download RAW message or body]
Git commit 86c9995136a6a3348bee09ac8fe62d5c71d2ff93 by Simon St James.
Committed on 17/06/2016 at 08:14.
Pushed by sstjames into branch 'master'.
Continue moving Command-related stuff into CommandMode.
M +16 -8 src/vimode/emulatedcommandbar.cpp
M +9 -7 src/vimode/emulatedcommandbar.h
http://commits.kde.org/ktexteditor/86c9995136a6a3348bee09ac8fe62d5c71d2ff93
diff --git a/src/vimode/emulatedcommandbar.cpp b/src/vimode/emulatedcommandbar.cpp
index fd88520..3a3b24f 100644
--- a/src/vimode/emulatedcommandbar.cpp
+++ b/src/vimode/emulatedcommandbar.cpp
@@ -629,7 +629,7 @@ bool EmulatedCommandBar::handleKeyPress(const QKeyEvent \
*keyEvent) if (!m_completer->popup()->isVisible()) {
CompletionStartParams completionStartParams;
if (m_mode == Command) {
- completionStartParams = m_commandMode->completionInvoked();
+ completionStartParams = \
m_commandMode->completionInvoked(CompletionInvocation::ExtraContext); } else {
completionStartParams = activateSearchHistoryCompletion();
}
@@ -651,7 +651,7 @@ bool EmulatedCommandBar::handleKeyPress(const QKeyEvent \
*keyEvent) if (!m_completer->popup()->isVisible()) {
CompletionStartParams completionStartParams;
if (m_mode == Command) {
- completionStartParams = \
m_commandMode->activateCommandHistoryCompletion(); + \
completionStartParams = \
m_commandMode->completionInvoked(CompletionInvocation::NormalContext); } else {
completionStartParams = activateSearchHistoryCompletion();
}
@@ -1167,14 +1167,22 @@ void EmulatedCommandBar::CommandMode::editTextChanged ( const \
QString& newText, }
}
-EmulatedCommandBar::CompletionStartParams \
EmulatedCommandBar::CommandMode::completionInvoked() \
+EmulatedCommandBar::CompletionStartParams \
EmulatedCommandBar::CommandMode::completionInvoked(EmulatedCommandBar::CompletionInvocation \
invocationType) {
CompletionStartParams completionStartParams;
- if (isCursorInFindTermOfSed()) {
- completionStartParams = activateSedFindHistoryCompletion();
- } else if (isCursorInReplaceTermOfSed()) {
- completionStartParams = activateSedReplaceHistoryCompletion();
- } else {
+ if (invocationType == EmulatedCommandBar::CompletionInvocation::ExtraContext)
+ {
+ if (isCursorInFindTermOfSed()) {
+ completionStartParams = activateSedFindHistoryCompletion();
+ } else if (isCursorInReplaceTermOfSed()) {
+ completionStartParams = activateSedReplaceHistoryCompletion();
+ } else {
+ completionStartParams = activateCommandHistoryCompletion();
+ }
+ }
+ else
+ {
+ // Normal context, so boring, ordinary History completion.
completionStartParams = activateCommandHistoryCompletion();
}
return completionStartParams;
diff --git a/src/vimode/emulatedcommandbar.h b/src/vimode/emulatedcommandbar.h
index a15693c..ffd05ea 100644
--- a/src/vimode/emulatedcommandbar.h
+++ b/src/vimode/emulatedcommandbar.h
@@ -187,6 +187,8 @@ private:
bool m_isSendingSyntheticSearchCompletedKeypress = false;
};
+ enum class CompletionInvocation { ExtraContext, NormalContext }; // TODO - make \
member of upcoming Completer class. +
class CommandMode : public ActiveMode
{
public:
@@ -198,7 +200,7 @@ private:
virtual bool handleKeyPress ( const QKeyEvent* keyEvent );
void editTextChanged(const QString &newText, bool \
isNextTextChangeDueToCompletionChange); QString executeCommand(const QString \
&commandToExecute);
- CompletionStartParams completionInvoked();
+ CompletionStartParams completionInvoked(CompletionInvocation \
invocationType); void completionChosen();
/**
* Stuff to do with expressions of the form:
@@ -218,16 +220,11 @@ private:
* the range over which the command should be run e.g. '<,'>. @see \
CommandRangeExpressionParser
*/
CommandMode::ParsedSedExpression parseAsSedExpression(); // TODO - make \
private
- int commandBeforeCursorBegin();
- void replaceCommandBeforeCursorWith(const QString &newCommand);
+ private:
CompletionStartParams activateCommandCompletion();
CompletionStartParams activateCommandHistoryCompletion();
CompletionStartParams activateSedFindHistoryCompletion();
CompletionStartParams activateSedReplaceHistoryCompletion();
- KCompletion m_cmdCompletion;
- QHash<QString, KTextEditor::Command *> m_cmdDict;
- KTextEditor::Command *queryCommand(const QString &cmd) const;
- private:
QString withoutRangeExpression();
QString rangeExpression();
QString withSedFindTermReplacedWith(const QString &newFindTerm);
@@ -236,10 +233,15 @@ private:
bool isCursorInReplaceTermOfSed();
QString sedFindTerm();
QString sedReplaceTerm();
+ void replaceCommandBeforeCursorWith(const QString &newCommand);
+ int commandBeforeCursorBegin();
QLineEdit *m_edit;
InputModeManager *m_viInputModeManager = nullptr;
KTextEditor::ViewPrivate *m_view;
InteractiveSedReplaceMode *m_interactiveSedReplaceMode;
+ KCompletion m_cmdCompletion;
+ QHash<QString, KTextEditor::Command *> m_cmdDict;
+ KTextEditor::Command *queryCommand(const QString &cmd) const;
};
QScopedPointer<InteractiveSedReplaceMode> m_interactiveSedReplaceMode;
QScopedPointer<SearchMode> m_searchMode;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic