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
a575cb18
Commit
a575cb18
authored
Sep 16, 2009
by
mae
Browse files
implement backspace for auto parentheses mode
parent
9832cff1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/texteditor/basetexteditor.cpp
View file @
a575cb18
...
...
@@ -989,8 +989,7 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
}
break
;
case
Qt
::
Key_Backspace
:
if
(
ro
)
break
;
if
(
d
->
m_document
->
tabSettings
().
m_smartBackspace
&&
(
e
->
modifiers
()
&
(
Qt
::
ControlModifier
if
((
e
->
modifiers
()
&
(
Qt
::
ControlModifier
|
Qt
::
ShiftModifier
|
Qt
::
AltModifier
|
Qt
::
MetaModifier
))
==
Qt
::
NoModifier
...
...
@@ -3261,11 +3260,34 @@ void BaseTextEditor::handleHomeKey(bool anchor)
void
BaseTextEditor
::
handleBackspaceKey
()
{
QTextCursor
cursor
=
textCursor
();
int
pos
=
cursor
.
position
();
QTC_ASSERT
(
!
cursor
.
hasSelection
(),
return
);
const
TextEditor
::
TabSettings
&
tabSettings
=
d
->
m_document
->
tabSettings
();
if
(
tabSettings
.
m_autoParentheses
)
{
QChar
lookAhead
=
characterAt
(
pos
);
QChar
lookBehind
=
characterAt
(
pos
-
1
);
QChar
lookFurtherBehind
=
characterAt
(
pos
-
2
);
if
((
lookBehind
==
QLatin1Char
(
'('
)
&&
lookAhead
==
QLatin1Char
(
')'
))
||
(
lookBehind
==
QLatin1Char
(
'['
)
&&
lookAhead
==
QLatin1Char
(
']'
))
||
(
lookBehind
==
QLatin1Char
(
'"'
)
&&
lookAhead
==
QLatin1Char
(
'"'
)
&&
lookFurtherBehind
!=
QLatin1Char
(
'\\'
)))
{
cursor
.
beginEditBlock
();
cursor
.
deleteChar
();
cursor
.
deletePreviousChar
();
cursor
.
endEditBlock
();
return
;
}
}
if
(
!
tabSettings
.
m_smartBackspace
)
{
cursor
.
deletePreviousChar
();
return
;
}
QTextBlock
currentBlock
=
cursor
.
block
();
int
positionInBlock
=
cursor
.
position
()
-
currentBlock
.
position
();
int
positionInBlock
=
pos
-
currentBlock
.
position
();
const
QString
blockText
=
currentBlock
.
text
();
if
(
cursor
.
atBlockStart
()
||
tabSettings
.
firstNonSpace
(
blockText
)
<
positionInBlock
)
{
cursor
.
deletePreviousChar
();
...
...
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