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;
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);