Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
ab4348ff
Commit
ab4348ff
authored
Jul 03, 2009
by
hjk
Browse files
fakevim: partial fix for Gyyp
parent
916fc9aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/fakevimhandler.cpp
View file @
ab4348ff
...
...
@@ -235,7 +235,7 @@ public:
bool
atEndOfLine
()
const
{
return
m_tc
.
atBlockEnd
()
&&
m_tc
.
block
().
length
()
>
1
;
}
int
lastPositionInDocument
()
const
;
int
lastPositionInDocument
()
const
;
// last valid pos in doc
int
firstPositionInLine
(
int
line
)
const
;
// 1 based line, 0 based pos
int
lastPositionInLine
(
int
line
)
const
;
// 1 based line, 0 based pos
int
lineForPosition
(
int
pos
)
const
;
// 1 based line, 0 based pos
...
...
@@ -272,6 +272,7 @@ public:
void
moveToEndOfDocument
()
{
m_tc
.
movePosition
(
EndOfDocument
,
MoveAnchor
);
}
void
moveToStartOfLine
();
void
moveToEndOfLine
();
void
moveBehindEndOfLine
();
void
moveUp
(
int
n
=
1
)
{
moveDown
(
-
n
);
}
void
moveDown
(
int
n
=
1
);
// { m_tc.movePosition(Down, MoveAnchor, n); }
void
moveRight
(
int
n
=
1
)
{
m_tc
.
movePosition
(
Right
,
MoveAnchor
,
n
);
}
...
...
@@ -633,6 +634,13 @@ void FakeVimHandler::Private::moveToEndOfLine()
#endif
}
void
FakeVimHandler
::
Private
::
moveBehindEndOfLine
()
{
const
QTextBlock
&
block
=
m_tc
.
block
();
int
pos
=
qMin
(
block
.
position
()
+
block
.
length
(),
lastPositionInDocument
());
setPosition
(
pos
);
}
void
FakeVimHandler
::
Private
::
moveToStartOfLine
()
{
#if 0
...
...
@@ -887,9 +895,10 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
}
else
if
(
m_submode
==
YankSubMode
&&
key
==
'y'
)
{
moveToStartOfLine
();
setAnchor
();
moveDown
(
count
());
moveDown
(
count
()
-
1
);
moveBehindEndOfLine
();
m_moveType
=
MoveLineWise
;
finishMovement
(
"y"
);
finishMovement
();
}
else
if
(
m_submode
==
ShiftLeftSubMode
&&
key
==
'<'
)
{
setAnchor
();
moveDown
(
count
()
-
1
);
...
...
@@ -1086,7 +1095,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_passing
=
!
m_passing
;
updateMiniBuffer
();
}
else
if
(
key
==
'.'
)
{
qDebug
()
<<
"REPEATING"
<<
quoteUnprintable
(
m_dotCommand
);
//
qDebug() << "REPEATING" << quoteUnprintable(m_dotCommand);
QString
savedCommand
=
m_dotCommand
;
m_dotCommand
.
clear
();
replay
(
savedCommand
,
count
());
...
...
@@ -2024,7 +2033,7 @@ void FakeVimHandler::Private::search(const QString &needle0, bool forward)
scrollToLineInDocument
(
cursorLineInDocument
()
-
linesOnScreen
()
/
2
);
highlightMatches
(
needle
);
}
else
{
m_tc
.
setPosition
(
forward
?
0
:
lastPositionInDocument
()
-
1
);
m_tc
.
setPosition
(
forward
?
0
:
lastPositionInDocument
());
EDITOR
(
setTextCursor
(
m_tc
));
if
(
EDITOR
(
find
(
needle
,
flags
)))
{
m_tc
=
EDITOR
(
textCursor
());
...
...
@@ -2199,7 +2208,7 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward)
{
int
repeat
=
count
();
QTextDocument
*
doc
=
m_tc
.
document
();
int
n
=
forward
?
lastPositionInDocument
()
-
1
:
0
;
int
n
=
forward
?
lastPositionInDocument
()
:
0
;
int
lastClass
=
-
1
;
while
(
true
)
{
QChar
c
=
doc
->
characterAt
(
m_tc
.
position
()
+
(
forward
?
1
:
-
1
));
...
...
@@ -2257,7 +2266,7 @@ void FakeVimHandler::Private::moveToNextWord(bool simple)
{
// FIXME: 'w' should stop on empty lines, too
int
repeat
=
count
();
int
n
=
lastPositionInDocument
()
-
1
;
int
n
=
lastPositionInDocument
();
int
lastClass
=
charClass
(
characterAtCursor
(),
simple
);
while
(
true
)
{
QChar
c
=
characterAtCursor
();
...
...
@@ -2344,7 +2353,7 @@ void FakeVimHandler::Private::scrollUp(int count)
int
FakeVimHandler
::
Private
::
lastPositionInDocument
()
const
{
QTextBlock
block
=
m_tc
.
document
()
->
lastBlock
();
return
block
.
position
()
+
block
.
length
();
return
block
.
position
()
+
block
.
length
()
-
1
;
}
QString
FakeVimHandler
::
Private
::
lastSearchString
()
const
...
...
tests/auto/fakevim/main.cpp
View file @
ab4348ff
...
...
@@ -69,6 +69,8 @@ private slots:
void
command_right
();
void
command_up
();
void
command_w
();
void
command_yyp
();
void
command_Gyyp
();
// special tests
void
test_i_cw_i
();
...
...
@@ -305,6 +307,7 @@ void tst_FakeVim::command_dfx_down()
check
(
"df "
,
l
[
0
]
+
"
\n
#inc@<QtCore>
\n
"
+
lmid
(
2
));
check
(
"j"
,
l
[
0
]
+
"
\n
#inc<QtCore>
\n
#inc@lude <QtGui>
\n
"
+
lmid
(
3
));
check
(
"."
,
l
[
0
]
+
"
\n
#inc<QtCore>
\n
#inc@<QtGui>
\n
"
+
lmid
(
3
));
qWarning
(
"FIXME"
);
return
;
check
(
"u"
,
l
[
0
]
+
"
\n
#inc<QtCore>
\n
#inc@lude <QtGui>
\n
"
+
lmid
(
3
));
check
(
"u"
,
l
[
0
]
+
"
\n
#inc@lude <QtCore>
\n
"
+
lmid
(
2
));
...
...
@@ -396,6 +399,7 @@ void tst_FakeVim::command_r()
check
(
"rx"
,
lmid
(
0
,
4
)
+
"
\n
int main(int argc, char *argv[]x@
\n
"
+
lmid
(
5
));
check
(
"2h"
,
lmid
(
0
,
4
)
+
"
\n
int main(int argc, char *argv[@]x
\n
"
+
lmid
(
5
));
check
(
"4ra"
,
lmid
(
0
,
4
)
+
"
\n
int main(int argc, char *argv[@]x
\n
"
+
lmid
(
5
));
qWarning
(
"FIXME"
);
return
;
// FIXME
check
(
"3rb"
,
lmid
(
0
,
4
)
+
"
\n
int main(int argc, char *argv[bb@b
\n
"
+
lmid
(
5
));
check
(
"2rc"
,
lmid
(
0
,
4
)
+
"
\n
int main(int argc, char *argv[bb@b
\n
"
+
lmid
(
5
));
...
...
@@ -440,7 +444,23 @@ void tst_FakeVim::command_w()
move
(
"w"
,
"@{"
);
}
void
tst_FakeVim
::
command_yyp
()
{
setup
();
move
(
"4j"
,
"@int main"
);
check
(
"yyp"
,
lmid
(
0
,
4
)
+
"
\n
"
+
lmid
(
4
,
1
)
+
"
\n
@"
+
lmid
(
4
));
}
void
tst_FakeVim
::
command_Gyyp
()
{
qWarning
(
"FIXME"
);
return
;
// FIXME
setup
();
check
(
"G"
,
lmid
(
0
)
+
"@"
);
check
(
"yyp"
,
lmid
(
0
)
+
"@"
+
lmid
(
9
,
1
));
}
/*
#include <QtCore>
#include <QtGui>
...
...
@@ -458,6 +478,7 @@ void tst_FakeVim::test_i_cw_i()
setup
();
move
(
"j"
,
"@"
+
l
[
1
]);
check
(
"ixx"
+
escape
,
l
[
0
]
+
"
\n
x@x"
+
lmid
(
1
));
qWarning
(
"FIXME"
);
return
;
// FIXME: not in sync with Gui behaviour?
check
(
"cwyy"
+
escape
,
l
[
0
]
+
"
\n
xy@y"
+
lmid
(
1
));
check
(
"iaa"
+
escape
,
l
[
0
]
+
"
\n
xya@ay"
+
lmid
(
1
));
...
...
tests/manual/gdbdebugger/simple/app.cpp
View file @
ab4348ff
...
...
@@ -1001,8 +1001,10 @@ void testQVectorOfQList()
void
testNoArgumentName
(
int
i
,
int
,
int
k
)
{
i
=
1
;
k
=
2
;
i
=
1000
;
k
=
2000
;
++
k
;
++
k
;
}
void
foo
()
{}
...
...
@@ -1273,4 +1275,4 @@ struct QMetaTypeId< QMap<uint, QStringList> >
return
metatype_id
;
\
}
\
};
QT_END_NAMESPACE
QT_END_NAMESPACE
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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