| 1 | /* |
|---|---|
| 2 | SPDX-FileCopyrightText: 2013-2016 Simon St James <kdedevel@etotheipiplusone.com> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #ifndef KATEVI_EMULATED_COMMAND_BAR_ACTIVEMODE_H |
| 8 | #define KATEVI_EMULATED_COMMAND_BAR_ACTIVEMODE_H |
| 9 | |
| 10 | #include "completer.h" |
| 11 | |
| 12 | class QKeyEvent; |
| 13 | class QString; |
| 14 | class QWidget; |
| 15 | |
| 16 | namespace KTextEditor |
| 17 | { |
| 18 | class Cursor; |
| 19 | class Range; |
| 20 | class ViewPrivate; |
| 21 | } |
| 22 | |
| 23 | namespace KateVi |
| 24 | { |
| 25 | class EmulatedCommandBar; |
| 26 | struct CompletionStartParams; |
| 27 | class MatchHighlighter; |
| 28 | class InputModeManager; |
| 29 | |
| 30 | class ActiveMode |
| 31 | { |
| 32 | public: |
| 33 | ActiveMode(EmulatedCommandBar *emulatedCommandBar, MatchHighlighter *matchHighlighter, InputModeManager *viInputModeManager, KTextEditor::ViewPrivate *view) |
| 34 | : m_emulatedCommandBar(emulatedCommandBar) |
| 35 | , m_viInputModeManager(viInputModeManager) |
| 36 | , m_view(view) |
| 37 | , m_matchHighligher(matchHighlighter) |
| 38 | { |
| 39 | } |
| 40 | virtual ~ActiveMode() = 0; |
| 41 | virtual bool handleKeyPress(const QKeyEvent *keyEvent) = 0; |
| 42 | virtual void editTextChanged(const QString &newText) |
| 43 | { |
| 44 | Q_UNUSED(newText); |
| 45 | } |
| 46 | virtual KateVi::CompletionStartParams completionInvoked(Completer::CompletionInvocation invocationType); |
| 47 | virtual void completionChosen() |
| 48 | { |
| 49 | } |
| 50 | virtual void deactivate(bool wasAborted) = 0; |
| 51 | void setViInputModeManager(InputModeManager *viInputModeManager); |
| 52 | |
| 53 | protected: |
| 54 | // Helper methods. |
| 55 | void hideAllWidgetsExcept(QWidget *widgetToKeepVisible); |
| 56 | void updateMatchHighlight(KTextEditor::Range matchRange); |
| 57 | void close(bool wasAborted); |
| 58 | void closeWithStatusMessage(const QString &exitStatusMessage); |
| 59 | void startCompletion(const CompletionStartParams &completionStartParams); |
| 60 | void moveCursorTo(const KTextEditor::Cursor cursorPos); |
| 61 | EmulatedCommandBar *emulatedCommandBar(); |
| 62 | KTextEditor::ViewPrivate *view(); |
| 63 | InputModeManager *viInputModeManager(); |
| 64 | |
| 65 | private: |
| 66 | EmulatedCommandBar *m_emulatedCommandBar = nullptr; |
| 67 | InputModeManager *m_viInputModeManager = nullptr; |
| 68 | KTextEditor::ViewPrivate *m_view = nullptr; |
| 69 | MatchHighlighter *m_matchHighligher = nullptr; |
| 70 | }; |
| 71 | } |
| 72 | #endif |
| 73 |
