mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
man: Center "SerenityOS manual" title
This patch calculates how many spaces are needed to center the top title of "SerenityOS manual".
This commit is contained in:
parent
246c31ccf6
commit
19b7a5fe0d
Notes:
sideshowbarker
2024-07-17 18:37:55 +09:00
Author: https://github.com/xslendix Commit: https://github.com/SerenityOS/serenity/commit/19b7a5fe0d Pull-request: https://github.com/SerenityOS/serenity/pull/12586 Reviewed-by: https://github.com/petelliott ✅
1 changed files with 10 additions and 2 deletions
|
@ -116,13 +116,21 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto buffer = file->read_all();
|
||||
auto source = String::copy(buffer);
|
||||
|
||||
outln("{}({})\t\tSerenityOS manual", name, section);
|
||||
const String title("SerenityOS manual");
|
||||
|
||||
int spaces = view_width / 2 - String(name).length() - String(section).length() - title.length() / 2 - 4;
|
||||
if (spaces < 0)
|
||||
spaces = 0;
|
||||
out("{}({})", name, section);
|
||||
while (spaces--)
|
||||
out(" ");
|
||||
outln(title);
|
||||
|
||||
auto document = Markdown::Document::parse(source);
|
||||
VERIFY(document);
|
||||
|
||||
String rendered = document->render_for_terminal(view_width);
|
||||
out("{}", rendered);
|
||||
outln("{}", rendered);
|
||||
|
||||
// FIXME: Remove this wait, it shouldn't be necessary but Shell does not
|
||||
// resume properly without it. This wait also breaks <C-z> backgrounding
|
||||
|
|
Loading…
Reference in a new issue