mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Improved the layout of ConsoleApplication::printHelp() when there are long items
This commit is contained in:
parent
b8bee51651
commit
097525ba5b
1 changed files with 15 additions and 4 deletions
|
|
@ -261,18 +261,29 @@ void ConsoleApplication::printHelp (const String& preamble, const ArgumentList&
|
|||
.fromLastOccurrenceOf ("\\", false, false);
|
||||
|
||||
StringArray namesAndArgs;
|
||||
int maxLength = 0;
|
||||
int descriptionIndent = 0;
|
||||
|
||||
for (auto& c : commands)
|
||||
{
|
||||
auto nameAndArgs = exeName + " " + c.argumentDescription;
|
||||
namesAndArgs.add (nameAndArgs);
|
||||
maxLength = std::max (maxLength, nameAndArgs.length());
|
||||
descriptionIndent = std::max (descriptionIndent, nameAndArgs.length());
|
||||
}
|
||||
|
||||
descriptionIndent = std::min (descriptionIndent + 1, 40);
|
||||
|
||||
for (size_t i = 0; i < commands.size(); ++i)
|
||||
std::cout << " " << namesAndArgs[(int) i].paddedRight (' ', maxLength + 2)
|
||||
<< commands[i].commandDescription << std::endl;
|
||||
{
|
||||
auto nameAndArgs = namesAndArgs[(int) i];
|
||||
std::cout << ' ';
|
||||
|
||||
if (nameAndArgs.length() > descriptionIndent)
|
||||
std::cout << nameAndArgs << std::endl << String::repeatedString (" ", descriptionIndent + 1);
|
||||
else
|
||||
std::cout << nameAndArgs.paddedRight (' ', descriptionIndent);
|
||||
|
||||
std::cout << commands[i].commandDescription << std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue