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
Tobias Hunger
qt-creator
Commits
26965d20
Commit
26965d20
authored
Apr 29, 2010
by
hjk
Browse files
fakevim: positioning fixes for linewise shifting
parent
0e122406
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/fakevimhandler.cpp
View file @
26965d20
...
...
@@ -3249,7 +3249,6 @@ void FakeVimHandler::Private::indentSelectedText(QChar typedChar)
indentText
(
range
,
typedChar
);
setPosition
(
firstPositionInLine
(
beginLine
));
moveToTargetColumn
();
handleStartOfLine
();
setTargetColumn
();
setDotCommand
(
"%1=="
,
endLine
-
beginLine
+
1
);
...
...
@@ -3278,24 +3277,27 @@ bool FakeVimHandler::Private::isElectricCharacter(QChar c) const
void
FakeVimHandler
::
Private
::
shiftRegionRight
(
int
repeat
)
{
setTargetColumn
();
int
beginLine
=
lineForPosition
(
anchor
());
int
endLine
=
lineForPosition
(
position
());
if
(
beginLine
>
endLine
)
int
targetPos
=
anchor
();
if
(
beginLine
>
endLine
)
{
qSwap
(
beginLine
,
endLine
);
targetPos
=
position
();
}
if
(
hasConfig
(
ConfigStartOfLine
))
targetPos
=
firstPositionInLine
(
beginLine
);
int
len
=
config
(
ConfigShiftWidth
).
toInt
()
*
repeat
;
QString
indent
(
len
,
' '
);
int
firstPos
=
firstPositionInLine
(
beginLine
);
beginEditBlock
(
firs
tPos
);
beginEditBlock
(
targe
tPos
);
for
(
int
line
=
beginLine
;
line
<=
endLine
;
++
line
)
{
setPosition
(
firstPositionInLine
(
line
));
m_tc
.
insertText
(
indent
);
}
endEditBlock
();
setPosition
(
firstPos
);
moveToTargetColumn
();
setPosition
(
targetPos
);
handleStartOfLine
();
setTargetColumn
();
setDotCommand
(
"%1>>"
,
endLine
-
beginLine
+
1
);
...
...
@@ -3303,16 +3305,19 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat)
void
FakeVimHandler
::
Private
::
shiftRegionLeft
(
int
repeat
)
{
setTargetColumn
();
int
beginLine
=
lineForPosition
(
anchor
());
int
endLine
=
lineForPosition
(
position
());
if
(
beginLine
>
endLine
)
int
targetPos
=
anchor
();
if
(
beginLine
>
endLine
)
{
qSwap
(
beginLine
,
endLine
);
targetPos
=
position
();
}
const
int
shift
=
config
(
ConfigShiftWidth
).
toInt
()
*
repeat
;
const
int
tab
=
config
(
ConfigTabStop
).
toInt
();
const
int
firstPos
=
firstPositionInLine
(
beginLine
);
if
(
hasConfig
(
ConfigStartOfLine
))
targetPos
=
firstPositionInLine
(
beginLine
);
beginEditBlock
(
firs
tPos
);
beginEditBlock
(
targe
tPos
);
for
(
int
line
=
endLine
;
line
>=
beginLine
;
--
line
)
{
int
pos
=
firstPositionInLine
(
line
);
const
QString
text
=
lineContents
(
line
);
...
...
@@ -3331,8 +3336,7 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
}
endEditBlock
();
setPosition
(
firstPos
);
moveToTargetColumn
();
setPosition
(
targetPos
);
handleStartOfLine
();
setTargetColumn
();
setDotCommand
(
"%1<<"
,
endLine
-
beginLine
+
1
);
...
...
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