1
0
Fork 0
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:
jules 2012-07-24 15:45:44 +01:00
parent c2697bdce9
commit 87db662f29
17 changed files with 270 additions and 93 deletions

View file

@ -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;
}
}
}
}
}