1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:57:45 +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:
xSlendiX 2022-02-16 23:10:44 +02:00 committed by Andreas Kling
parent 246c31ccf6
commit 19b7a5fe0d

View file

@ -116,13 +116,21 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto buffer = file->read_all(); auto buffer = file->read_all();
auto source = String::copy(buffer); 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); auto document = Markdown::Document::parse(source);
VERIFY(document); VERIFY(document);
String rendered = document->render_for_terminal(view_width); 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 // FIXME: Remove this wait, it shouldn't be necessary but Shell does not
// resume properly without it. This wait also breaks <C-z> backgrounding // resume properly without it. This wait also breaks <C-z> backgrounding