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
9af00271
Commit
9af00271
authored
Nov 30, 2009
by
hjk
Browse files
fakevim: make undo of line shifting 'atomic'
parent
e84de32a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/fakevimhandler.cpp
View file @
9af00271
...
@@ -357,6 +357,7 @@ public:
...
@@ -357,6 +357,7 @@ public:
QChar
characterAtCursor
()
const
QChar
characterAtCursor
()
const
{
return
m_tc
.
document
()
->
characterAt
(
m_tc
.
position
());
}
{
return
m_tc
.
document
()
->
characterAt
(
m_tc
.
position
());
}
void
beginEditBlock
()
{
UNDO_DEBUG
(
"BEGIN EDIT BLOCK"
);
m_tc
.
beginEditBlock
();
}
void
beginEditBlock
()
{
UNDO_DEBUG
(
"BEGIN EDIT BLOCK"
);
m_tc
.
beginEditBlock
();
}
void
beginEditBlock
(
int
pos
)
{
setUndoPosition
(
pos
);
beginEditBlock
();
}
void
endEditBlock
()
{
UNDO_DEBUG
(
"END EDIT BLOCK"
);
m_tc
.
endEditBlock
();
}
void
endEditBlock
()
{
UNDO_DEBUG
(
"END EDIT BLOCK"
);
m_tc
.
endEditBlock
();
}
void
joinPreviousEditBlock
()
{
UNDO_DEBUG
(
"JOIN EDIT BLOCK"
);
m_tc
.
joinPreviousEditBlock
();
}
void
joinPreviousEditBlock
()
{
UNDO_DEBUG
(
"JOIN EDIT BLOCK"
);
m_tc
.
joinPreviousEditBlock
();
}
...
@@ -416,6 +417,7 @@ public:
...
@@ -416,6 +417,7 @@ public:
// undo handling
// undo handling
void
undo
();
void
undo
();
void
redo
();
void
redo
();
void
setUndoPosition
(
int
pos
);
QMap
<
int
,
int
>
m_undoCursorPosition
;
// revision -> position
QMap
<
int
,
int
>
m_undoCursorPosition
;
// revision -> position
// extra data for '.'
// extra data for '.'
...
@@ -667,7 +669,7 @@ EventResult FakeVimHandler::Private::handleKey(int key, int unmodified,
...
@@ -667,7 +669,7 @@ EventResult FakeVimHandler::Private::handleKey(int key, int unmodified,
const
QString
&
text
)
const
QString
&
text
)
{
{
//qDebug() << " CURSOR POS: " << m_undoCursorPosition;
//qDebug() << " CURSOR POS: " << m_undoCursorPosition;
m_undoCursorPosition
[
m_tc
.
document
()
->
availableUndoSteps
()]
=
m_tc
.
position
();
setUndoPosition
(
m_tc
.
position
()
)
;
//qDebug() << "KEY: " << key << text << "POS: " << m_tc.position();
//qDebug() << "KEY: " << key << text << "POS: " << m_tc.position();
if
(
m_mode
==
InsertMode
)
if
(
m_mode
==
InsertMode
)
return
handleInsertMode
(
key
,
unmodified
,
text
);
return
handleInsertMode
(
key
,
unmodified
,
text
);
...
@@ -679,6 +681,12 @@ EventResult FakeVimHandler::Private::handleKey(int key, int unmodified,
...
@@ -679,6 +681,12 @@ EventResult FakeVimHandler::Private::handleKey(int key, int unmodified,
return
EventUnhandled
;
return
EventUnhandled
;
}
}
void
FakeVimHandler
::
Private
::
setUndoPosition
(
int
pos
)
{
//qDebug() << " CURSOR POS: " << m_undoCursorPosition;
m_undoCursorPosition
[
m_tc
.
document
()
->
availableUndoSteps
()]
=
pos
;
}
void
FakeVimHandler
::
Private
::
moveDown
(
int
n
)
void
FakeVimHandler
::
Private
::
moveDown
(
int
n
)
{
{
#if 0
#if 0
...
@@ -2256,10 +2264,12 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat)
...
@@ -2256,10 +2264,12 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat)
QString
indent
(
len
,
' '
);
QString
indent
(
len
,
' '
);
int
firstPos
=
firstPositionInLine
(
beginLine
);
int
firstPos
=
firstPositionInLine
(
beginLine
);
beginEditBlock
(
firstPos
);
for
(
int
line
=
beginLine
;
line
<=
endLine
;
++
line
)
{
for
(
int
line
=
beginLine
;
line
<=
endLine
;
++
line
)
{
setPosition
(
firstPositionInLine
(
line
));
setPosition
(
firstPositionInLine
(
line
));
m_tc
.
insertText
(
indent
);
m_tc
.
insertText
(
indent
);
}
}
endEditBlock
();
setPosition
(
firstPos
);
setPosition
(
firstPos
);
moveToFirstNonBlankOnLine
();
moveToFirstNonBlankOnLine
();
...
@@ -2277,6 +2287,7 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
...
@@ -2277,6 +2287,7 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
int
tab
=
config
(
ConfigTabStop
).
toInt
();
int
tab
=
config
(
ConfigTabStop
).
toInt
();
int
firstPos
=
firstPositionInLine
(
beginLine
);
int
firstPos
=
firstPositionInLine
(
beginLine
);
beginEditBlock
(
firstPos
);
for
(
int
line
=
beginLine
;
line
<=
endLine
;
++
line
)
{
for
(
int
line
=
beginLine
;
line
<=
endLine
;
++
line
)
{
int
pos
=
firstPositionInLine
(
line
);
int
pos
=
firstPositionInLine
(
line
);
setPosition
(
pos
);
setPosition
(
pos
);
...
@@ -2297,6 +2308,7 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
...
@@ -2297,6 +2308,7 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
removeSelectedText
();
removeSelectedText
();
setPosition
(
pos
);
setPosition
(
pos
);
}
}
endEditBlock
();
setPosition
(
firstPos
);
setPosition
(
firstPos
);
moveToFirstNonBlankOnLine
();
moveToFirstNonBlankOnLine
();
...
...
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