aboutsummaryrefslogtreecommitdiff
path: root/src/keymap
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-04-05 16:36:18 +0530
committerAkshay Nair <phenax5@gmail.com>2025-04-05 16:36:18 +0530
commitb6526785478ea8ba70ddd119f1e3e53a892d4a22 (patch)
treeab8d25169ead042255c5057f0969e775c61ab8dc /src/keymap
parent09cdcd15b31469c839831cad534fec9896999b60 (diff)
downloadnull-browser-b6526785478ea8ba70ddd119f1e3e53a892d4a22.tar.gz
null-browser-b6526785478ea8ba70ddd119f1e3e53a892d4a22.zip
Update clang formatting
Diffstat (limited to '')
-rw-r--r--src/keymap/KeySeqParser.cpp4
-rw-r--r--src/keymap/KeySeqParser.hpp9
-rw-r--r--src/keymap/KeymapEvaluator.cpp16
3 files changed, 11 insertions, 18 deletions
diff --git a/src/keymap/KeySeqParser.cpp b/src/keymap/KeySeqParser.cpp
index f81ba2a..aef3b58 100644
--- a/src/keymap/KeySeqParser.cpp
+++ b/src/keymap/KeySeqParser.cpp
@@ -5,8 +5,8 @@
#include "keymap/KeySeqParser.hpp"
-bool operator==(const KeyChord chord1, const KeyChord chord2) {
- return chord1.mod == chord2.mod && chord1.key == chord2.key;
+bool KeyChord::operator==(const KeyChord &chord2) const {
+ return this->mod == chord2.mod && this->key == chord2.key;
}
QList<KeyChord> KeySeqParser::parse(QString key_sequence) {
diff --git a/src/keymap/KeySeqParser.hpp b/src/keymap/KeySeqParser.hpp
index eb878ab..31680a9 100644
--- a/src/keymap/KeySeqParser.hpp
+++ b/src/keymap/KeySeqParser.hpp
@@ -6,8 +6,9 @@
struct KeyChord {
Qt::KeyboardModifiers mod;
Qt::Key key;
+
+ bool operator==(const KeyChord &chord2) const;
};
-bool operator==(KeyChord chord1, KeyChord chord2);
using KeySequence = QList<KeyChord>;
@@ -19,14 +20,12 @@ enum KeyMatchType : uint8_t {
class KeySeqParser {
public:
- static KeyMatchType key_sequence_match(const KeySequence &target,
- const KeySequence &current) {
+ static KeyMatchType key_sequence_match(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))
+ if (target[i].key != current[i].key || !target[i].mod.testFlags(current[i].mod))
return KeyMatchType::NoMatch;
}
diff --git a/src/keymap/KeymapEvaluator.cpp b/src/keymap/KeymapEvaluator.cpp
index 396e494..e42ec3c 100644
--- a/src/keymap/KeymapEvaluator.cpp
+++ b/src/keymap/KeymapEvaluator.cpp
@@ -7,21 +7,18 @@
// TODO: Clear mapping after some time
-void KeymapEvaluator::add_keymap(KeyMode mode, const QString &key,
- KeyAction action) {
+void KeymapEvaluator::add_keymap(KeyMode mode, const QString &key, KeyAction action) {
if (!modal_keys.contains(mode))
modal_keys.insert(mode, {});
qDebug() << " " << mode << key;
auto key_seq = key_seq_parser.parse(key);
- modal_keys[mode].append(
- KeyMap{.key_sequence = key_seq, .action = std::move(action)});
+ modal_keys[mode].append(KeyMap{.key_sequence = key_seq, .action = std::move(action)});
}
bool KeymapEvaluator::evaluate(Qt::KeyboardModifiers modifiers, Qt::Key key) {
- if (key == Qt::Key_Control || key == Qt::Key_Shift || key == Qt::Key_Meta ||
- key == Qt::Key_Alt)
+ if (key == Qt::Key_Control || key == Qt::Key_Shift || key == Qt::Key_Meta || key == Qt::Key_Alt)
return true;
const auto *keymaps = current_mode_keys();
@@ -30,8 +27,7 @@ bool KeymapEvaluator::evaluate(Qt::KeyboardModifiers modifiers, Qt::Key key) {
active_key_sequence.append(KeyChord{.mod = modifiers, .key = key});
for (const auto &keymap : *keymaps) {
- auto match_type = KeySeqParser::key_sequence_match(keymap.key_sequence,
- active_key_sequence);
+ auto match_type = KeySeqParser::key_sequence_match(keymap.key_sequence, active_key_sequence);
if (match_type == KeyMatchType::Match) {
qDebug() << "CALLED" << key;
@@ -53,9 +49,7 @@ bool KeymapEvaluator::evaluate(Qt::KeyboardModifiers modifiers, Qt::Key key) {
return true;
}
-bool KeymapEvaluator::is_insertable_mode() {
- return current_mode == KeyMode::Insert;
-}
+bool KeymapEvaluator::is_insertable_mode() { return current_mode == KeyMode::Insert; }
const QList<KeyMap> *KeymapEvaluator::current_mode_keys() {
if (!modal_keys.contains(current_mode))