1 | /* |
2 | SPDX-FileCopyrightText: KDE Developers |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef KATEVI_LASTCHANGERECORDER_H |
8 | #define KATEVI_LASTCHANGERECORDER_H |
9 | |
10 | #include "completion.h" |
11 | #include "keyevent.h" |
12 | |
13 | #include <QKeyEvent> |
14 | #include <QList> |
15 | #include <QString> |
16 | |
17 | namespace KateVi |
18 | { |
19 | class InputModeManager; |
20 | |
21 | /** |
22 | * In e.g. Insert mode, Qt seems to feed each keypress through twice; once as a ShortcutOverride (even if the key |
23 | * doesn't actually appear to be a ShortcutOverride) and then, whether the "ShortcutOverride" was accepted or not, |
24 | * again as a KeyPress. We don't want to store both, so this helper helps to decide what to do. |
25 | */ |
26 | bool isRepeatOfLastShortcutOverrideAsKeyPress(const QKeyEvent ¤tKeyPress, const QList<KeyEvent> &keyEventLog); |
27 | |
28 | class LastChangeRecorder |
29 | { |
30 | public: |
31 | explicit LastChangeRecorder(InputModeManager *viInputModeManager); |
32 | |
33 | void record(const QKeyEvent &event); |
34 | void dropLast(); |
35 | void clear(); |
36 | |
37 | QString encodedChanges() const; |
38 | |
39 | void replay(const QString &commands, const CompletionList &completions); |
40 | bool isReplaying() const; |
41 | |
42 | private: |
43 | InputModeManager *m_viInputModeManager; |
44 | |
45 | QList<KeyEvent> m_changeLog; |
46 | |
47 | bool m_isReplaying; |
48 | }; |
49 | } |
50 | |
51 | #endif // KATEVI_LASTCHANGERECORDER_H |
52 | |