1/*
2 SPDX-FileCopyrightText: 2008-2009 Erlend Hamberg <ehamberg@gmail.com>
3 SPDX-FileCopyrightText: 2013 Simon St James <kdedevel@etotheipiplusone.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KATEVI_KEY_MAPPER_H
9#define KATEVI_KEY_MAPPER_H
10
11#include <QObject>
12#include <ktexteditor_export.h>
13
14class QTimer;
15
16namespace KTextEditor
17{
18class DocumentPrivate;
19class ViewPrivate;
20}
21
22namespace KateVi
23{
24class InputModeManager;
25
26class KeyMapper : public QObject
27{
28public:
29 KeyMapper(InputModeManager *kateViInputModeManager, KTextEditor::DocumentPrivate *doc);
30 bool handleKeypress(QChar key);
31 KTEXTEDITOR_EXPORT void setMappingTimeout(int timeoutMS);
32 void setDoNotMapNextKeypress();
33 bool isExecutingMapping() const;
34 bool isPlayingBackRejectedKeys() const;
35
36public:
37 void mappingTimerTimeOut();
38
39private:
40 // Will be the mapping used if we decide that no extra mapping characters will be
41 // typed, either because we have a mapping that cannot be extended to another
42 // mapping by adding additional characters, or we have a mapping and timed out waiting
43 // for it to be extended to a longer mapping.
44 // (Essentially, this allows us to have mappings that extend each other e.g. "'12" and
45 // "'123", and to choose between them.)
46 QString m_fullMappingMatch;
47 QString m_mappingKeys;
48 bool m_doNotExpandFurtherMappings;
49 QTimer *m_mappingTimer;
50 InputModeManager *m_viInputModeManager;
51 KTextEditor::DocumentPrivate *m_doc;
52 int m_timeoutlen; // time to wait for the next keypress of a multi-key mapping (default: 1000 ms)
53 bool m_doNotMapNextKeypress;
54 int m_numMappingsBeingExecuted;
55 bool m_isPlayingBackRejectedKeys;
56
57private:
58 void executeMapping();
59 void playBackRejectedKeys();
60};
61}
62
63#endif /* KATEVI_KEY_MAPPER_H */
64

source code of ktexteditor/src/vimode/keymapper.h