File indexing completed on 2024-04-28 15:31:18
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 KTEXTEDITOR_EXPORT KeyMapper : public QObject 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 KeyMapper(InputModeManager *kateViInputModeManager, KTextEditor::DocumentPrivate *doc, KTextEditor::ViewPrivate *view); 0032 bool handleKeypress(QChar key); 0033 void setMappingTimeout(int timeoutMS); 0034 void setDoNotMapNextKeypress(); 0035 bool isExecutingMapping() const; 0036 bool isPlayingBackRejectedKeys() const; 0037 0038 public Q_SLOTS: 0039 void mappingTimerTimeOut(); 0040 0041 private: 0042 // Will be the mapping used if we decide that no extra mapping characters will be 0043 // typed, either because we have a mapping that cannot be extended to another 0044 // mapping by adding additional characters, or we have a mapping and timed out waiting 0045 // for it to be extended to a longer mapping. 0046 // (Essentially, this allows us to have mappings that extend each other e.g. "'12" and 0047 // "'123", and to choose between them.) 0048 QString m_fullMappingMatch; 0049 QString m_mappingKeys; 0050 bool m_doNotExpandFurtherMappings; 0051 QTimer *m_mappingTimer; 0052 InputModeManager *m_viInputModeManager; 0053 KTextEditor::DocumentPrivate *m_doc; 0054 KTextEditor::ViewPrivate *m_view; 0055 int m_timeoutlen; // time to wait for the next keypress of a multi-key mapping (default: 1000 ms) 0056 bool m_doNotMapNextKeypress; 0057 int m_numMappingsBeingExecuted; 0058 bool m_isPlayingBackRejectedKeys; 0059 0060 private: 0061 KTEXTEDITOR_NO_EXPORT 0062 void executeMapping(); 0063 KTEXTEDITOR_NO_EXPORT 0064 void playBackRejectedKeys(); 0065 }; 0066 0067 } 0068 0069 #endif /* KATEVI_KEY_MAPPER_H */