Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
eeffd9be
Commit
eeffd9be
authored
Dec 27, 2008
by
hjk
Committed by
Roberto Raggi
Dec 29, 2008
Browse files
make <count> work for 'i'
parent
bfa828ef
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/handler.cpp
View file @
eeffd9be
...
...
@@ -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
);
}
}
...
...
tests/auto/fakevim/fakevim.pro
0 → 100644
View file @
eeffd9be
load
(
qttest_p4
)
SOURCES
+=
\
main
.
cpp
\
handler
.
cpp
HEADER
+=
\
handler
.
h
tests/auto/fakevim/main.cpp
0 → 100644
View file @
eeffd9be
/***************************************************************************
**
** 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"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment