Commit 1f176af9 authored by hjk's avatar hjk
Browse files

fakevim: fix ^ when it is a dead key

parent 02a9a462
......@@ -72,6 +72,7 @@
#include <QtCore/QStack>
#include <QtGui/QApplication>
#include <QtGui/QInputMethodEvent>
#include <QtGui/QKeyEvent>
#include <QtGui/QLineEdit>
#include <QtGui/QPlainTextEdit>
......@@ -3968,6 +3969,21 @@ bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev)
return false;
}
if (active && ev->type() == QEvent::InputMethod && ob == d->editor()) {
// This handles simple dead keys. The sequence of events is
// KeyRelease-InputMethod-KeyRelease for dead keys instead of
// KeyPress-KeyRelease as for simple keys. As vi acts on key presses,
// we have to act on the InputMethod event.
// FIXME: A first approximation working for e.g. ^ on a German keyboard
QInputMethodEvent *imev = static_cast<QInputMethodEvent *>(ev);
KEY_DEBUG("INPUTMETHOD" << imev->commitString() << imev->preeditString());
QString commitString = imev->commitString();
int key = commitString.size() == 1 ? commitString.at(0).unicode() : 0;
QKeyEvent kev(QEvent::KeyPress, key, Qt::KeyboardModifiers(), commitString);
EventResult res = d->handleEvent(&kev);
return res == EventHandled;
}
if (active && ev->type() == QEvent::KeyPress && ob == d->editor()) {
QKeyEvent *kev = static_cast<QKeyEvent *>(ev);
KEY_DEBUG("KEYPRESS" << kev->key());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment