Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
9d8809e9
Commit
9d8809e9
authored
16 years ago
by
dt
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline
parents
d370b08a
9100e963
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/fakevim/fakevimhandler.cpp
+178
-127
178 additions, 127 deletions
src/plugins/fakevim/fakevimhandler.cpp
with
178 additions
and
127 deletions
src/plugins/fakevim/fakevimhandler.cpp
+
178
−
127
View file @
9d8809e9
...
@@ -137,17 +137,23 @@ struct EditOperation
...
@@ -137,17 +137,23 @@ struct EditOperation
QString
m_to
;
QString
m_to
;
};
};
QDebug
&
operator
<<
(
QDebug
&
ts
,
const
EditOperation
&
op
)
static
QDebug
&
operator
<<
(
QDebug
&
ts
,
const
EditOperation
&
op
)
{
{
if
(
op
.
m_itemCount
>
0
)
{
if
(
op
.
m_itemCount
>
0
)
{
ts
<<
"EDIT BLOCK WITH"
<<
op
.
m_itemCount
<<
"ITEMS"
;
ts
<<
"
\n
EDIT BLOCK WITH
"
<<
op
.
m_itemCount
<<
"
ITEMS"
;
}
else
{
}
else
{
ts
<<
"EDIT AT "
<<
op
.
m_position
ts
<<
"
\n
EDIT AT "
<<
op
.
m_position
<<
" FROM "
<<
op
.
m_from
<<
" TO "
<<
op
.
m_to
;
<<
"
\n
FROM "
<<
op
.
m_from
<<
"
\n
TO "
<<
op
.
m_to
;
}
}
return
ts
;
return
ts
;
}
}
int
lineCount
(
const
QString
&
text
)
{
//return text.count(QChar(ParagraphSeparator));
return
text
.
count
(
QChar
(
'\n'
));
}
class
FakeVimHandler
::
Private
class
FakeVimHandler
::
Private
{
{
public:
public:
...
@@ -206,26 +212,29 @@ private:
...
@@ -206,26 +212,29 @@ private:
// to reduce line noise
// to reduce line noise
typedef
QTextCursor
::
MoveOperation
MoveOperation
;
typedef
QTextCursor
::
MoveOperation
MoveOperation
;
typedef
QTextCursor
::
MoveMode
MoveMode
;
typedef
QTextCursor
::
MoveMode
MoveMode
;
void
moveToEndOfDocument
(
MoveMode
m
,
int
n
=
1
)
void
moveToEndOfDocument
()
{
m_tc
.
movePosition
(
QTextCursor
::
End
,
m
,
n
);
}
{
m_tc
.
movePosition
(
QTextCursor
::
End
,
MoveAnchor
);
}
void
moveToStartOfLine
(
MoveMode
m
,
int
n
=
1
)
void
moveToStartOfLine
()
{
m_tc
.
movePosition
(
QTextCursor
::
StartOfLine
,
m
,
n
);
}
{
m_tc
.
movePosition
(
QTextCursor
::
StartOfLine
,
MoveAnchor
);
}
void
moveToEndOfLine
(
MoveMode
m
,
int
n
=
1
)
void
moveToEndOfLine
()
{
m_tc
.
movePosition
(
QTextCursor
::
EndOfLine
,
m
,
n
);
}
{
m_tc
.
movePosition
(
QTextCursor
::
EndOfLine
,
MoveAnchor
);
}
void
moveUp
(
MoveMode
m
,
int
n
=
1
)
void
moveUp
(
int
n
=
1
)
{
m_tc
.
movePosition
(
QTextCursor
::
Up
,
m
,
n
);
}
{
m_tc
.
movePosition
(
QTextCursor
::
Up
,
MoveAnchor
,
n
);
}
void
moveDown
(
MoveMode
m
,
int
n
=
1
)
void
moveDown
(
int
n
=
1
)
{
m_tc
.
movePosition
(
QTextCursor
::
Down
,
m
,
n
);
}
{
m_tc
.
movePosition
(
QTextCursor
::
Down
,
MoveAnchor
,
n
);
}
void
moveRight
(
MoveMode
m
,
int
n
=
1
)
void
moveRight
(
int
n
=
1
)
{
m_tc
.
movePosition
(
QTextCursor
::
Right
,
m
,
n
);
}
{
m_tc
.
movePosition
(
QTextCursor
::
Right
,
MoveAnchor
,
n
);
}
void
moveLeft
(
MoveMode
m
,
int
n
=
1
)
void
moveLeft
(
int
n
=
1
)
{
m_tc
.
movePosition
(
QTextCursor
::
Left
,
m
,
n
);
}
{
m_tc
.
movePosition
(
QTextCursor
::
Left
,
MoveAnchor
,
n
);
}
void
setAnchor
()
{
m_anchor
=
m_tc
.
position
();
}
QString
selectedText
()
const
;
void
handleFfTt
(
int
key
);
void
handleFfTt
(
int
key
);
// helper function for handleCommand. return 1 based line index.
// helper function for handleCommand. return 1 based line index.
int
readLineCode
(
QString
&
cmd
);
int
readLineCode
(
QString
&
cmd
);
QTextCursor
selectRange
(
int
beginLine
,
int
endLine
);
void
selectRange
(
int
beginLine
,
int
endLine
);
void
setWidget
(
QWidget
*
ob
);
void
setWidget
(
QWidget
*
ob
);
void
enterInsertMode
();
void
enterInsertMode
();
...
@@ -250,6 +259,7 @@ public:
...
@@ -250,6 +259,7 @@ public:
int
m_subsubdata
;
int
m_subsubdata
;
QString
m_input
;
QString
m_input
;
QTextCursor
m_tc
;
QTextCursor
m_tc
;
int
m_anchor
;
QHash
<
int
,
QString
>
m_registers
;
QHash
<
int
,
QString
>
m_registers
;
int
m_register
;
int
m_register
;
QString
m_mvcount
;
QString
m_mvcount
;
...
@@ -277,9 +287,11 @@ public:
...
@@ -277,9 +287,11 @@ public:
void
recordRemoveNextChar
();
void
recordRemoveNextChar
();
void
recordInsertText
(
const
QString
&
data
);
void
recordInsertText
(
const
QString
&
data
);
void
recordRemoveSelectedText
();
QString
recordRemoveSelectedText
();
void
recordBeginGroup
();
void
recordBeginGroup
();
void
recordEndGroup
();
void
recordEndGroup
();
int
anchor
()
const
{
return
m_anchor
;
}
int
position
()
const
{
return
m_tc
.
position
();
}
void
undo
();
void
undo
();
void
redo
();
void
redo
();
...
@@ -403,9 +415,9 @@ bool FakeVimHandler::Private::handleKey(int key, int unmodified, const QString &
...
@@ -403,9 +415,9 @@ bool FakeVimHandler::Private::handleKey(int key, int unmodified, const QString &
void
FakeVimHandler
::
Private
::
finishMovement
(
const
QString
&
dotCommand
)
void
FakeVimHandler
::
Private
::
finishMovement
(
const
QString
&
dotCommand
)
{
{
if
(
m_submode
==
FilterSubMode
)
{
if
(
m_submode
==
FilterSubMode
)
{
int
beginLine
=
lineForPosition
(
m_tc
.
anchor
());
int
beginLine
=
lineForPosition
(
anchor
());
int
endLine
=
lineForPosition
(
m_tc
.
position
());
int
endLine
=
lineForPosition
(
position
());
m_tc
.
setPosition
(
qMin
(
m_tc
.
anchor
(),
m_tc
.
position
()));
m_tc
.
setPosition
(
qMin
(
anchor
(),
position
()));
m_mode
=
ExMode
;
m_mode
=
ExMode
;
m_commandBuffer
=
QString
(
".,+%1!"
).
arg
(
qAbs
(
endLine
-
beginLine
));
m_commandBuffer
=
QString
(
".,+%1!"
).
arg
(
qAbs
(
endLine
-
beginLine
));
m_commandHistory
.
append
(
QString
());
m_commandHistory
.
append
(
QString
());
...
@@ -420,16 +432,15 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
...
@@ -420,16 +432,15 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
if
(
m_submode
==
ChangeSubMode
)
{
if
(
m_submode
==
ChangeSubMode
)
{
if
(
!
dotCommand
.
isEmpty
())
if
(
!
dotCommand
.
isEmpty
())
m_dotCommand
=
"c"
+
dotCommand
;
m_dotCommand
=
"c"
+
dotCommand
;
m_registers
[
m_register
]
=
m_tc
.
s
electedText
();
QString
text
=
recordRemoveS
electedText
();
recordRemoveSelectedT
ext
()
;
m_registers
[
m_register
]
=
t
ext
;
m_mode
=
InsertMode
;
m_mode
=
InsertMode
;
m_submode
=
NoSubMode
;
m_submode
=
NoSubMode
;
}
else
if
(
m_submode
==
DeleteSubMode
)
{
}
else
if
(
m_submode
==
DeleteSubMode
)
{
if
(
!
dotCommand
.
isEmpty
())
if
(
!
dotCommand
.
isEmpty
())
m_dotCommand
=
"d"
+
dotCommand
;
m_dotCommand
=
"d"
+
dotCommand
;
recordRemove
(
qMin
(
m_tc
.
position
(),
m_tc
.
anchor
()),
m_tc
.
selectedText
());
m_registers
[
m_register
]
=
recordRemoveSelectedText
();
m_registers
[
m_register
]
=
m_tc
.
selectedText
();
recordEndGroup
();
recordRemoveSelectedText
();
m_submode
=
NoSubMode
;
m_submode
=
NoSubMode
;
if
(
atEol
())
if
(
atEol
())
moveLeft
(
MoveAnchor
);
moveLeft
(
MoveAnchor
);
...
@@ -594,26 +605,31 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
...
@@ -594,26 +605,31 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_register
=
key
;
m_register
=
key
;
m_submode
=
NoSubMode
;
m_submode
=
NoSubMode
;
}
else
if
(
m_submode
==
ChangeSubMode
&&
key
==
'c'
)
{
}
else
if
(
m_submode
==
ChangeSubMode
&&
key
==
'c'
)
{
moveToStartOfLine
(
MoveAnchor
);
moveToStartOfLine
();
moveDown
(
KeepAnchor
,
count
());
setAnchor
();
m_registers
[
m_register
]
=
m_tc
.
selectedText
();
moveDown
(
count
());
moveLeft
();
QString
text
=
recordRemoveSelectedText
();
m_registers
[
m_register
]
=
text
;
m_submode
=
NoSubMode
;
m_mode
=
InsertMode
;
finishMovement
(
"c"
);
finishMovement
(
"c"
);
}
else
if
(
m_submode
==
DeleteSubMode
&&
key
==
'd'
)
{
}
else
if
(
m_submode
==
DeleteSubMode
&&
key
==
'd'
)
{
moveToStartOfLine
(
MoveAnchor
);
moveToStartOfLine
();
moveDown
(
KeepAnchor
,
count
());
moveDown
(
count
());
m_registers
[
m_register
]
=
m_tc
.
s
electedText
();
m_registers
[
m_register
]
=
recordRemoveS
electedText
();
finishMovement
(
"d"
);
finishMovement
(
"d"
);
}
else
if
(
m_submode
==
YankSubMode
&&
key
==
'y'
)
{
}
else
if
(
m_submode
==
YankSubMode
&&
key
==
'y'
)
{
moveToStartOfLine
(
MoveAnchor
);
moveToStartOfLine
();
moveDown
(
KeepAnchor
,
count
());
moveDown
(
count
());
m_registers
[
m_register
]
=
m_tc
.
selectedText
();
m_registers
[
m_register
]
=
selectedText
();
finishMovement
();
finishMovement
();
}
else
if
(
m_submode
==
ReplaceSubMode
)
{
}
else
if
(
m_submode
==
ReplaceSubMode
)
{
if
(
atEol
())
if
(
atEol
())
moveLeft
(
KeepAnchor
);
moveLeft
(
KeepAnchor
);
else
else
m_tc
.
deleteChar
();
m_tc
.
deleteChar
();
m_tc
.
i
nsertText
(
text
);
recordI
nsertText
(
text
);
}
else
if
(
m_submode
==
IndentSubMode
&&
key
==
'='
)
{
}
else
if
(
m_submode
==
IndentSubMode
&&
key
==
'='
)
{
indentRegion
(
m_tc
.
block
(),
m_tc
.
block
().
next
());
indentRegion
(
m_tc
.
block
(),
m_tc
.
block
().
next
());
finishMovement
();
finishMovement
();
...
@@ -679,8 +695,9 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
...
@@ -679,8 +695,9 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
}
else
if
(
key
==
'\''
)
{
}
else
if
(
key
==
'\''
)
{
m_subsubmode
=
TickSubSubMode
;
m_subsubmode
=
TickSubSubMode
;
}
else
if
(
key
==
'|'
)
{
}
else
if
(
key
==
'|'
)
{
moveToStartOfLine
(
KeepAnchor
);
setAnchor
();
moveRight
(
KeepAnchor
,
qMin
(
count
(),
rightDist
())
-
1
);
moveToStartOfLine
();
moveRight
(
qMin
(
count
(),
rightDist
())
-
1
);
finishMovement
();
finishMovement
();
}
else
if
(
key
==
'!'
&&
m_visualMode
==
NoVisualMode
)
{
}
else
if
(
key
==
'!'
&&
m_visualMode
==
NoVisualMode
)
{
m_submode
=
FilterSubMode
;
m_submode
=
FilterSubMode
;
...
@@ -693,16 +710,16 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
...
@@ -693,16 +710,16 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
}
else
if
(
key
==
'"'
)
{
}
else
if
(
key
==
'"'
)
{
m_submode
=
RegisterSubMode
;
m_submode
=
RegisterSubMode
;
}
else
if
(
unmodified
==
Key_Return
)
{
}
else
if
(
unmodified
==
Key_Return
)
{
moveToStartOfLine
(
MoveAnchor
);
moveToStartOfLine
();
moveDown
(
MoveAnchor
);
moveDown
();
moveToFirstNonBlankOnLine
();
moveToFirstNonBlankOnLine
();
finishMovement
();
finishMovement
();
}
else
if
(
key
==
Key_Home
)
{
}
else
if
(
key
==
Key_Home
)
{
m
_tc
.
movePosition
(
StartOfLine
,
KeepAnchor
);
m
oveToStartOfLine
(
);
finishMovement
();
finishMovement
();
}
else
if
(
key
==
'$'
||
key
==
Key_End
)
{
}
else
if
(
key
==
'$'
||
key
==
Key_End
)
{
int
submode
=
m_submode
;
int
submode
=
m_submode
;
moveToEndOfLine
(
KeepAnchor
);
moveToEndOfLine
();
finishMovement
();
finishMovement
();
if
(
submode
==
NoSubMode
)
if
(
submode
==
NoSubMode
)
m_desiredColumn
=
-
1
;
m_desiredColumn
=
-
1
;
...
@@ -722,12 +739,14 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
...
@@ -722,12 +739,14 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
finishMovement
();
finishMovement
();
}
else
if
(
key
==
'a'
)
{
}
else
if
(
key
==
'a'
)
{
m_mode
=
InsertMode
;
m_mode
=
InsertMode
;
recordBeginGroup
();
m_lastInsertion
.
clear
();
m_lastInsertion
.
clear
();
m
_tc
.
movePosition
(
Right
,
MoveAnchor
,
1
);
m
oveRight
(
);
updateMiniBuffer
();
updateMiniBuffer
();
}
else
if
(
key
==
'A'
)
{
}
else
if
(
key
==
'A'
)
{
m_mode
=
InsertMode
;
m_mode
=
InsertMode
;
moveToEndOfLine
(
MoveAnchor
);
moveToEndOfLine
();
recordBeginGroup
();
m_lastInsertion
.
clear
();
m_lastInsertion
.
clear
();
}
else
if
(
key
==
'b'
)
{
}
else
if
(
key
==
'b'
)
{
moveToWordBoundary
(
false
,
false
);
moveToWordBoundary
(
false
,
false
);
...
@@ -736,27 +755,37 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
...
@@ -736,27 +755,37 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
moveToWordBoundary
(
true
,
false
);
moveToWordBoundary
(
true
,
false
);
finishMovement
();
finishMovement
();
}
else
if
(
key
==
'c'
)
{
}
else
if
(
key
==
'c'
)
{
setAnchor
();
recordBeginGroup
();
m_submode
=
ChangeSubMode
;
m_submode
=
ChangeSubMode
;
}
else
if
(
key
==
'C'
)
{
}
else
if
(
key
==
'C'
)
{
m_submode
=
ChangeSubMode
;
setAnchor
();
moveToEndOfLine
(
KeepAnchor
);
recordBeginGroup
();
moveToEndOfLine
();
m_registers
[
m_register
]
=
recordRemoveSelectedText
();
m_mode
=
InsertMode
;
finishMovement
();
finishMovement
();
}
else
if
(
key
==
'd'
&&
m_visualMode
==
NoVisualMode
)
{
}
else
if
(
key
==
'd'
&&
m_visualMode
==
NoVisualMode
)
{
if
(
atEol
())
if
(
atEol
())
moveLeft
(
MoveAnchor
);
moveLeft
();
setAnchor
();
recordBeginGroup
();
m_opcount
=
m_mvcount
;
m_opcount
=
m_mvcount
;
m_mvcount
.
clear
();
m_mvcount
.
clear
();
m_submode
=
DeleteSubMode
;
m_submode
=
DeleteSubMode
;
}
else
if
(
key
==
'd'
)
{
}
else
if
(
key
==
'd'
)
{
setAnchor
();
leaveVisualMode
();
leaveVisualMode
();
int
beginLine
=
lineForPosition
(
m_marks
[
'<'
]);
int
beginLine
=
lineForPosition
(
m_marks
[
'<'
]);
int
endLine
=
lineForPosition
(
m_marks
[
'>'
]);
int
endLine
=
lineForPosition
(
m_marks
[
'>'
]);
m_tc
=
selectRange
(
beginLine
,
endLine
);
selectRange
(
beginLine
,
endLine
);
recordRemoveSelectedText
();
recordRemoveSelectedText
();
}
else
if
(
key
==
'D'
)
{
}
else
if
(
key
==
'D'
)
{
setAnchor
();
recordBeginGroup
();
m_submode
=
DeleteSubMode
;
m_submode
=
DeleteSubMode
;
moveDown
(
KeepAnchor
,
qMax
(
count
()
-
1
,
0
));
moveDown
(
qMax
(
count
()
-
1
,
0
));
moveRight
(
KeepAnchor
,
rightDist
());
moveRight
(
rightDist
());
finishMovement
();
finishMovement
();
}
else
if
(
key
==
'e'
)
{
}
else
if
(
key
==
'e'
)
{
moveToWordBoundary
(
false
,
true
);
moveToWordBoundary
(
false
,
true
);
...
@@ -775,15 +804,16 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
...
@@ -775,15 +804,16 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
if
(
m_config
[
ConfigStartOfLine
]
==
ConfigOn
)
if
(
m_config
[
ConfigStartOfLine
]
==
ConfigOn
)
moveToFirstNonBlankOnLine
();
moveToFirstNonBlankOnLine
();
finishMovement
();
finishMovement
();
}
else
if
(
key
==
'h'
||
key
==
Key_Left
)
{
}
else
if
(
key
==
'h'
||
key
==
Key_Left
||
key
==
Key_Backspace
||
key
==
control
(
'h'
))
{
int
n
=
qMin
(
count
(),
leftDist
());
int
n
=
qMin
(
count
(),
leftDist
());
if
(
m_fakeEnd
&&
m_tc
.
block
().
length
()
>
1
)
if
(
m_fakeEnd
&&
m_tc
.
block
().
length
()
>
1
)
++
n
;
++
n
;
moveLeft
(
KeepAnchor
,
n
);
moveLeft
(
n
);
finishMovement
();
finishMovement
();
}
else
if
(
key
==
'H'
)
{
}
else
if
(
key
==
'H'
)
{
m_tc
=
EDITOR
(
cursorForPosition
(
QPoint
(
0
,
0
)));
m_tc
=
EDITOR
(
cursorForPosition
(
QPoint
(
0
,
0
)));
moveDown
(
KeepAnchor
,
qMax
(
count
()
-
1
,
0
));
moveDown
(
qMax
(
count
()
-
1
,
0
));
moveToFirstNonBlankOnLine
();
moveToFirstNonBlankOnLine
();
finishMovement
();
finishMovement
();
}
else
if
(
key
==
'i'
)
{
}
else
if
(
key
==
'i'
)
{
...
@@ -792,20 +822,21 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
...
@@ -792,20 +822,21 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
if
(
atEol
())
if
(
atEol
())
moveLeft
(
MoveAnchor
);
moveLeft
(
MoveAnchor
);
}
else
if
(
key
==
'I'
)
{
}
else
if
(
key
==
'I'
)
{
setAnchor
();
enterInsertMode
();
enterInsertMode
();
if
(
m_gflag
)
if
(
m_gflag
)
moveToStartOfLine
(
KeepAnchor
);
moveToStartOfLine
();
else
else
moveToFirstNonBlankOnLine
();
moveToFirstNonBlankOnLine
();
}
else
if
(
key
==
'j'
||
key
==
Key_Down
)
{
}
else
if
(
key
==
'j'
||
key
==
Key_Down
)
{
int
savedColumn
=
m_desiredColumn
;
int
savedColumn
=
m_desiredColumn
;
if
(
m_submode
==
NoSubMode
||
m_submode
==
ZSubMode
if
(
m_submode
==
NoSubMode
||
m_submode
==
ZSubMode
||
m_submode
==
RegisterSubMode
)
{
||
m_submode
==
RegisterSubMode
)
{
moveDown
(
KeepAnchor
,
count
());
moveDown
(
count
());
moveToDesiredColumn
();
moveToDesiredColumn
();
}
else
{
}
else
{
moveToStartOfLine
(
MoveAnchor
);
moveToStartOfLine
();
moveDown
(
KeepAnchor
,
count
()
+
1
);
moveDown
(
count
()
+
1
);
}
}
finishMovement
();
finishMovement
();
m_desiredColumn
=
savedColumn
;
m_desiredColumn
=
savedColumn
;
...
@@ -813,33 +844,34 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
...
@@ -813,33 +844,34 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
recordBeginGroup
();
recordBeginGroup
();
if
(
m_submode
==
NoSubMode
)
{
if
(
m_submode
==
NoSubMode
)
{
for
(
int
i
=
qMax
(
count
(),
2
)
-
1
;
--
i
>=
0
;
)
{
for
(
int
i
=
qMax
(
count
(),
2
)
-
1
;
--
i
>=
0
;
)
{
moveToEndOfLine
(
MoveAnchor
);
moveToEndOfLine
();
recordRemoveNextChar
();
recordRemoveNextChar
();
if
(
!
m_gflag
)
if
(
!
m_gflag
)
recordInsertText
(
" "
);
recordInsertText
(
" "
);
}
}
if
(
!
m_gflag
)
if
(
!
m_gflag
)
moveLeft
(
MoveAnchor
,
1
);
moveLeft
();
}
}
recordEndGroup
();
recordEndGroup
();
}
else
if
(
key
==
'k'
||
key
==
Key_Up
)
{
}
else
if
(
key
==
'k'
||
key
==
Key_Up
)
{
int
savedColumn
=
m_desiredColumn
;
int
savedColumn
=
m_desiredColumn
;
if
(
m_submode
==
NoSubMode
||
m_submode
==
ZSubMode
||
m_submode
==
RegisterSubMode
)
{
if
(
m_submode
==
NoSubMode
||
m_submode
==
ZSubMode
moveUp
(
KeepAnchor
,
count
());
||
m_submode
==
RegisterSubMode
)
{
moveUp
(
count
());
moveToDesiredColumn
();
moveToDesiredColumn
();
}
else
{
}
else
{
moveToStartOfLine
(
MoveAnchor
);
moveToStartOfLine
();
moveDown
(
MoveAnchor
);
moveDown
();
moveUp
(
KeepAnchor
,
count
()
+
1
);
moveUp
(
count
()
+
1
);
}
}
finishMovement
();
finishMovement
();
m_desiredColumn
=
savedColumn
;
m_desiredColumn
=
savedColumn
;
}
else
if
(
key
==
'l'
||
key
==
Key_Right
)
{
}
else
if
(
key
==
'l'
||
key
==
Key_Right
)
{
moveRight
(
KeepAnchor
,
qMin
(
count
(),
rightDist
()));
moveRight
(
qMin
(
count
(),
rightDist
()));
finishMovement
();
finishMovement
();
}
else
if
(
key
==
'L'
)
{
}
else
if
(
key
==
'L'
)
{
m_tc
=
EDITOR
(
cursorForPosition
(
QPoint
(
0
,
EDITOR
(
height
()))));
m_tc
=
EDITOR
(
cursorForPosition
(
QPoint
(
0
,
EDITOR
(
height
()))));
moveUp
(
KeepAnchor
,
qMax
(
count
(),
1
));
moveUp
(
qMax
(
count
(),
1
));
moveToFirstNonBlankOnLine
();
moveToFirstNonBlankOnLine
();
finishMovement
();
finishMovement
();
}
else
if
(
key
==
'm'
)
{
}
else
if
(
key
==
'm'
)
{
...
@@ -855,45 +887,52 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
...
@@ -855,45 +887,52 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
}
else
if
(
key
==
'o'
||
key
==
'O'
)
{
}
else
if
(
key
==
'o'
||
key
==
'O'
)
{
enterInsertMode
();
enterInsertMode
();
moveToFirstNonBlankOnLine
();
moveToFirstNonBlankOnLine
();
recordBeginGroup
();
int
numSpaces
=
leftDist
();
int
numSpaces
=
leftDist
();
moveUp
(
MoveAnchor
,
1
);
moveUp
();
if
(
key
==
'o'
)
if
(
key
==
'o'
)
m
_tc
.
movePosition
(
Down
,
MoveAnchor
,
1
);
m
oveDown
(
);
moveToEndOfLine
(
MoveAnchor
);
moveToEndOfLine
();
m_tc
.
i
nsertText
(
"
\n
"
);
recordI
nsertText
(
"
\n
"
);
moveToStartOfLine
(
MoveAnchor
);
moveToStartOfLine
();
if
(
m_config
[
ConfigAutoIndent
]
==
ConfigOn
)
if
(
m_config
[
ConfigAutoIndent
]
==
ConfigOn
)
m_tc
.
i
nsertText
(
QString
(
indentDist
(),
' '
));
recordI
nsertText
(
QString
(
indentDist
(),
' '
));
else
else
m_tc
.
insertText
(
QString
(
numSpaces
,
' '
));
recordInsertText
(
QString
(
numSpaces
,
' '
));
recordEndGroup
();
}
else
if
(
key
==
'p'
||
key
==
'P'
)
{
}
else
if
(
key
==
'p'
||
key
==
'P'
)
{
recordBeginGroup
();
QString
text
=
m_registers
[
m_register
];
QString
text
=
m_registers
[
m_register
];
int
n
=
text
.
count
(
QChar
(
ParagraphSeparator
));
int
n
=
text
.
count
(
QChar
(
ParagraphSeparator
));
if
(
n
>
0
)
{
if
(
n
>
0
)
{
m
_tc
.
movePosition
(
StartOfLine
);
m
oveTo
StartOfLine
(
);
if
(
key
==
'p'
)
if
(
key
==
'p'
)
m
_tc
.
movePosition
(
Down
);
m
oveDown
(
MoveAnchor
);
m_tc
.
i
nsertText
(
text
);
recordI
nsertText
(
text
);
m
_tc
.
movePosition
(
Up
,
MoveAnchor
,
n
);
m
oveUp
(
n
);
}
else
{
}
else
{
if
(
key
==
'p'
)
if
(
key
==
'p'
)
m
_tc
.
movePosition
(
Right
);
m
ove
Right
(
);
m_tc
.
i
nsertText
(
text
);
recordI
nsertText
(
text
);
m
_tc
.
movePosition
(
Left
);
m
ove
Left
(
);
}
}
recordEndGroup
();
m_dotCommand
=
"p"
;
m_dotCommand
=
"p"
;
}
else
if
(
key
==
'r'
)
{
}
else
if
(
key
==
'r'
)
{
recordBeginGroup
();
m_submode
=
ReplaceSubMode
;
m_submode
=
ReplaceSubMode
;
m_dotCommand
=
"r"
;
m_dotCommand
=
"r"
;
}
else
if
(
key
==
'R'
)
{
}
else
if
(
key
==
'R'
)
{
recordBeginGroup
();
m_mode
=
InsertMode
;
m_mode
=
InsertMode
;
m_submode
=
ReplaceSubMode
;
m_submode
=
ReplaceSubMode
;
m_dotCommand
=
"R"
;
m_dotCommand
=
"R"
;
}
else
if
(
key
==
control
(
'r'
))
{
}
else
if
(
key
==
control
(
'r'
))
{
redo
();
redo
();
}
else
if
(
key
==
's'
)
{
}
else
if
(
key
==
's'
)
{
recordBeginGroup
();
m_submode
=
ChangeSubMode
;
m_submode
=
ChangeSubMode
;
m
_tc
.
movePosition
(
Right
,
KeepAnchor
,
qMin
(
count
(),
rightDist
()));
m
oveRight
(
qMin
(
count
(),
rightDist
()));
}
else
if
(
key
==
't'
||
key
==
'T'
)
{
}
else
if
(
key
==
't'
||
key
==
'T'
)
{
m_subsubmode
=
FtSubSubMode
;
m_subsubmode
=
FtSubSubMode
;
m_subsubdata
=
key
;
m_subsubdata
=
key
;
...
@@ -918,38 +957,42 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
...
@@ -918,38 +957,42 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
}
else
if
(
key
==
'x'
)
{
// = "dl"
}
else
if
(
key
==
'x'
)
{
// = "dl"
if
(
atEol
())
if
(
atEol
())
moveLeft
(
MoveAnchor
);
moveLeft
(
MoveAnchor
);
recordBeginGroup
();
m_submode
=
DeleteSubMode
;
m_submode
=
DeleteSubMode
;
moveRight
(
KeepAnchor
,
qMin
(
count
(),
rightDist
()));
moveRight
(
qMin
(
count
(),
rightDist
()));
finishMovement
(
"l"
);
finishMovement
(
"l"
);
}
else
if
(
key
==
'X'
)
{
}
else
if
(
key
==
'X'
)
{
if
(
leftDist
()
>
0
)
{
if
(
leftDist
()
>
0
)
{
moveLeft
(
KeepAnchor
,
qMin
(
count
(),
leftDist
()));
setAnchor
();
m_tc
.
deleteChar
();
moveLeft
(
qMin
(
count
(),
leftDist
()));
recordRemoveSelectedText
();
}
}
finishMovement
();
finishMovement
();
}
else
if
(
key
==
'y'
)
{
}
else
if
(
key
==
'y'
)
{
if
(
atEol
())
if
(
atEol
())
moveLeft
(
MoveAnchor
);
moveLeft
();
recordBeginGroup
();
m_submode
=
YankSubMode
;
m_submode
=
YankSubMode
;
}
else
if
(
key
==
'z'
)
{
}
else
if
(
key
==
'z'
)
{
recordBeginGroup
();
m_submode
=
ZSubMode
;
m_submode
=
ZSubMode
;
}
else
if
(
key
==
'~'
&&
!
atEol
())
{
}
else
if
(
key
==
'~'
&&
!
atEol
())
{
moveRight
(
KeepAnchor
,
qMin
(
count
(),
rightDist
()));
recordBeginGroup
();
QString
str
=
m_tc
.
selectedText
();
setAnchor
();
moveRight
(
qMin
(
count
(),
rightDist
()));
QString
str
=
recordRemoveSelectedText
();
for
(
int
i
=
str
.
size
();
--
i
>=
0
;
)
{
for
(
int
i
=
str
.
size
();
--
i
>=
0
;
)
{
QChar
c
=
str
.
at
(
i
);
QChar
c
=
str
.
at
(
i
);
str
[
i
]
=
c
.
isUpper
()
?
c
.
toLower
()
:
c
.
toUpper
();
str
[
i
]
=
c
.
isUpper
()
?
c
.
toLower
()
:
c
.
toUpper
();
}
}
m_tc
.
deleteChar
(
);
recordInsertText
(
str
);
m_tc
.
insertText
(
str
);
recordEndGroup
(
);
}
else
if
(
key
==
Key_PageDown
||
key
==
control
(
'f'
))
{
}
else
if
(
key
==
Key_PageDown
||
key
==
control
(
'f'
))
{
moveDown
(
KeepAnchor
,
count
()
*
(
linesOnScreen
()
-
2
));
moveDown
(
count
()
*
(
linesOnScreen
()
-
2
));
finishMovement
();
finishMovement
();
}
else
if
(
key
==
Key_PageUp
||
key
==
control
(
'b'
))
{
}
else
if
(
key
==
Key_PageUp
||
key
==
control
(
'b'
))
{
moveUp
(
KeepAnchor
,
count
()
*
(
linesOnScreen
()
-
2
));
moveUp
(
count
()
*
(
linesOnScreen
()
-
2
));
finishMovement
();
finishMovement
();
}
else
if
(
key
==
Key_Backspace
||
key
==
control
(
'h'
))
{
m_tc
.
deletePreviousChar
();
}
else
if
(
key
==
Key_Delete
)
{
}
else
if
(
key
==
Key_Delete
)
{
m_tc
.
deleteChar
();
m_tc
.
deleteChar
();
}
else
if
(
key
==
Key_Escape
)
{
}
else
if
(
key
==
Key_Escape
)
{
...
@@ -975,21 +1018,23 @@ bool FakeVimHandler::Private::handleInsertMode(int key, int, const QString &text
...
@@ -975,21 +1018,23 @@ bool FakeVimHandler::Private::handleInsertMode(int key, int, const QString &text
data
+=
m_lastInsertion
;
data
+=
m_lastInsertion
;
}
}
recordInsert
(
m_tc
.
position
()
-
m_lastInsertion
.
size
(),
data
);
recordInsert
(
m_tc
.
position
()
-
m_lastInsertion
.
size
(),
data
);
moveLeft
(
MoveAnchor
,
qMin
(
1
,
leftDist
()));
recordEndGroup
();
//qDebug() << "UNDO: " << m_undoStack;
moveLeft
(
qMin
(
1
,
leftDist
()));
enterCommandMode
();
enterCommandMode
();
}
else
if
(
key
==
Key_Left
)
{
}
else
if
(
key
==
Key_Left
)
{
moveLeft
(
MoveAnchor
,
count
());
moveLeft
(
count
());
m_lastInsertion
.
clear
();
m_lastInsertion
.
clear
();
}
else
if
(
key
==
Key_Down
)
{
}
else
if
(
key
==
Key_Down
)
{
m_submode
=
NoSubMode
;
m_submode
=
NoSubMode
;
moveDown
(
MoveAnchor
,
count
());
moveDown
(
count
());
m_lastInsertion
.
clear
();
m_lastInsertion
.
clear
();
}
else
if
(
key
==
Key_Up
)
{
}
else
if
(
key
==
Key_Up
)
{
m_submode
=
NoSubMode
;
m_submode
=
NoSubMode
;
moveUp
(
MoveAnchor
,
count
());
moveUp
(
count
());
m_lastInsertion
.
clear
();
m_lastInsertion
.
clear
();
}
else
if
(
key
==
Key_Right
)
{
}
else
if
(
key
==
Key_Right
)
{
moveRight
(
MoveAnchor
,
count
());
moveRight
(
count
());
m_lastInsertion
.
clear
();
m_lastInsertion
.
clear
();
}
else
if
(
key
==
Key_Return
)
{
}
else
if
(
key
==
Key_Return
)
{
m_submode
=
NoSubMode
;
m_submode
=
NoSubMode
;
...
@@ -1003,10 +1048,10 @@ bool FakeVimHandler::Private::handleInsertMode(int key, int, const QString &text
...
@@ -1003,10 +1048,10 @@ bool FakeVimHandler::Private::handleInsertMode(int key, int, const QString &text
m_tc
.
deleteChar
();
m_tc
.
deleteChar
();
m_lastInsertion
.
clear
();
m_lastInsertion
.
clear
();
}
else
if
(
key
==
Key_PageDown
||
key
==
control
(
'f'
))
{
}
else
if
(
key
==
Key_PageDown
||
key
==
control
(
'f'
))
{
moveDown
(
KeepAnchor
,
count
()
*
(
linesOnScreen
()
-
2
));
moveDown
(
count
()
*
(
linesOnScreen
()
-
2
));
m_lastInsertion
.
clear
();
m_lastInsertion
.
clear
();
}
else
if
(
key
==
Key_PageUp
||
key
==
control
(
'b'
))
{
}
else
if
(
key
==
Key_PageUp
||
key
==
control
(
'b'
))
{
moveUp
(
KeepAnchor
,
count
()
*
(
linesOnScreen
()
-
2
));
moveUp
(
count
()
*
(
linesOnScreen
()
-
2
));
m_lastInsertion
.
clear
();
m_lastInsertion
.
clear
();
}
else
if
(
key
==
Key_Tab
&&
m_config
[
ConfigExpandTab
]
==
ConfigOn
)
{
}
else
if
(
key
==
Key_Tab
&&
m_config
[
ConfigExpandTab
]
==
ConfigOn
)
{
QString
str
=
QString
(
m_config
[
ConfigTabStop
].
toInt
(),
' '
);
QString
str
=
QString
(
m_config
[
ConfigTabStop
].
toInt
(),
' '
);
...
@@ -1173,17 +1218,15 @@ int FakeVimHandler::Private::readLineCode(QString &cmd)
...
@@ -1173,17 +1218,15 @@ int FakeVimHandler::Private::readLineCode(QString &cmd)
return
-
1
;
return
-
1
;
}
}
QTextCursor
FakeVimHandler
::
Private
::
selectRange
(
int
beginLine
,
int
endLine
)
void
FakeVimHandler
::
Private
::
selectRange
(
int
beginLine
,
int
endLine
)
{
{
QTextCursor
tc
=
m_tc
;
m_tc
.
setPosition
(
positionForLine
(
beginLine
),
MoveAnchor
);
tc
.
setPosition
(
positionForLine
(
beginLine
),
MoveAnchor
);
if
(
endLine
==
linesInDocument
())
{
if
(
endLine
==
linesInDocument
())
{
tc
.
setPosition
(
positionForLine
(
endLine
),
KeepAnchor
);
m_
tc
.
setPosition
(
positionForLine
(
endLine
),
KeepAnchor
);
tc
.
movePosition
(
EndOfLine
,
KeepAnchor
);
m_
tc
.
movePosition
(
EndOfLine
,
KeepAnchor
);
}
else
{
}
else
{
tc
.
setPosition
(
positionForLine
(
endLine
+
1
),
KeepAnchor
);
m_
tc
.
setPosition
(
positionForLine
(
endLine
+
1
),
KeepAnchor
);
}
}
return
tc
;
}
}
void
FakeVimHandler
::
Private
::
handleExCommand
(
const
QString
&
cmd0
)
void
FakeVimHandler
::
Private
::
handleExCommand
(
const
QString
&
cmd0
)
...
@@ -1223,11 +1266,11 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
...
@@ -1223,11 +1266,11 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
beginLine
=
cursorLineInDocument
();
beginLine
=
cursorLineInDocument
();
if
(
endLine
==
-
1
)
if
(
endLine
==
-
1
)
endLine
=
cursorLineInDocument
();
endLine
=
cursorLineInDocument
();
QTextCursor
tc
=
selectRange
(
beginLine
,
endLine
);
selectRange
(
beginLine
,
endLine
);
QString
reg
=
reDelete
.
cap
(
2
);
QString
reg
=
reDelete
.
cap
(
2
);
QString
text
=
recordRemoveSelectedText
();
if
(
!
reg
.
isEmpty
())
if
(
!
reg
.
isEmpty
())
m_registers
[
reg
.
at
(
0
).
unicode
()]
=
tc
.
selection
().
toPlainText
();
m_registers
[
reg
.
at
(
0
).
unicode
()]
=
text
;
tc
.
removeSelectedText
();
}
else
if
(
reWrite
.
indexIn
(
cmd
)
!=
-
1
)
{
// :w
}
else
if
(
reWrite
.
indexIn
(
cmd
)
!=
-
1
)
{
// :w
enterCommandMode
();
enterCommandMode
();
bool
noArgs
=
(
beginLine
==
-
1
);
bool
noArgs
=
(
beginLine
==
-
1
);
...
@@ -1245,9 +1288,8 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
...
@@ -1245,9 +1288,8 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
if
(
exists
&&
!
forced
&&
!
noArgs
)
{
if
(
exists
&&
!
forced
&&
!
noArgs
)
{
showRedMessage
(
tr
(
"File '%1' exists (add ! to override)"
).
arg
(
fileName
));
showRedMessage
(
tr
(
"File '%1' exists (add ! to override)"
).
arg
(
fileName
));
}
else
if
(
file
.
open
(
QIODevice
::
ReadWrite
))
{
}
else
if
(
file
.
open
(
QIODevice
::
ReadWrite
))
{
QTextCursor
tc
=
selectRange
(
beginLine
,
endLine
);
selectRange
(
beginLine
,
endLine
);
QString
contents
=
tc
.
selection
().
toPlainText
();
emit
q
->
writeFile
(
fileName
,
selectedText
());
emit
q
->
writeFile
(
fileName
,
contents
);
// check by reading back
// check by reading back
file
.
open
(
QIODevice
::
ReadOnly
);
file
.
open
(
QIODevice
::
ReadOnly
);
QByteArray
ba
=
file
.
readAll
();
QByteArray
ba
=
file
.
readAll
();
...
@@ -1272,10 +1314,10 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
...
@@ -1272,10 +1314,10 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
beginLine
=
cursorLineInDocument
();
beginLine
=
cursorLineInDocument
();
if
(
endLine
==
-
1
)
if
(
endLine
==
-
1
)
endLine
=
cursorLineInDocument
();
endLine
=
cursorLineInDocument
();
QTextCursor
tc
=
selectRange
(
beginLine
,
endLine
);
selectRange
(
beginLine
,
endLine
);
QString
text
=
tc
.
selection
().
toPlainText
();
tc
.
removeSelectedText
();
QString
command
=
cmd
.
mid
(
1
).
trimmed
();
QString
command
=
cmd
.
mid
(
1
).
trimmed
();
recordBeginGroup
();
QString
text
=
recordRemoveSelectedText
();
QProcess
proc
;
QProcess
proc
;
proc
.
start
(
cmd
.
mid
(
1
));
proc
.
start
(
cmd
.
mid
(
1
));
proc
.
waitForStarted
();
proc
.
waitForStarted
();
...
@@ -1283,7 +1325,8 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
...
@@ -1283,7 +1325,8 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
proc
.
closeWriteChannel
();
proc
.
closeWriteChannel
();
proc
.
waitForFinished
();
proc
.
waitForFinished
();
QString
result
=
QString
::
fromUtf8
(
proc
.
readAllStandardOutput
());
QString
result
=
QString
::
fromUtf8
(
proc
.
readAllStandardOutput
());
m_tc
.
insertText
(
result
);
recordInsertText
(
result
);
recordEndGroup
();
leaveVisualMode
();
leaveVisualMode
();
m_tc
.
setPosition
(
positionForLine
(
beginLine
));
m_tc
.
setPosition
(
positionForLine
(
beginLine
));
...
@@ -1357,8 +1400,6 @@ void FakeVimHandler::Private::search(const QString &needle0, bool forward)
...
@@ -1357,8 +1400,6 @@ void FakeVimHandler::Private::search(const QString &needle0, bool forward)
EDITOR
(
setTextCursor
(
m_tc
));
EDITOR
(
setTextCursor
(
m_tc
));
if
(
EDITOR
(
find
(
needle
,
flags
)))
{
if
(
EDITOR
(
find
(
needle
,
flags
)))
{
m_tc
=
EDITOR
(
textCursor
());
m_tc
=
EDITOR
(
textCursor
());
// the qMax seems to be needed for QPlainTextEdit only
//m_tc.movePosition(Left, MoveAnchor, qMax(1, needle.size() - 1));
m_tc
.
setPosition
(
m_tc
.
anchor
());
m_tc
.
setPosition
(
m_tc
.
anchor
());
return
;
return
;
}
}
...
@@ -1367,8 +1408,6 @@ void FakeVimHandler::Private::search(const QString &needle0, bool forward)
...
@@ -1367,8 +1408,6 @@ void FakeVimHandler::Private::search(const QString &needle0, bool forward)
EDITOR
(
setTextCursor
(
m_tc
));
EDITOR
(
setTextCursor
(
m_tc
));
if
(
EDITOR
(
find
(
needle
,
flags
)))
{
if
(
EDITOR
(
find
(
needle
,
flags
)))
{
m_tc
=
EDITOR
(
textCursor
());
m_tc
=
EDITOR
(
textCursor
());
// the qMax seems to be needed for QPlainTextEdit only
//m_tc.movePosition(Left, MoveAnchor, qMax(1, needle.size() - 1));
m_tc
.
setPosition
(
m_tc
.
anchor
());
m_tc
.
setPosition
(
m_tc
.
anchor
());
if
(
forward
)
if
(
forward
)
showRedMessage
(
"search hit BOTTOM, continuing at TOP"
);
showRedMessage
(
"search hit BOTTOM, continuing at TOP"
);
...
@@ -1643,6 +1682,13 @@ QString FakeVimHandler::Private::lastSearchString() const
...
@@ -1643,6 +1682,13 @@ QString FakeVimHandler::Private::lastSearchString() const
return
m_searchHistory
.
empty
()
?
QString
()
:
m_searchHistory
.
back
();
return
m_searchHistory
.
empty
()
?
QString
()
:
m_searchHistory
.
back
();
}
}
QString
FakeVimHandler
::
Private
::
selectedText
()
const
{
QTextCursor
tc
=
m_tc
;
tc
.
setPosition
(
m_anchor
,
KeepAnchor
);
return
tc
.
selection
().
toPlainText
();
}
int
FakeVimHandler
::
Private
::
positionForLine
(
int
line
)
const
int
FakeVimHandler
::
Private
::
positionForLine
(
int
line
)
const
{
{
return
m_tc
.
block
().
document
()
->
findBlockByNumber
(
line
-
1
).
position
();
return
m_tc
.
block
().
document
()
->
findBlockByNumber
(
line
-
1
).
position
();
...
@@ -1738,6 +1784,7 @@ void FakeVimHandler::Private::redo()
...
@@ -1738,6 +1784,7 @@ void FakeVimHandler::Private::redo()
void
FakeVimHandler
::
Private
::
recordBeginGroup
()
void
FakeVimHandler
::
Private
::
recordBeginGroup
()
{
{
//qDebug() << "PUSH";
m_undoGroupStack
.
push
(
m_undoStack
.
size
());
m_undoGroupStack
.
push
(
m_undoStack
.
size
());
}
}
...
@@ -1745,22 +1792,25 @@ void FakeVimHandler::Private::recordEndGroup()
...
@@ -1745,22 +1792,25 @@ void FakeVimHandler::Private::recordEndGroup()
{
{
EditOperation
op
;
EditOperation
op
;
op
.
m_itemCount
=
m_undoStack
.
size
()
-
m_undoGroupStack
.
pop
();
op
.
m_itemCount
=
m_undoStack
.
size
()
-
m_undoGroupStack
.
pop
();
//qDebug() << "POP " << op.m_itemCount;
recordOperation
(
op
);
recordOperation
(
op
);
}
}
void
FakeVimHandler
::
Private
::
recordRemoveSelectedText
()
QString
FakeVimHandler
::
Private
::
recordRemoveSelectedText
()
{
{
EditOperation
op
;
EditOperation
op
;
op
.
m_position
=
qMin
(
m_tc
.
position
(),
m_tc
.
anchor
());
m_tc
.
setPosition
(
anchor
(),
KeepAnchor
);
op
.
m_position
=
qMin
(
position
(),
anchor
());
op
.
m_from
=
m_tc
.
selection
().
toPlainText
();
op
.
m_from
=
m_tc
.
selection
().
toPlainText
();
recordOperation
(
op
);
recordOperation
(
op
);
m_tc
.
removeSelectedText
();
m_tc
.
removeSelectedText
();
return
op
.
m_from
;
}
}
void
FakeVimHandler
::
Private
::
recordRemoveNextChar
()
void
FakeVimHandler
::
Private
::
recordRemoveNextChar
()
{
{
m_
tc
.
setPosition
(
m_tc
.
position
(),
MoveAnchor
);
m_
anchor
=
position
();
m
_tc
.
movePosition
(
Right
,
KeepAnchor
);
m
oveRight
(
);
recordRemoveSelectedText
();
recordRemoveSelectedText
();
}
}
...
@@ -1775,6 +1825,7 @@ void FakeVimHandler::Private::recordInsertText(const QString &data)
...
@@ -1775,6 +1825,7 @@ void FakeVimHandler::Private::recordInsertText(const QString &data)
void
FakeVimHandler
::
Private
::
recordOperation
(
const
EditOperation
&
op
)
void
FakeVimHandler
::
Private
::
recordOperation
(
const
EditOperation
&
op
)
{
{
qDebug
()
<<
"OP: "
<<
op
;
m_undoStack
.
push
(
op
);
m_undoStack
.
push
(
op
);
m_redoStack
.
clear
();
m_redoStack
.
clear
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment