21static int MAX_LENGTH = -1;
22static int SectionMargin = 2;
24#define EXPANDER(COUNT, ITEM) QString(COUNT, ITEM).toStdString()
25#define SPACES(X) EXPANDER(X, ' ')
26#define SECTION_MARGIN SPACES(SectionMargin)
27#define WIDTH ((MAX_LENGTH > 10)? MAX_LENGTH: width())
37void print(
const QString& key,
const QString& value,
int keyLength) {
39 auto diffExpander = QString(keyLength - key.size(),
' ');
40 std::cout <<
SECTION_MARGIN << key.toStdString() << diffExpander.toStdString() <<
":";
42 QString expander(keyLength + SectionMargin,
' ');
43 auto words = value.split(
" ");
45 int currentLength = std::max(keyLength,
static_cast<int>(key.size()));
46 for (
const auto& word : words) {
47 if (currentLength + 2 + word.size() <
WIDTH) {
48 std::cout <<
" " << word.toStdString();
49 currentLength += 2 + word.size();
52 std::cout << std::endl << expander.toStdString() <<
":";
53 currentLength = keyLength;
55 std::cout <<
" " << word.toStdString();
56 currentLength += 2 + word.size();
63 for (
auto line = oprionsList.begin(); line != oprionsList.end(); ++line) {
64 if (line.key().size() > maxLength)
65 maxLength = line.key().size();
68 maxLength = std::min(
WIDTH / 3, maxLength);
70 for (
auto line = oprionsList.begin(); line != oprionsList.end(); ++line) {
71 print(line.key(), line.value(), maxLength + SectionMargin);
72 std::cout << std::endl;
77 for (
auto line = help.begin(); line != help.end(); ++line) {
78 QString expander(
WIDTH,
'-');
80 std::cout << line.key().toStdString() << std::endl;
81 std::cout << expander.toStdString() << std::endl;
83 std::cout << std::endl << expander.toStdString() << std::endl;
88 MAX_LENGTH = newLength;
94 CONSOLE_SCREEN_BUFFER_INFO csbi;
96 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
97 return csbi.srWindow.Right - csbi.srWindow.Left + 1;
100 ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
void setLineLength(int newLength)
setLineLength sets new length of the help line (width of the console window). If you set this into -1...
QMultiMap< QString, QString > Options
Options this is list of key-descriptions pairs of help. The key is name of the available argument and...
void print(const QString &key, const QString &value, int keyLength)
QMultiMap< QString, Options > Section
Section This is list of the help Sections. The one section it is Title of the section and Help::Optio...
int width()
width This method return current width of the cosole window.
The QuasaraAppUtils class This lib include base functions for the all applications of QuasarApp group...