diff --git a/src/assert.cc b/src/assert.cc index 1edf1e45..eb88120c 100644 --- a/src/assert.cc +++ b/src/assert.cc @@ -26,10 +26,10 @@ private: void on_assert_failed(const char* message) { - String debug_info = "pid: " + to_string(getpid()); - write_debug("assert failed: '"_str + message + "' " + debug_info); + String debug_info = format("pid: {}", getpid()); + write_debug(format("assert failed: '{}' ", message, debug_info)); - const auto msg = message + "\n[Debug Infos]\n"_str + debug_info; + const auto msg = format("{}\n[Debug Infos]\n{}", message, debug_info); #if defined(__CYGWIN__) int res = MessageBox(NULL, msg.c_str(), "Kakoune: assert failed", MB_OKCANCEL | MB_ICONERROR); diff --git a/src/client.cc b/src/client.cc index dcd575b8..27a56c80 100644 --- a/src/client.cc +++ b/src/client.cc @@ -104,11 +104,11 @@ DisplayLine Client::generate_mode_line() const Face status_face = get_face("StatusLine"); status.push_back({ context().buffer().display_name(), status_face }); - status.push_back({ " " + to_string((int)pos.line+1) + ":" + to_string((int)col+1) + " ", status_face }); + status.push_back({ format(" {}:{} ", pos.line+1, col+1), status_face }); if (context().buffer().is_modified()) status.push_back({ "[+]", info_face }); if (m_input_handler.is_recording()) - status.push_back({ "[recording ("_str + StringView{m_input_handler.recording_reg()} + ")]", info_face }); + status.push_back({ format("[recording ({})]", m_input_handler.recording_reg()), info_face }); if (context().buffer().flags() & Buffer::Flags::New) status.push_back({ "[new file]", info_face }); if (context().user_hooks_support().is_disabled()) @@ -118,7 +118,7 @@ DisplayLine Client::generate_mode_line() const status.push_back({ " ", status_face }); for (auto& atom : m_input_handler.mode_line()) status.push_back(std::move(atom)); - status.push_back({ " - " + context().name() + "@[" + Server::instance().session() + "]", status_face }); + status.push_back({ format(" - {}@[{}]", context().name(), Server::instance().session()), status_face }); return status; } diff --git a/src/client_manager.cc b/src/client_manager.cc index 26a278ae..ecade79c 100644 --- a/src/client_manager.cc +++ b/src/client_manager.cc @@ -19,7 +19,7 @@ String ClientManager::generate_name() const { for (int i = 0; true; ++i) { - String name = "unnamed" + to_string(i); + String name = format("unnamed{}", i); if (validate_client_name(name)) return name; } diff --git a/src/command_manager.cc b/src/command_manager.cc index f6e72cbd..736705ca 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -362,9 +362,8 @@ void CommandManager::execute_single_command(CommandParameters params, } catch (runtime_error& error) { - String info = to_string(pos.line+1) + ":" + to_string(pos.column+1) + - ": '" + command_it->first + "' " + error.what(); - throw runtime_error(std::move(info)); + throw runtime_error(format("{}:{}: '{}' {}", pos.line+1, pos.column+1, + command_it->first, error.what())); } } diff --git a/src/commands.cc b/src/commands.cc index ccd49079..e1cfcb10 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -834,8 +834,8 @@ const CommandDesc debug_cmd = { { if (parser[0] == "info") { - write_debug("pid: " + to_string(getpid())); - write_debug("session: " + Server::instance().session()); + write_debug(format("pid: {}", getpid())); + write_debug(format("session: {}", Server::instance().session())); } else if (parser[0] == "buffers") { @@ -847,7 +847,7 @@ const CommandDesc debug_cmd = { { write_debug("Options:"); for (auto& option : context.options().flatten_options()) - write_debug(" * " + option->name() + ": " + option->get_as_string()); + write_debug(format(" * {}: {}", option->name(), option->get_as_string())); } else if (parser[0] == "memory") { @@ -857,11 +857,11 @@ const CommandDesc debug_cmd = { { size_t count = domain_allocated_bytes[domain]; total += count; - write_debug(" "_str + domain_name((MemoryDomain)domain) + ": " + to_string(count)); + write_debug(format(" {}: {}", domain_name((MemoryDomain)domain), count)); } - write_debug(" Total: " + to_string(total)); + write_debug(format(" Total: {}", total)); #if defined(__GLIBC__) || defined(__CYGWIN__) - write_debug(" Malloced: " + to_string(mallinfo().uordblks)); + write_debug(format(" Malloced: {}", mallinfo().uordblks)); #endif } else if (parser[0] == "shared-strings") @@ -869,7 +869,7 @@ const CommandDesc debug_cmd = { StringRegistry::instance().debug_stats(); } else - throw runtime_error("unknown debug command '" + parser[0] + "'"); + throw runtime_error(format("unknown debug command '{}'", parser[0])); } }; @@ -890,7 +890,7 @@ const CommandDesc source_cmd = { } catch (Kakoune::runtime_error& err) { - write_debug(parser[0] + ":" + err.what()); + write_debug(format("{}:{}", parser[0], err.what())); throw; } }