mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-16 00:34:19 +00:00
Introjucer: code editor improvements, icon class reshuffle.
This commit is contained in:
parent
c2697bdce9
commit
87db662f29
17 changed files with 270 additions and 93 deletions
|
|
@ -232,25 +232,37 @@ void CppCodeEditorComponent::handleReturnKey()
|
|||
{
|
||||
CodeEditorComponent::handleReturnKey();
|
||||
|
||||
const CodeDocument::Position pos (getCaretPos());
|
||||
CodeDocument::Position pos (getCaretPos());
|
||||
|
||||
if (pos.getLineNumber() > 0 && pos.getLineText().trim().isEmpty())
|
||||
{
|
||||
String indent;
|
||||
CppUtils::getIndentForCurrentBlock (pos, indent);
|
||||
|
||||
const String previousLine (pos.movedByLines (-1).getLineText());
|
||||
const String trimmedPreviousLine (previousLine.trim());
|
||||
const String leadingWhitespace (CppUtils::getLeadingWhitespace (previousLine));
|
||||
|
||||
insertTextAtCaret (leadingWhitespace);
|
||||
|
||||
if (trimmedPreviousLine.endsWithChar ('{')
|
||||
|| ((trimmedPreviousLine.startsWith ("if ")
|
||||
|| trimmedPreviousLine.startsWith ("for ")
|
||||
|| trimmedPreviousLine.startsWith ("while "))
|
||||
&& trimmedPreviousLine.endsWithChar (')')))
|
||||
{
|
||||
const String leadingWhitespace (CppUtils::getLeadingWhitespace (previousLine));
|
||||
insertTextAtCaret (leadingWhitespace);
|
||||
insertTabAtCaret();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (pos.getLineNumber() > 0)
|
||||
{
|
||||
pos = pos.movedByLines (-1);
|
||||
const String leadingWhitespace (CppUtils::getLeadingWhitespace (pos.getLineText()));
|
||||
|
||||
if (leadingWhitespace.isNotEmpty())
|
||||
{
|
||||
insertTextAtCaret (leadingWhitespace);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue