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
554f4fe6
Commit
554f4fe6
authored
Sep 17, 2009
by
mae
Browse files
ensure visibility for extra blocks that are auto inserted
parent
061865ef
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppeditor.cpp
View file @
554f4fe6
...
...
@@ -1356,13 +1356,13 @@ bool CPPEditor::autoBackspace(QTextCursor &cursor)
return
false
;
}
void
CPPEditor
::
paragraphSeparatorAboutToBeInserted
(
QTextCursor
&
cursor
)
int
CPPEditor
::
paragraphSeparatorAboutToBeInserted
(
QTextCursor
&
cursor
)
{
if
(
characterAt
(
cursor
.
position
()
-
1
)
!=
QLatin1Char
(
'{'
))
return
;
return
0
;
if
(
!
contextAllowsAutoParentheses
(
cursor
))
return
;
return
0
;
// verify that we indeed do have an extra opening brace in the document
...
...
@@ -1387,7 +1387,9 @@ void CPPEditor::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
}
cursor
.
setPosition
(
pos
);
m_allowSkippingOfBlockEnd
=
true
;
return
1
;
}
return
0
;
}
bool
CPPEditor
::
contextAllowsAutoParentheses
(
const
QTextCursor
&
cursor
)
const
...
...
src/plugins/cppeditor/cppeditor.h
View file @
554f4fe6
...
...
@@ -215,7 +215,7 @@ protected:
bool
isElectricCharacter
(
const
QChar
&
ch
)
const
;
QString
autoComplete
(
QTextCursor
&
cursor
,
const
QString
&
text
)
const
;
bool
autoBackspace
(
QTextCursor
&
cursor
);
void
paragraphSeparatorAboutToBeInserted
(
QTextCursor
&
cursor
);
int
paragraphSeparatorAboutToBeInserted
(
QTextCursor
&
cursor
);
bool
contextAllowsAutoParentheses
(
const
QTextCursor
&
cursor
)
const
;
...
...
src/plugins/texteditor/basetexteditor.cpp
View file @
554f4fe6
...
...
@@ -890,7 +890,7 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
const
TabSettings
&
ts
=
d
->
m_document
->
tabSettings
();
cursor
.
beginEditBlock
();
paragraphSeparatorAboutToBeInserted
(
cursor
);
// virtual
int
extraBlocks
=
paragraphSeparatorAboutToBeInserted
(
cursor
);
// virtual
if
(
ts
.
m_autoIndent
)
{
cursor
.
insertBlock
();
...
...
@@ -902,6 +902,16 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
}
cursor
.
endEditBlock
();
e
->
accept
();
if
(
extraBlocks
>
0
)
{
QTextCursor
ensureVisible
=
cursor
;
while
(
extraBlocks
>
0
)
{
--
extraBlocks
;
ensureVisible
.
movePosition
(
QTextCursor
::
NextBlock
);
}
setTextCursor
(
ensureVisible
);
}
setTextCursor
(
cursor
);
return
;
}
else
if
(
!
ro
...
...
@@ -3279,9 +3289,10 @@ bool BaseTextEditor::autoBackspace(QTextCursor &cursor)
return
false
;
}
void
BaseTextEditor
::
paragraphSeparatorAboutToBeInserted
(
QTextCursor
&
cursor
)
int
BaseTextEditor
::
paragraphSeparatorAboutToBeInserted
(
QTextCursor
&
cursor
)
{
Q_UNUSED
(
cursor
)
Q_UNUSED
(
cursor
);
return
0
;
}
void
BaseTextEditor
::
indentBlock
(
QTextDocument
*
,
QTextBlock
,
QChar
)
...
...
src/plugins/texteditor/basetexteditor.h
View file @
554f4fe6
...
...
@@ -509,8 +509,8 @@ protected:
virtual
QString
autoComplete
(
QTextCursor
&
cursor
,
const
QString
&
text
)
const
;
// Handles backspace. When returning true, backspace processing is stopped
virtual
bool
autoBackspace
(
QTextCursor
&
cursor
);
// Hook to insert special characters on enter
virtual
void
paragraphSeparatorAboutToBeInserted
(
QTextCursor
&
cursor
);
// Hook to insert special characters on enter
. Returns the number of extra blocks inserted.
virtual
int
paragraphSeparatorAboutToBeInserted
(
QTextCursor
&
cursor
);
// Indent a text block based on previous line. Default does nothing
virtual
void
indentBlock
(
QTextDocument
*
doc
,
QTextBlock
block
,
QChar
typedChar
);
// Indent at cursor. Calls indentBlock for selection or current line.
...
...
Write
Preview
Markdown
is supported
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