File indexing completed on 2024-03-24 04:00:56
0001 /* 0002 SPDX-FileCopyrightText: 2008-2009 Erlend Hamberg <ehamberg@gmail.com> 0003 SPDX-FileCopyrightText: 2013 Simon St James <kdedevel@etotheipiplusone.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KATEVI_KEY_MAPPER_H 0009 #define KATEVI_KEY_MAPPER_H 0010 0011 #include <QObject> 0012 #include <ktexteditor_export.h> 0013 0014 class QTimer; 0015 0016 namespace KTextEditor 0017 { 0018 class DocumentPrivate; 0019 class ViewPrivate; 0020 } 0021 0022 namespace KateVi 0023 { 0024 class InputModeManager; 0025 0026 class KeyMapper : public QObject 0027 { 0028 public: 0029 KeyMapper(InputModeManager *kateViInputModeManager, KTextEditor::DocumentPrivate *doc); 0030 bool handleKeypress(QChar key); 0031 KTEXTEDITOR_EXPORT void setMappingTimeout(int timeoutMS); 0032 void setDoNotMapNextKeypress(); 0033 bool isExecutingMapping() const; 0034 bool isPlayingBackRejectedKeys() const; 0035 0036 public: 0037 void mappingTimerTimeOut(); 0038 0039 private: 0040 // Will be the mapping used if we decide that no extra mapping characters will be 0041 // typed, either because we have a mapping that cannot be extended to another 0042 // mapping by adding additional characters, or we have a mapping and timed out waiting 0043 // for it to be extended to a longer mapping. 0044 // (Essentially, this allows us to have mappings that extend each other e.g. "'12" and 0045 // "'123", and to choose between them.) 0046 QString m_fullMappingMatch; 0047 QString m_mappingKeys; 0048 bool m_doNotExpandFurtherMappings; 0049 QTimer *m_mappingTimer; 0050 InputModeManager *m_viInputModeManager; 0051 KTextEditor::DocumentPrivate *m_doc; 0052 int m_timeoutlen; // time to wait for the next keypress of a multi-key mapping (default: 1000 ms) 0053 bool m_doNotMapNextKeypress; 0054 int m_numMappingsBeingExecuted; 0055 bool m_isPlayingBackRejectedKeys; 0056 0057 private: 0058 void executeMapping(); 0059 void playBackRejectedKeys(); 0060 }; 0061 } 0062 0063 #endif /* KATEVI_KEY_MAPPER_H */