mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Spreadsheet: Use new format functions.
In a few places I also simplified a few format strings: -outln("{} item{}", items, items.size() == 1 ? ' ' : 's'); +outln("{} item(s)", items); In my opinion this is more readable and in some places it incorrectly wrote '0 item' which is "fixed" now. In other places the placeholder space looked weird.
This commit is contained in:
parent
30ca17e78f
commit
f005548d56
Notes:
sideshowbarker
2024-07-19 02:00:44 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/f005548d560 Pull-request: https://github.com/SerenityOS/serenity/pull/3699
5 changed files with 18 additions and 19 deletions
|
@ -56,9 +56,9 @@ CellTypeDialog::CellTypeDialog(const Vector<Position>& positions, Sheet& sheet,
|
|||
StringBuilder builder;
|
||||
|
||||
if (positions.size() == 1)
|
||||
builder.appendf("Format Cell %s%zu", positions.first().column.characters(), positions.first().row);
|
||||
builder.appendff("Format Cell {}{}", positions.first().column, positions.first().row);
|
||||
else
|
||||
builder.appendf("Format %zu Cells", positions.size());
|
||||
builder.appendff("Format {} Cells", positions.size());
|
||||
|
||||
set_title(builder.string_view());
|
||||
resize(285, 360);
|
||||
|
|
|
@ -132,21 +132,21 @@ String HelpWindow::render(const GUI::ModelIndex& index)
|
|||
|
||||
markdown_builder.append("# ARGUMENTS\n");
|
||||
if (argc > 0)
|
||||
markdown_builder.appendf("%d required argument%s: \n", argc, argc > 1 ? "s" : "");
|
||||
markdown_builder.appendff("{} required argument(s):\n", argc);
|
||||
else
|
||||
markdown_builder.appendf("No required arguments.\n");
|
||||
|
||||
for (size_t i = 0; i < argc; ++i)
|
||||
markdown_builder.appendf("- `%s`\n", argnames.at(i).to_string().characters());
|
||||
markdown_builder.appendff("- `{}`\n", argnames.at(i).to_string());
|
||||
|
||||
if (argc > 0)
|
||||
markdown_builder.append("\n");
|
||||
|
||||
if ((size_t)argnames.size() > argc) {
|
||||
auto opt_count = argnames.size() - argc;
|
||||
markdown_builder.appendf("%d optional argument%s: \n", opt_count, opt_count > 1 ? "s" : "");
|
||||
markdown_builder.appendff("{} optional argument(s):\n", opt_count);
|
||||
for (size_t i = argc; i < (size_t)argnames.size(); ++i)
|
||||
markdown_builder.appendf("- `%s`\n", argnames.at(i).to_string().characters());
|
||||
markdown_builder.appendff("- `{}`\n", argnames.at(i).to_string());
|
||||
markdown_builder.append("\n");
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ String HelpWindow::render(const GUI::ModelIndex& index)
|
|||
if (!examples.is_empty()) {
|
||||
markdown_builder.append("# EXAMPLES\n");
|
||||
examples.for_each_member([&](auto& text, auto& description_value) {
|
||||
markdown_builder.appendf("- %s\n\n```js\n%s\n```\n", description_value.to_string().characters(), text.characters());
|
||||
markdown_builder.appendf("- {}\n\n```js\n{}\n```\n", description_value.to_string(), text);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -64,16 +64,15 @@ Sheet::Sheet(Workbook& workbook)
|
|||
auto buffer = file_or_error.value()->read_all();
|
||||
JS::Parser parser { JS::Lexer(buffer) };
|
||||
if (parser.has_errors()) {
|
||||
dbg() << "Spreadsheet: Failed to parse runtime code";
|
||||
dbgln("Spreadsheet: Failed to parse runtime code");
|
||||
for (auto& error : parser.errors())
|
||||
dbg() << "Error: " << error.to_string() << "\n"
|
||||
<< error.source_location_hint(buffer);
|
||||
dbgln("Error: {}\n{}", error.to_string(), error.source_location_hint(buffer));
|
||||
} else {
|
||||
interpreter().run(global_object(), parser.parse_program());
|
||||
if (auto exc = interpreter().exception()) {
|
||||
dbg() << "Spreadsheet: Failed to run runtime code: ";
|
||||
dbgln("Spreadsheet: Failed to run runtime code: ");
|
||||
for (auto& t : exc->trace())
|
||||
dbg() << t;
|
||||
dbgln("{}", t);
|
||||
interpreter().vm().clear_exception();
|
||||
}
|
||||
}
|
||||
|
@ -331,7 +330,7 @@ JsonObject Sheet::to_json() const
|
|||
for (auto& it : m_cells) {
|
||||
StringBuilder builder;
|
||||
builder.append(it.key.column);
|
||||
builder.appendf("%zu", it.key.row);
|
||||
builder.appendff("{}", it.key.row);
|
||||
auto key = builder.to_string();
|
||||
|
||||
JsonObject data;
|
||||
|
@ -399,7 +398,7 @@ JsonObject Sheet::gather_documentation() const
|
|||
if (!value_object.has_own_property(doc_name))
|
||||
return;
|
||||
|
||||
dbg() << "Found '" << it.key.to_display_string() << "'";
|
||||
dbgln("Found '{}'", it.key.to_display_string());
|
||||
auto doc = value_object.get(doc_name);
|
||||
if (!doc.is_string())
|
||||
return;
|
||||
|
@ -410,7 +409,7 @@ JsonObject Sheet::gather_documentation() const
|
|||
if (doc_object.has_value())
|
||||
object.set(it.key.to_display_string(), doc_object.value());
|
||||
else
|
||||
dbg() << "Sheet::gather_documentation(): Failed to parse the documentation for '" << it.key.to_display_string() << "'!";
|
||||
dbgln("Sheet::gather_documentation(): Failed to parse the documentation for '{}'!", it.key.to_display_string());
|
||||
};
|
||||
|
||||
for (auto& it : interpreter().global_object().shape().property_table())
|
||||
|
|
|
@ -104,7 +104,7 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
|
|||
auto& position = selection.first();
|
||||
StringBuilder builder;
|
||||
builder.append(position.column);
|
||||
builder.appendf("%zu", position.row);
|
||||
builder.appendff("{}", position.row);
|
||||
m_current_cell_label->set_enabled(true);
|
||||
m_current_cell_label->set_text(builder.string_view());
|
||||
|
||||
|
@ -121,7 +121,7 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
|
|||
|
||||
// There are many cells selected, change all of them.
|
||||
StringBuilder builder;
|
||||
builder.appendf("<%zu>", selection.size());
|
||||
builder.appendff("<{}>", selection.size());
|
||||
m_current_cell_label->set_enabled(true);
|
||||
m_current_cell_label->set_text(builder.string_view());
|
||||
|
||||
|
@ -184,7 +184,7 @@ void SpreadsheetWidget::add_sheet()
|
|||
{
|
||||
StringBuilder name;
|
||||
name.append("Sheet");
|
||||
name.appendf(" %d", m_workbook->sheets().size() + 1);
|
||||
name.appendff(" {}", m_workbook->sheets().size() + 1);
|
||||
|
||||
auto& sheet = m_workbook->add_sheet(name.string_view());
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
if (filename) {
|
||||
if (!Core::File::exists(filename) || Core::File::is_directory(filename)) {
|
||||
fprintf(stderr, "File does not exist or is a directory: %s\n", filename);
|
||||
warnln("File does not exist or is a directory: {}", filename);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue