LibMarkdown: Convert StringBuilder::appendf() => AK::Format

These are the last ones in the codebase. :^)
This commit is contained in:
Andreas Kling 2021-05-07 21:08:37 +02:00
parent 32080452e3
commit 730ed465fe
Notes: sideshowbarker 2024-07-18 18:35:01 +09:00

View file

@ -22,11 +22,15 @@ String Table::render_for_terminal(size_t view_width) const
auto string = text.render_for_terminal();
if (alignment == Alignment::Center) {
auto padding_length = (width - original_length) / 2;
builder.appendf("%*s%s%*s", (int)padding_length, "", string.characters(), (int)padding_length, "");
// FIXME: We're using a StringView literal to bypass the compile-time AK::Format checking here, since it can't handle the "}}"
builder.appendff("{:{1}}"sv, "", (int)padding_length);
builder.append(string);
builder.appendff("{:{1}}"sv, "", (int)padding_length);
if ((width - original_length) % 2)
builder.append(' ');
} else {
builder.appendf(alignment == Alignment::Left ? "%-*s" : "%*s", (int)(width + (string.length() - original_length)), string.characters());
// FIXME: We're using StringView literals to bypass the compile-time AK::Format checking here, since it can't handle the "}}"
builder.appendff(alignment == Alignment::Left ? "{:<{1}}"sv : "{:>{1}}"sv, string, (int)(width + (string.length() - original_length)));
}
};