From b4b6a646b3a7a7f6c7e990c67f208b76f4b5f748 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 20 Apr 2025 12:57:07 +0530 Subject: Refactor + expose managing mode to inside lua --- src/keymap/KeymapEvaluator.hpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/keymap/KeymapEvaluator.hpp') diff --git a/src/keymap/KeymapEvaluator.hpp b/src/keymap/KeymapEvaluator.hpp index 34f4ae5..a7a100b 100644 --- a/src/keymap/KeymapEvaluator.hpp +++ b/src/keymap/KeymapEvaluator.hpp @@ -2,8 +2,8 @@ #include #include -#include #include +#include #include "keymap/KeySeqParser.hpp" #include "utils.hpp" @@ -15,7 +15,16 @@ struct KeyMap { KeyAction action; }; -enum KeyMode : uint8_t { Normal, Insert }; +using KeyMode = QString; + +struct KeyModeConfig { + bool passthrough; +}; + +struct KeyModeState { + QList keymap; + KeyModeConfig config; +}; class KeymapEvaluator : public QObject { Q_OBJECT @@ -28,20 +37,20 @@ public: return keymap_evaluator; } - void add_keymap(KeyMode mode, const QString &key, KeyAction action); + void add_keymap(const KeyMode &mode, const QString &key, KeyAction action); bool evaluate(Qt::KeyboardModifiers modifiers, Qt::Key key); - KeyMode mode_from_string(const QString &mode_string); + void define_mode(const KeyMode &mode, const KeyModeConfig &config); DEFINE_SETTER(set_current_mode, current_mode) DEFINE_GETTER(get_current_mode, current_mode) protected: const QList *current_mode_keys(); - bool is_insertable_mode(); + bool is_passthrough_mode(); private: - QMap> modal_keys; + std::unordered_map modal_keys; KeySeqParser key_seq_parser; - KeyMode current_mode = KeyMode::Normal; + KeyMode current_mode = "i"; KeySequence active_key_sequence; }; -- cgit v1.3.1