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
Marco Bubke
flatpak-qt-creator
Commits
a5df2e7b
Commit
a5df2e7b
authored
Jan 19, 2010
by
mae
Browse files
backspace/delete handling for snippet editing
parent
60ad6c47
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/texteditor/basetexteditor.cpp
View file @
a5df2e7b
...
...
@@ -1184,6 +1184,10 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
return
;
}
if
(
d
->
m_snippetOverlay
->
isVisible
()
&&
(
e
->
key
()
==
Qt
::
Key_Delete
||
e
->
key
()
==
Qt
::
Key_Backspace
))
d
->
snippetCheckCursor
(
textCursor
());
if
(
ro
||
e
->
text
().
isEmpty
()
||
!
e
->
text
().
at
(
0
).
isPrint
())
{
QPlainTextEdit
::
keyPressEvent
(
e
);
}
else
if
((
e
->
modifiers
()
&
(
Qt
::
ControlModifier
|
Qt
::
AltModifier
))
!=
Qt
::
ControlModifier
){
...
...
@@ -1651,11 +1655,15 @@ void BaseTextEditorPrivate::setupDocumentSignals(BaseTextDocument *document)
void
BaseTextEditorPrivate
::
snippetCheckCursor
(
const
QTextCursor
&
cursor
)
{
if
(
cursor
.
hasSelection
())
return
;
if
(
!
m_snippetOverlay
->
isVisible
()
||
m_snippetOverlay
->
isEmpty
())
return
;
if
(
!
m_snippetOverlay
->
hasCursorInSelection
(
cursor
))
{
QTextCursor
start
=
cursor
;
start
.
setPosition
(
cursor
.
selectionStart
());
QTextCursor
end
=
cursor
;
end
.
setPosition
(
cursor
.
selectionEnd
());
if
(
!
m_snippetOverlay
->
hasCursorInSelection
(
start
)
||
!
m_snippetOverlay
->
hasCursorInSelection
(
end
))
{
m_snippetOverlay
->
setVisible
(
false
);
m_snippetOverlay
->
clear
();
}
...
...
@@ -3572,6 +3580,12 @@ void BaseTextEditor::handleBackspaceKey()
int
pos
=
cursor
.
position
();
QTC_ASSERT
(
!
cursor
.
hasSelection
(),
return
);
if
(
d
->
m_snippetOverlay
->
isVisible
())
{
QTextCursor
snippetCursor
=
cursor
;
snippetCursor
.
movePosition
(
QTextCursor
::
Left
);
d
->
snippetCheckCursor
(
snippetCursor
);
}
const
TextEditor
::
TabSettings
&
tabSettings
=
d
->
m_document
->
tabSettings
();
if
(
tabSettings
.
m_autoIndent
&&
autoBackspace
(
cursor
))
...
...
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