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
Marco Bubke
flatpak-qt-creator
Commits
23a9971a
Commit
23a9971a
authored
Jan 28, 2009
by
Martin Aumueller
Browse files
fakevim: implement paren matching w/o making FakeVimHandler depend on Qt Creator's TextEditor
parent
1dc1a64e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/fakevimhandler.cpp
View file @
23a9971a
...
...
@@ -1846,6 +1846,16 @@ void FakeVimHandler::Private::moveToNextWord(bool simple)
void
FakeVimHandler
::
Private
::
moveToMatchingParanthesis
()
{
bool
moved
=
false
;
bool
forward
=
false
;
emit
q
->
moveToMatchingParenthesis
(
&
moved
,
&
forward
,
&
m_tc
);
if
(
moved
&&
forward
)
{
if
(
m_submode
==
NoSubMode
||
m_submode
==
ZSubMode
||
m_submode
==
RegisterSubMode
)
m_tc
.
movePosition
(
Left
,
KeepAnchor
,
1
);
}
#if 0
// FIXME: remove TextEditor dependency
bool undoFakeEOL = false;
...
...
src/plugins/fakevim/fakevimhandler.h
View file @
23a9971a
...
...
@@ -79,6 +79,7 @@ signals:
void
selectionChanged
(
const
QList
<
QTextEdit
::
ExtraSelection
>
&
selection
);
void
writeFileRequested
(
bool
*
handled
,
const
QString
&
fileName
,
const
QString
&
contents
);
void
moveToMatchingParenthesis
(
bool
*
moved
,
bool
*
forward
,
QTextCursor
*
cursor
);
private:
bool
eventFilter
(
QObject
*
ob
,
QEvent
*
ev
);
...
...
src/plugins/fakevim/fakevimplugin.cpp
View file @
23a9971a
...
...
@@ -122,6 +122,7 @@ private slots:
void
showExtraInformation
(
const
QString
&
msg
);
void
changeSelection
(
const
QList
<
QTextEdit
::
ExtraSelection
>
&
selections
);
void
writeFile
(
bool
*
handled
,
const
QString
&
fileName
,
const
QString
&
contents
);
void
moveToMatchingParenthesis
(
bool
*
moved
,
bool
*
forward
,
QTextCursor
*
cursor
);
private:
FakeVimPlugin
*
q
;
...
...
@@ -203,6 +204,8 @@ void FakeVimPluginPrivate::installHandler(Core::IEditor *editor)
this
,
SLOT
(
writeFile
(
bool
*
,
QString
,
QString
)));
connect
(
handler
,
SIGNAL
(
selectionChanged
(
QList
<
QTextEdit
::
ExtraSelection
>
)),
this
,
SLOT
(
changeSelection
(
QList
<
QTextEdit
::
ExtraSelection
>
)));
connect
(
handler
,
SIGNAL
(
moveToMatchingParenthesis
(
bool
*
,
bool
*
,
QTextCursor
*
)),
this
,
SLOT
(
moveToMatchingParenthesis
(
bool
*
,
bool
*
,
QTextCursor
*
)));
handler
->
setupWidget
();
handler
->
setExtraData
(
editor
);
...
...
@@ -250,6 +253,42 @@ void FakeVimPluginPrivate::writeFile(bool *handled,
}
}
void
FakeVimPluginPrivate
::
moveToMatchingParenthesis
(
bool
*
moved
,
bool
*
forward
,
QTextCursor
*
cursor
)
{
*
moved
=
false
;
bool
undoFakeEOL
=
false
;
if
(
cursor
->
atBlockEnd
()
&&
cursor
->
block
().
length
()
>
1
)
{
cursor
->
movePosition
(
QTextCursor
::
Left
,
QTextCursor
::
KeepAnchor
,
1
);
undoFakeEOL
=
true
;
}
TextEditor
::
TextBlockUserData
::
MatchType
match
=
TextEditor
::
TextBlockUserData
::
matchCursorForward
(
cursor
);
if
(
match
==
TextEditor
::
TextBlockUserData
::
Match
)
{
*
moved
=
true
;
*
forward
=
true
;
}
else
{
if
(
undoFakeEOL
)
cursor
->
movePosition
(
QTextCursor
::
Right
,
QTextCursor
::
KeepAnchor
,
1
);
if
(
match
==
TextEditor
::
TextBlockUserData
::
NoMatch
)
{
// backward matching is according to the character before the cursor
bool
undoMove
=
false
;
if
(
!
cursor
->
atBlockEnd
())
{
cursor
->
movePosition
(
QTextCursor
::
Right
,
QTextCursor
::
KeepAnchor
,
1
);
undoMove
=
true
;
}
match
=
TextEditor
::
TextBlockUserData
::
matchCursorBackward
(
cursor
);
if
(
match
==
TextEditor
::
TextBlockUserData
::
Match
)
{
*
moved
=
true
;
*
forward
=
false
;
}
else
if
(
undoMove
)
{
cursor
->
movePosition
(
QTextCursor
::
Left
,
QTextCursor
::
KeepAnchor
,
1
);
}
}
}
}
void
FakeVimPluginPrivate
::
removeHandler
()
{
if
(
FakeVimHandler
*
handler
=
qobject_cast
<
FakeVimHandler
*>
(
sender
()))
{
...
...
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