1 | /* |
2 | SPDX-FileCopyrightText: KDE Developers |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef KATEVI_MACROS_H |
8 | #define KATEVI_MACROS_H |
9 | |
10 | #include "completion.h" |
11 | #include "keyevent.h" |
12 | #include "ktexteditor_export.h" |
13 | |
14 | #include <QKeyEvent> |
15 | |
16 | class KConfigGroup; |
17 | |
18 | namespace KateVi |
19 | { |
20 | class Macros |
21 | { |
22 | public: |
23 | explicit Macros(); |
24 | ~Macros(); |
25 | |
26 | void writeConfig(KConfigGroup &config) const; |
27 | void readConfig(const KConfigGroup &config); |
28 | |
29 | void store(const QChar ®, const QList<KeyEvent> ¯oKeyEventLog, const CompletionList &completions); |
30 | void remove(const QChar ®); |
31 | KTEXTEDITOR_EXPORT void clear(); |
32 | |
33 | QString get(const QChar ®) const; |
34 | CompletionList getCompletions(const QChar ®) const; |
35 | |
36 | private: |
37 | int readMacroCompletions(const QChar ®, const QStringList &encodedMacroCompletions, int macroCompletionIndex); |
38 | static QString encodeMacroCompletionForConfig(const Completion &completionForMacro); |
39 | static Completion decodeMacroCompletionFromConfig(const QString &encodedMacroCompletion); |
40 | |
41 | private: |
42 | QHash<QChar, QString> m_macros; |
43 | QHash<QChar, QList<Completion>> m_completions; |
44 | }; |
45 | |
46 | } |
47 | |
48 | #endif // KATEVI_MACROS_H |
49 | |