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
dcad2e24
Commit
dcad2e24
authored
Nov 10, 2009
by
hjk
Browse files
fakevim: fix pasting in visual block mode
parent
82c54828
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/fakevimhandler.cpp
View file @
dcad2e24
...
...
@@ -666,6 +666,7 @@ void FakeVimHandler::Private::restoreWidget()
EventResult
FakeVimHandler
::
Private
::
handleKey
(
int
key
,
int
unmodified
,
const
QString
&
text
)
{
//qDebug() << " CURSOR POS: " << m_undoCursorPosition;
m_undoCursorPosition
[
m_tc
.
document
()
->
availableUndoSteps
()]
=
m_tc
.
position
();
//qDebug() << "KEY: " << key << text << "POS: " << m_tc.position();
if
(
m_mode
==
InsertMode
)
...
...
@@ -2601,7 +2602,7 @@ void FakeVimHandler::Private::removeText(const Range &range)
beginEditBlock
();
for
(
int
i
=
beginLine
;
i
<=
endLine
&&
block
.
isValid
();
++
i
)
{
int
bCol
=
qMin
(
beginColumn
,
block
.
length
()
-
1
);
int
eCol
=
qMin
(
endColumn
,
block
.
length
()
-
1
);
int
eCol
=
qMin
(
endColumn
+
1
,
block
.
length
()
-
1
);
tc
.
setPosition
(
block
.
position
()
+
bCol
,
MoveAnchor
);
tc
.
setPosition
(
block
.
position
()
+
eCol
,
KeepAnchor
);
fixMarks
(
block
.
position
()
+
bCol
,
tc
.
selectionStart
()
-
tc
.
selectionEnd
());
...
...
@@ -2645,7 +2646,8 @@ void FakeVimHandler::Private::pasteText(bool afterCursor)
case
RangeBlockMode
:
{
beginEditBlock
();
QTextBlock
block
=
m_tc
.
block
();
moveRight
();
if
(
afterCursor
)
moveRight
();
QTextCursor
tc
=
m_tc
;
const
int
col
=
tc
.
position
()
-
block
.
position
();
//for (int i = lines.size(); --i >= 0; ) {
...
...
@@ -2654,10 +2656,10 @@ void FakeVimHandler::Private::pasteText(bool afterCursor)
tc
.
movePosition
(
StartOfLine
,
MoveAnchor
);
if
(
col
>=
block
.
length
())
{
tc
.
movePosition
(
EndOfLine
,
MoveAnchor
);
fixMarks
(
position
(),
QString
(
col
-
line
.
size
()
+
1
,
QChar
(
' '
)).
length
()
);
fixMarks
(
position
(),
col
-
line
.
size
()
+
1
);
tc
.
insertText
(
QString
(
col
-
line
.
size
()
+
1
,
QChar
(
' '
)));
}
else
{
tc
.
movePosition
(
Right
,
MoveAnchor
,
col
);
tc
.
movePosition
(
Right
,
MoveAnchor
,
col
-
1
+
afterCursor
);
}
qDebug
()
<<
"INSERT "
<<
line
<<
" AT "
<<
tc
.
position
()
<<
"COL: "
<<
col
;
...
...
@@ -2666,12 +2668,13 @@ void FakeVimHandler::Private::pasteText(bool afterCursor)
tc
.
movePosition
(
StartOfLine
,
MoveAnchor
);
tc
.
movePosition
(
Down
,
MoveAnchor
,
1
);
if
(
tc
.
position
()
>=
lastPositionInDocument
()
-
1
)
{
fixMarks
(
position
(),
QString
(
QChar
(
'\n'
)).
length
()
);
fixMarks
(
position
(),
1
);
tc
.
insertText
(
QString
(
QChar
(
'\n'
)));
tc
.
movePosition
(
Up
,
MoveAnchor
,
1
);
}
block
=
block
.
next
();
}
moveLeft
();
endEditBlock
();
break
;
}
...
...
@@ -2737,6 +2740,7 @@ QWidget *FakeVimHandler::Private::editor() const
void
FakeVimHandler
::
Private
::
undo
()
{
//qDebug() << " CURSOR POS: " << m_undoCursorPosition;
int
current
=
m_tc
.
document
()
->
availableUndoSteps
();
//endEditBlock();
EDITOR
(
undo
());
...
...
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