forked from qt-creator/qt-creator
make the key handlers return a bool indication whether they acted on the
key or not.
This commit is contained in:
@@ -146,11 +146,11 @@ private:
|
||||
static int control(int key) { return key + 256; }
|
||||
|
||||
void init();
|
||||
void handleKey(int key, const QString &text);
|
||||
void handleInsertMode(int key, const QString &text);
|
||||
void handleCommandMode(int key, const QString &text);
|
||||
void handleRegisterMode(int key, const QString &text);
|
||||
void handleMiniBufferModes(int key, const QString &text);
|
||||
bool handleKey(int key, const QString &text);
|
||||
bool handleInsertMode(int key, const QString &text);
|
||||
bool handleCommandMode(int key, const QString &text);
|
||||
bool handleRegisterMode(int key, const QString &text);
|
||||
bool handleMiniBufferModes(int key, const QString &text);
|
||||
void finishMovement(const QString &text = QString());
|
||||
void search(const QString &needle, bool forward);
|
||||
|
||||
@@ -312,17 +312,18 @@ bool FakeVimHandler::Private::eventFilter(QObject *ob, QEvent *ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
void FakeVimHandler::Private::handleKey(int key, const QString &text)
|
||||
bool FakeVimHandler::Private::handleKey(int key, const QString &text)
|
||||
{
|
||||
//qDebug() << "KEY: " << key << text << "POS: " << m_tc.position();
|
||||
//qDebug() << "\nUNDO: " << m_undoStack << "\nREDO: " << m_redoStack;
|
||||
if (m_mode == InsertMode)
|
||||
handleInsertMode(key, text);
|
||||
else if (m_mode == CommandMode)
|
||||
handleCommandMode(key, text);
|
||||
else if (m_mode == ExMode || m_mode == SearchForwardMode
|
||||
return handleInsertMode(key, text);
|
||||
if (m_mode == CommandMode)
|
||||
return handleCommandMode(key, text);
|
||||
if (m_mode == ExMode || m_mode == SearchForwardMode
|
||||
|| m_mode == SearchBackwardMode)
|
||||
handleMiniBufferModes(key, text);
|
||||
return handleMiniBufferModes(key, text);
|
||||
return false;
|
||||
}
|
||||
|
||||
void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
||||
@@ -456,7 +457,7 @@ void FakeVimHandler::Private::showMessage(const QString &msg)
|
||||
updateMiniBuffer();
|
||||
}
|
||||
|
||||
void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
|
||||
bool FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
|
||||
{
|
||||
Q_UNUSED(text)
|
||||
|
||||
@@ -742,10 +743,12 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
|
||||
leaveVisualMode();
|
||||
} else {
|
||||
qDebug() << "Ignored" << key << text;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void FakeVimHandler::Private::handleInsertMode(int key, const QString &text)
|
||||
bool FakeVimHandler::Private::handleInsertMode(int key, const QString &text)
|
||||
{
|
||||
if (key == Key_Escape) {
|
||||
// start with '1', as one instance was already physically inserted
|
||||
@@ -789,14 +792,17 @@ void FakeVimHandler::Private::handleInsertMode(int key, const QString &text)
|
||||
m_lastInsertion.clear();
|
||||
} else if (key == Key_Backspace) {
|
||||
finishMovement();
|
||||
} else {
|
||||
} else if (!text.isEmpty()) {
|
||||
m_lastInsertion.append(text);
|
||||
m_tc.insertText(text);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
updateMiniBuffer();
|
||||
return true;
|
||||
}
|
||||
|
||||
void FakeVimHandler::Private::handleMiniBufferModes(int key, const QString &text)
|
||||
bool FakeVimHandler::Private::handleMiniBufferModes(int key, const QString &text)
|
||||
{
|
||||
Q_UNUSED(text)
|
||||
|
||||
@@ -858,6 +864,7 @@ void FakeVimHandler::Private::handleMiniBufferModes(int key, const QString &text
|
||||
m_commandBuffer += QChar(key);
|
||||
updateMiniBuffer();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 1 based.
|
||||
|
||||
Reference in New Issue
Block a user