forked from qt-creator/qt-creator
make <count> work for 'i'
This commit is contained in:
@@ -160,6 +160,7 @@ public:
|
||||
QString m_commandBuffer;
|
||||
|
||||
bool m_lastSearchForward;
|
||||
QString m_lastInsertion;
|
||||
|
||||
// History for '/'
|
||||
QString lastSearchString() const;
|
||||
@@ -388,6 +389,7 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
|
||||
moveToFirstNonBlankOnLine();
|
||||
finishMovement();
|
||||
} else if (key == 'i') {
|
||||
m_lastInsertion.clear();
|
||||
m_mode = InsertMode;
|
||||
} else if (key == 'j' || key == Key_Down) {
|
||||
m_tc.movePosition(Down, KeepAnchor, count());
|
||||
@@ -483,28 +485,42 @@ void FakeVimHandler::Private::handleInsertMode(int key, const QString &text)
|
||||
{
|
||||
if (key == Key_Escape) {
|
||||
m_mode = CommandMode;
|
||||
m_tc.movePosition(Left, KeepAnchor, qMin(1, leftDist()));
|
||||
for (int i = 1; i < count(); ++i)
|
||||
m_tc.insertText(m_lastInsertion);
|
||||
m_tc.movePosition(Left, MoveAnchor, qMin(1, leftDist()));
|
||||
} else if (key == Key_Left) {
|
||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
||||
m_lastInsertion.clear();
|
||||
} else if (key == Key_Down) {
|
||||
m_tc.movePosition(Down, MoveAnchor, 1);
|
||||
m_lastInsertion.clear();
|
||||
} else if (key == Key_Up) {
|
||||
m_tc.movePosition(Up, MoveAnchor, 1);
|
||||
m_lastInsertion.clear();
|
||||
} else if (key == Key_Right) {
|
||||
m_tc.movePosition(Right, MoveAnchor, 1);
|
||||
m_lastInsertion.clear();
|
||||
} else if (key == Key_Return) {
|
||||
m_tc.insertBlock();
|
||||
m_lastInsertion.clear();
|
||||
} else if (key == Key_Backspace) {
|
||||
m_tc.deletePreviousChar();
|
||||
m_lastInsertion = m_lastInsertion.left(m_lastInsertion.size() - 1);
|
||||
} else if (key == Key_Delete) {
|
||||
m_tc.deleteChar();
|
||||
m_lastInsertion.clear();
|
||||
} else if (key == Key_PageDown || key == control('f')) {
|
||||
m_tc.movePosition(Down, KeepAnchor, count() * (linesOnScreen() - 2));
|
||||
m_lastInsertion.clear();
|
||||
} else if (key == Key_Backspace) {
|
||||
finishMovement();
|
||||
} else if (key == Key_PageUp || key == control('b')) {
|
||||
m_tc.movePosition(Up, KeepAnchor, count() * (linesOnScreen() - 2));
|
||||
m_lastInsertion.clear();
|
||||
} else if (key == Key_Backspace) {
|
||||
finishMovement();
|
||||
} else {
|
||||
m_lastInsertion.append(text);
|
||||
m_tc.insertText(text);
|
||||
}
|
||||
}
|
||||
|
||||
9
tests/auto/fakevim/fakevim.pro
Normal file
9
tests/auto/fakevim/fakevim.pro
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
load(qttest_p4)
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
handler.cpp
|
||||
|
||||
HEADER += \
|
||||
handler.h
|
||||
49
tests/auto/fakevim/main.cpp
Normal file
49
tests/auto/fakevim/main.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** Non-Open Source Usage
|
||||
**
|
||||
** Licensees may use this file in accordance with the Qt Beta Version
|
||||
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||
** alternatively, in accordance with the terms contained in a written
|
||||
** agreement between you and Nokia.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||
** of this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
**
|
||||
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#include "handler.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtCore/QSet>
|
||||
|
||||
class tst_FakeVim : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
};
|
||||
|
||||
|
||||
QTEST_MAIN(tst_FakeVim)
|
||||
|
||||
#include "main.moc"
|
||||
Reference in New Issue
Block a user