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
12class QKeyEvent;
13class QString;
14class QWidget;
15
16namespace KTextEditor
17{
18class Cursor;
19class Range;
20class ViewPrivate;
21}
22
23namespace KateVi
24{
25class EmulatedCommandBar;
26struct CompletionStartParams;
27class MatchHighlighter;
28class InputModeManager;
29
30class ActiveMode
31{
32public:
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
53protected:
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
65private:
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

source code of ktexteditor/src/vimode/emulatedcommandbar/activemode.h