From 29079ade72160e706445d7c0f015cae9cb400458 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Mon, 15 Oct 2018 19:39:17 +0800 Subject: [PATCH] vim: handle keys when CapsLock is on --- src/utils/vvim.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/utils/vvim.cpp b/src/utils/vvim.cpp index a2aa7741..070dbcb6 100644 --- a/src/utils/vvim.cpp +++ b/src/utils/vvim.cpp @@ -528,7 +528,21 @@ static bool joinLines(QTextCursor &p_cursor, bool VVim::handleKeyPressEvent(QKeyEvent *p_event, int *p_autoIndentPos) { - bool ret = handleKeyPressEvent(p_event->key(), p_event->modifiers(), p_autoIndentPos); + int modifiers = p_event->modifiers(); + QString keyText = p_event->text(); + if (keyText.size() == 1) { + if (keyText[0].isUpper()) { + // Upper case. + modifiers |= Qt::ShiftModifier; + } else if (keyText[0].isLower()) { + // Lower case. + if (modifiers & Qt::ShiftModifier) { + modifiers &= ~Qt::ShiftModifier; + } + } + } + + bool ret = handleKeyPressEvent(p_event->key(), modifiers, p_autoIndentPos); if (ret) { p_event->accept(); }