File indexing completed on 2024-03-24 04:00:57
0001 /* 0002 SPDX-FileCopyrightText: KDE Developers 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KATEVI_LASTCHANGERECORDER_H 0008 #define KATEVI_LASTCHANGERECORDER_H 0009 0010 #include "completion.h" 0011 #include "keyevent.h" 0012 0013 #include <QKeyEvent> 0014 #include <QList> 0015 #include <QString> 0016 0017 namespace KateVi 0018 { 0019 class InputModeManager; 0020 0021 /** 0022 * In e.g. Insert mode, Qt seems to feed each keypress through twice; once as a ShortcutOverride (even if the key 0023 * doesn't actually appear to be a ShortcutOverride) and then, whether the "ShortcutOverride" was accepted or not, 0024 * again as a KeyPress. We don't want to store both, so this helper helps to decide what to do. 0025 */ 0026 bool isRepeatOfLastShortcutOverrideAsKeyPress(const QKeyEvent ¤tKeyPress, const QList<KeyEvent> &keyEventLog); 0027 0028 class LastChangeRecorder 0029 { 0030 public: 0031 explicit LastChangeRecorder(InputModeManager *viInputModeManager); 0032 0033 void record(const QKeyEvent &event); 0034 void dropLast(); 0035 void clear(); 0036 0037 QString encodedChanges() const; 0038 0039 void replay(const QString &commands, const CompletionList &completions); 0040 bool isReplaying() const; 0041 0042 private: 0043 InputModeManager *m_viInputModeManager; 0044 0045 QList<KeyEvent> m_changeLog; 0046 0047 bool m_isReplaying; 0048 }; 0049 } 0050 0051 #endif // KATEVI_LASTCHANGERECORDER_H