diff options
Diffstat (limited to 'include/keymap')
| -rw-r--r-- | include/keymap/KeySeqParser.hpp | 44 | ||||
| -rw-r--r-- | include/keymap/KeymapEvaluator.hpp | 42 |
2 files changed, 0 insertions, 86 deletions
diff --git a/include/keymap/KeySeqParser.hpp b/include/keymap/KeySeqParser.hpp deleted file mode 100644 index fac2546..0000000 --- a/include/keymap/KeySeqParser.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include <QtCore/qnamespace.h> -#include <QtCore> -#include <cmath> - -struct KeyChord { - Qt::KeyboardModifiers mod; - Qt::Key key; -}; -bool operator==(const KeyChord a, const KeyChord b); - -typedef QList<KeyChord> KeySequence; - -enum KeyMatchType { - NoMatch, - Match, - Pending, -}; - -class KeySeqParser { -public: - static const KeyMatchType keySequenceMatch(const KeySequence target, - const KeySequence current) { - for (int i = 0; i < target.length(); i++) { - if (current.length() <= i) - return KeyMatchType::Pending; - - if (target[i].key != current[i].key || - !target[i].mod.testFlags(current[i].mod)) - return KeyMatchType::NoMatch; - } - - return KeyMatchType::Match; - } - -public: - KeySeqParser(); - - KeySequence parse(QString keySequence); - -private: - Qt::Key parseKey(QString keyName); -}; diff --git a/include/keymap/KeymapEvaluator.hpp b/include/keymap/KeymapEvaluator.hpp deleted file mode 100644 index db93900..0000000 --- a/include/keymap/KeymapEvaluator.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include <QWidget> -#include <QtCore/qmap.h> -#include <QtCore/qnamespace.h> -#include <QtCore> -#include <functional> - -#include "keymap/KeySeqParser.hpp" -#include "utils.hpp" - -typedef std::function<void()> KeyAction; - -struct KeyMap { - KeySequence keySequence; - KeyAction action; -}; - -enum KeyMode { Normal, Insert }; - -class KeymapEvaluator : public QObject { - Q_OBJECT - -public: - KeymapEvaluator(); - - void addKeymap(KeyMode mode, QString key, KeyAction action); - bool evaluate(Qt::KeyboardModifiers modifiers, Qt::Key key); - - DEFINE_SETTER(setCurrentMode, currentMode) - DEFINE_GETTER(getCurrentMode, currentMode) - -private: - const QList<KeyMap> *currentModeKeys(); - bool isInsertableMode(); - -private: - QMap<KeyMode, QList<KeyMap>> modalKeys; - KeySeqParser keySeqParser; - KeyMode currentMode = KeyMode::Normal; - KeySequence activeKeySequence; -}; |
