Commit 869c7770 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

JsonWizard: Allow for more control of line layout in templates

Expand "\n", "\\" and "\t" in the templates to a linebreak/single '\'
character/tab respectively. Also enable line continuation with a '\'
character followed by a line break.

This allows for nicer output from the templates, avoiding spurious
blank lines in places.

Change-Id: I224b49e799f306dcb8fb8aa8ab2ea52733aecfa4
Reviewed-by: default avatarDaniel Teske <>
Reviewed-by: default avatarTobias Hunger <>
parent 6568d9fb
...@@ -56,9 +56,32 @@ static QString processTextFileContents(Utils::AbstractMacroExpander *expander, ...@@ -56,9 +56,32 @@ static QString processTextFileContents(Utils::AbstractMacroExpander *expander,
if (input.isEmpty()) if (input.isEmpty())
return input; return input;
QString result; QString tmp;
if (!customWizardPreprocess(Utils::expandMacros(input, expander), &result, errorMessage)) if (!customWizardPreprocess(Utils::expandMacros(input, expander), &tmp, errorMessage))
return QString(); return QString();
// Expand \n, \t and handle line continuation:
QString result;
bool isEscaped = false;
for (int i = 0; i < tmp.count(); ++i) {
const QChar c =;
if (isEscaped) {
if (c == QLatin1Char('n'))
else if (c == QLatin1Char('t'))
else if (c != QLatin1Char('\n'))
isEscaped = false;
} else {
if (c == QLatin1Char('\\'))
isEscaped = true;
return result; return result;
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment