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
1f6c25a7
Commit
1f6c25a7
authored
Jan 19, 2010
by
mae
Browse files
snippet fixes
done with roberto
parent
76379a91
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/texteditor/basetexteditor.cpp
View file @
1f6c25a7
...
...
@@ -1178,7 +1178,13 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
}
}
if
(
e
->
key
()
==
Qt
::
Key_H
&&
e
->
modifiers
()
==
Qt
::
MetaModifier
)
{
if
(
e
->
key
()
==
Qt
::
Key_H
&&
e
->
modifiers
()
==
#ifdef Q_OS_DARWIN
Qt
::
MetaModifier
#else
Qt
::
ControlModifier
#endif
)
{
universalHelper
();
e
->
accept
();
return
;
...
...
@@ -1256,6 +1262,8 @@ void BaseTextEditor::universalHelper()
}
int
pos
=
0
;
QMap
<
int
,
int
>
positions
;
while
(
pos
<
snippet
.
size
())
{
if
(
snippet
.
at
(
pos
)
!=
QLatin1Char
(
'$'
))
{
const
int
start
=
pos
;
...
...
@@ -1278,22 +1286,34 @@ void BaseTextEditor::universalHelper()
int
cursorPosition
=
cursor
.
position
();
cursor
.
insertText
(
textToInsert
);
QTextCursor
tc
(
document
());
tc
.
setPosition
(
cursorPosition
-
1
);
tc
.
setPosition
(
cursorPosition
+
textToInsert
.
length
(),
QTextCursor
::
KeepAnchor
);
QTextEdit
::
ExtraSelection
selection
;
selection
.
cursor
=
tc
;
selection
.
format
.
setBackground
(
Qt
::
darkCyan
);
if
(
textToInsert
.
isEmpty
())
{
positions
.
insert
(
cursorPosition
,
0
);
}
else
{
positions
.
insert
(
cursorPosition
-
1
,
textToInsert
.
length
()
+
1
);
}
selections
.
append
(
selection
);
++
pos
;
}
}
cursor
.
endEditBlock
();
QMapIterator
<
int
,
int
>
it
(
positions
);
while
(
it
.
hasNext
())
{
it
.
next
();
int
length
=
it
.
value
();
int
position
=
it
.
key
();
QTextCursor
tc
(
document
());
tc
.
setPosition
(
position
);
tc
.
setPosition
(
position
+
length
,
QTextCursor
::
KeepAnchor
);
QTextEdit
::
ExtraSelection
selection
;
selection
.
cursor
=
tc
;
selection
.
format
.
setBackground
(
length
?
Qt
::
darkCyan
:
Qt
::
darkMagenta
);
selections
.
append
(
selection
);
}
cursor
.
setPosition
(
startCursorPosition
,
QTextCursor
::
KeepAnchor
);
indent
(
cursor
.
document
(),
cursor
,
QChar
());
cursor
.
endEditBlock
();
setExtraSelections
(
BaseTextEditor
::
SnippetPlaceholderSelection
,
selections
);
...
...
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