61 inline std::string
padRight(
const std::string& text,
int width) {
62 int pad = width -
static_cast<int>(text.size());
63 return (pad > 0) ? text + std::string(pad,
' ') : text;
72 inline std::string
centerIn(
const std::string& text,
int width) {
73 int left = (width -
static_cast<int>(text.size())) / 2;
74 return (left > 0) ? std::string(left,
' ') + text : text;
91 inline std::string
center(
const std::string& text) {
102 DWORD len =
sizeof(buf);
103 if (GetComputerNameA(buf, &len))
return std::string(buf);
105 if (gethostname(buf,
sizeof(buf)) == 0)
return std::string(buf);
123 auto mid = [inner](
const std::string& t) {
return centerIn(t, inner); };
127 {mid(R
"( /\\ +)"), true},
128 {mid(R
"( / \\ )"), true},
129 {mid(R
"( / \\ )"), true},
130 {mid(R
"(/ \\ )"), true},
131 {mid(R
"(========= -)"), true},
132 {mid(
"deltaFlow v" + std::string(deltaFlow_VERSION)),
true},
134 {
" Copyright (c) 2024 Saud Zahir.",
false},
135 {
" All rights reserved.",
false},
137 {
" deltaFlow is free software: you can redistribute it",
false},
138 {
" and/or modify it under the terms of the GNU General",
false},
139 {
" Public License as published by the Free Software",
false},
140 {
" Foundation, either version 3 of the License, or",
false},
141 {
" (at your option) any later version.",
false},
143 {
" deltaFlow is distributed in the hope that it will be useful,",
false},
144 {
" but WITHOUT ANY WARRANTY; without even the implied warranty",
false},
145 {
" of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.",
false},
146 {
" See the GNU General Public License for more details.",
false},
148 {
" <https://www.gnu.org/licenses/>",
false},
167 constexpr fmt::rgb
INFO{100, 200, 255};
168 constexpr fmt::rgb VAL{255, 255, 100};
169 constexpr fmt::rgb DIM{180, 180, 180};
173 {
" deltaFlow -- Power Flow Analysis Software",
"",
LOGO_COLOR, {}},
174 {
" A Program for Steady-State Power System Analysis",
"", DIM, {}},
175 {
" Version : ", deltaFlow_VERSION,
INFO, VAL},
176 {
" CMake : ", CMake_VERSION,
INFO, VAL},
177 {
" GCC : ", gcc_VERSION,
INFO, VAL},
179 {
" Copyright (c) 2024 ",
"Saud Zahir", DIM, fmt::rgb{255, 165, 0}},
180 {
" Licensed under GNU GPL v3.0",
"", fmt::rgb{100,255,100},{}},
182 {
" Hostname : ",
hostname(),
INFO, fmt::rgb{255, 200, 100}},
193 std::string s = rule;
195 s +=
" *" +
padRight(line.text, inner) +
"*\n";
207 s +=
" " + std::string(inner,
'_') +
"\n";
209 s +=
" |" +
padRight(p.key + p.value, inner) +
"|\n";
210 s +=
" |" + std::string(inner,
'_') +
"|\n";
231 s +=
center(title) +
"\n";
232 s +=
center(std::string(title.size() + 4,
'-')) +
"\n";
246 s +=
" " + std::string(title.size() + 4,
'-') +
"\n";
247 s +=
" " + title +
"\n";
248 s +=
" " + std::string(title.size() + 4,
'-') +
"\n";
257 constexpr fmt::rgb BORDER{0x5a, 0x71, 0x79};
265 fmt::rgb color = line.isLogo ?
LOGO_COLOR : BORDER;
266 fmt::print(fg(BORDER),
" *");
267 fmt::print(fg(color) | fmt::emphasis::bold,
"{}", line.text);
268 fmt::print(fg(BORDER),
"{}*\n",
padRight(
"", inner -
static_cast<int>(line.text.size())));
279 auto printLine = [&](
const std::string& text, fmt::rgb color) {
280 fmt::print(fg(fmt::color::white) | fmt::emphasis::bold,
" |");
281 fmt::print(fg(color),
"{}",
padRight(text, inner));
282 fmt::print(fg(fmt::color::white) | fmt::emphasis::bold,
"|\n");
285 auto printKV = [&](
const std::string& key,
const std::string& val,
286 fmt::rgb keyColor, fmt::rgb valColor) {
287 int pad = inner -
static_cast<int>(key.size()) -
static_cast<int>(val.size());
288 if (pad < 0) pad = 0;
289 fmt::print(fg(fmt::color::white) | fmt::emphasis::bold,
" |");
290 fmt::print(fg(keyColor),
"{}", key);
291 fmt::print(fg(valColor) | fmt::emphasis::bold,
"{}", val);
292 fmt::print(
"{}", std::string(pad,
' '));
293 fmt::print(fg(fmt::color::white) | fmt::emphasis::bold,
"|\n");
296 fmt::print(fg(fmt::color::white) | fmt::emphasis::bold,
297 " {}\n", std::string(inner,
'_'));
301 printLine(p.key, p.keyColor);
303 printKV(p.key, p.value, p.keyColor, p.valColor);
306 fmt::print(fg(fmt::color::white) | fmt::emphasis::bold,
307 " |{}|\n", std::string(inner,
'_'));
330 fmt::print(fg(
LOGO_COLOR),
"{}\n",
center(std::string(title.size() + 4,
'-')));
@ INFO
Informational messages.
Terminal and file output formatting for deltaFlow.
void printProductBox()
Prints the colored product info box to terminal.
constexpr fmt::rgb LOGO_COLOR
deltaFlow logo color
std::string center(const std::string &text)
Returns a centered string within the page width.
void printSectionHeader(const std::string &title)
Prints a colored section header to terminal.
constexpr int pageWidth
Standard output page width.
std::string padRight(const std::string &text, int width)
Right-pads a string with spaces to the given width.
constexpr int licenseBoxWidth
License notice box width.
void printLicenseNotice()
Prints the colored license notice box to terminal.
void printTerminalBanner()
Prints the full colored banner to terminal.
std::string licenseNotice()
Returns the plain-text license notice box.
std::string centerIn(const std::string &text, int width)
Centers a string within a given width.
std::string hostname()
Returns the machine hostname.
std::vector< LicenseLine > licenseContent()
Returns the license notice content lines.
std::string separator(char ch='=')
Returns a separator line of the given character.
constexpr int productBoxWidth
Product info box width.
std::string subSectionHeader(const std::string &title)
Returns a sub-section header for output files.
std::string sectionHeader(const std::string &title)
Returns a section header for output files.
std::string fileBanner()
Returns a full plain-text banner for output/log files.
std::vector< ProductLine > productContent()
Returns the product info box content lines.
std::string productBox()
Returns the plain-text product info box.
A single line in the license notice box.
bool isLogo
true for logo/brand lines
std::string text
Line content.
A single line in the product info box.
fmt::rgb valColor
Value color (terminal only, ignored when value is empty)
std::string key
Label or full text.
fmt::rgb keyColor
Key/text color (terminal only)
std::string value
Value (empty for non-KV lines)