KTextEditor

mappings.h
1/*
2 SPDX-FileCopyrightText: KDE Developers
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KATEVI_MAPPINGS_H
8#define KATEVI_MAPPINGS_H
9
10#include <QHash>
11#include <ktexteditor_export.h>
12
13class KConfigGroup;
14class KateViInputMode;
15
16namespace KateVi
17{
18class Mappings
19{
20public:
21 enum MappingRecursion {
22 Recursive,
23 NonRecursive
24 };
25
26 enum MappingMode {
27 NormalModeMapping = 0,
28 VisualModeMapping,
29 InsertModeMapping,
30 CommandModeMapping
31 };
32
33public:
34 void writeConfig(KConfigGroup &config) const;
35 void readConfig(const KConfigGroup &config);
36
37 KTEXTEDITOR_EXPORT void add(MappingMode mode, const QString &from, const QString &to, MappingRecursion recursion);
38 void remove(MappingMode mode, const QString &from);
39 KTEXTEDITOR_EXPORT void clear(MappingMode mode);
40
41 QString get(MappingMode mode, const QString &from, bool decode = false, bool includeTemporary = false) const;
42 QStringList getAll(MappingMode mode, bool decode = false, bool includeTemporary = false) const;
43 KTEXTEDITOR_EXPORT bool isRecursive(MappingMode mode, const QString &from) const;
44
45 KTEXTEDITOR_EXPORT void setLeader(const QChar &leader);
46
47public:
48 /**
49 * Returns CommandModeMapping if the emulated command bar is active, else the mapping mode
50 * corresponding to the current Vi mode.
51 */
52 static MappingMode mappingModeForCurrentViMode(KateViInputMode *viInputMode);
53
54private:
55 void writeMappings(KConfigGroup &config, const QString &mappingModeName, MappingMode mappingMode) const;
56 void readMappings(const KConfigGroup &config, const QString &mappingModeName, MappingMode mappingMode);
57
58private:
59 typedef struct {
60 // The real value of the mapping.
61 QString encoded;
62
63 // True if it's recursive, false otherwise.
64 bool recursive;
65
66 // True if this mapping should not be read/written in the config.
67 // Used for temporary mapping (e.g. mappings with <leader>).
68 bool temporary;
69 } Mapping;
70 typedef QHash<QString, Mapping> MappingList;
71
72 MappingList m_mappings[4];
73 QChar m_leader;
74};
75
76}
77
78#endif // KATEVI_MAPPINGS_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.