diff --git a/lib/libimhex/include/hex/api/localization_manager.hpp b/lib/libimhex/include/hex/api/localization_manager.hpp index 05cef447d..a47036f70 100644 --- a/lib/libimhex/include/hex/api/localization_manager.hpp +++ b/lib/libimhex/include/hex/api/localization_manager.hpp @@ -154,4 +154,13 @@ struct std::hash { std::size_t operator()(const hex::UnlocalizedString &string) const noexcept { return std::hash{}(string.get()); } -}; \ No newline at end of file +}; + +namespace fmt { + + template + auto format(const hex::Lang &entry, Args &&... args) { + return fmt::format(fmt::runtime(entry.get()), std::forward(args)...); + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/helpers/fmt.hpp b/lib/libimhex/include/hex/helpers/fmt.hpp index f222315ac..ef0a8db32 100644 --- a/lib/libimhex/include/hex/helpers/fmt.hpp +++ b/lib/libimhex/include/hex/helpers/fmt.hpp @@ -3,13 +3,4 @@ #include #include #include -#include - -namespace hex { - - template - std::string format(std::string_view format, Args... args) { - return fmt::format(fmt::runtime(format), args...); - } - -} \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libimhex/include/hex/helpers/logger.hpp b/lib/libimhex/include/hex/helpers/logger.hpp index 8f986a444..32a1a5734 100644 --- a/lib/libimhex/include/hex/helpers/logger.hpp +++ b/lib/libimhex/include/hex/helpers/logger.hpp @@ -12,9 +12,9 @@ EXPORT_MODULE namespace hex::log { namespace impl { - FILE *getDestination(); - wolv::io::File& getFile(); - bool isRedirected(); + [[nodiscard]] FILE *getDestination(); + [[nodiscard]] wolv::io::File& getFile(); + [[nodiscard]] bool isRedirected(); [[maybe_unused]] void redirectToFile(); [[maybe_unused]] void enableColorPrinting(); @@ -25,17 +25,18 @@ EXPORT_MODULE namespace hex::log { void unlockLoggerMutex(); struct LogEntry { - std::string project; - std::string level; + std::string_view project; + std::string_view level; std::string message; }; - std::vector& getLogEntries(); - void addLogEntry(std::string_view project, std::string_view level, std::string_view message); + const std::vector& getLogEntries(); + void addLogEntry(std::string_view project, std::string_view level, std::string message); - [[maybe_unused]] void printPrefix(FILE *dest, const fmt::text_style &ts, const std::string &level, const char *projectName); + [[maybe_unused]] void printPrefix(FILE *dest, fmt::text_style ts, std::string_view level, std::string_view projectName); - [[maybe_unused]] void print(const fmt::text_style &ts, const std::string &level, const std::string &fmt, auto && ... args) { + template + [[maybe_unused]] void print(fmt::text_style ts, std::string_view level, fmt::format_string fmt, Args && ... args) { if (isLoggingSuspended()) [[unlikely]] return; @@ -46,12 +47,14 @@ EXPORT_MODULE namespace hex::log { try { printPrefix(dest, ts, level, IMHEX_PROJECT_NAME); - auto message = fmt::format(fmt::runtime(fmt), args...); - fmt::print(dest, "{}\n", message); - fflush(dest); + auto message = fmt::format(fmt, std::forward(args)...); + fmt::println(dest, "{}", message); + std::fflush(dest); addLogEntry(IMHEX_PROJECT_NAME, level, std::move(message)); - } catch (const std::exception&) { } + } catch (const std::exception&) { + /* Ignore any exceptions, we can't do anything anyway */ + } } namespace color { @@ -70,52 +73,61 @@ EXPORT_MODULE namespace hex::log { void resumeLogging(); void enableDebugLogging(); - [[maybe_unused]] void debug(const std::string &fmt, auto && ... args) { + template + [[maybe_unused]] void debug(fmt::format_string fmt, Args && ... args) { if (impl::isDebugLoggingEnabled()) [[unlikely]] { - hex::log::impl::print(fg(impl::color::debug()) | fmt::emphasis::bold, "[DEBUG]", fmt, args...); + impl::print(fg(impl::color::debug()) | fmt::emphasis::bold, "[DEBUG]", fmt, std::forward(args)...); } else { - impl::addLogEntry(IMHEX_PROJECT_NAME, "[DEBUG]", fmt::format(fmt::runtime(fmt), args...)); + impl::addLogEntry(IMHEX_PROJECT_NAME, "[DEBUG]", fmt::format(fmt, std::forward(args)...)); } } - [[maybe_unused]] void info(const std::string &fmt, auto && ... args) { - hex::log::impl::print(fg(impl::color::info()) | fmt::emphasis::bold, "[INFO] ", fmt, args...); + template + [[maybe_unused]] void info(fmt::format_string fmt, Args && ... args) { + impl::print(fg(impl::color::info()) | fmt::emphasis::bold, "[INFO] ", fmt, std::forward(args)...); } - [[maybe_unused]] void warn(const std::string &fmt, auto && ... args) { - hex::log::impl::print(fg(impl::color::warn()) | fmt::emphasis::bold, "[WARN] ", fmt, args...); + template + [[maybe_unused]] void warn(fmt::format_string fmt, Args && ... args) { + impl::print(fg(impl::color::warn()) | fmt::emphasis::bold, "[WARN] ", fmt, std::forward(args)...); } - [[maybe_unused]] void error(const std::string &fmt, auto && ... args) { - hex::log::impl::print(fg(impl::color::error()) | fmt::emphasis::bold, "[ERROR]", fmt, args...); + template + [[maybe_unused]] void error(fmt::format_string fmt, Args && ... args) { + impl::print(fg(impl::color::error()) | fmt::emphasis::bold, "[ERROR]", fmt, std::forward(args)...); } - [[maybe_unused]] void fatal(const std::string &fmt, auto && ... args) { - hex::log::impl::print(fg(impl::color::fatal()) | fmt::emphasis::bold, "[FATAL]", fmt, args...); + template + [[maybe_unused]] void fatal(fmt::format_string fmt, Args && ... args) { + impl::print(fg(impl::color::fatal()) | fmt::emphasis::bold, "[FATAL]", fmt, std::forward(args)...); } - [[maybe_unused]] void print(const std::string &fmt, auto && ... args) { + template + [[maybe_unused]] void print(fmt::format_string fmt, Args && ... args) { impl::lockLoggerMutex(); ON_SCOPE_EXIT { impl::unlockLoggerMutex(); }; try { auto dest = impl::getDestination(); - auto message = fmt::format(fmt::runtime(fmt), args...); - fmt::print(dest, "{}", message); - fflush(dest); - } catch (const std::exception&) { } + fmt::print(dest, fmt, std::forward(args)...); + std::fflush(dest); + } catch (const std::exception&) { + /* Ignore any exceptions, we can't do anything anyway */ + } } - [[maybe_unused]] void println(const std::string &fmt, auto && ... args) { + template + [[maybe_unused]] void println(fmt::format_string fmt, Args && ... args) { impl::lockLoggerMutex(); ON_SCOPE_EXIT { impl::unlockLoggerMutex(); }; try { auto dest = impl::getDestination(); - auto message = fmt::format(fmt::runtime(fmt), args...); - fmt::print(dest, "{}\n", message); - fflush(dest); - } catch (const std::exception&) { } + fmt::println(dest, fmt, std::forward(args)...); + std::fflush(dest); + } catch (const std::exception&) { + /* Ignore any exceptions, we can't do anything anyway */ + } } } diff --git a/lib/libimhex/include/hex/providers/undo_redo/operations/operation_group.hpp b/lib/libimhex/include/hex/providers/undo_redo/operations/operation_group.hpp index 3c8e42726..3bf14509f 100644 --- a/lib/libimhex/include/hex/providers/undo_redo/operations/operation_group.hpp +++ b/lib/libimhex/include/hex/providers/undo_redo/operations/operation_group.hpp @@ -37,13 +37,13 @@ namespace hex::prv::undo { if (m_formattedContent.size() <= 10) m_formattedContent.emplace_back(newOperation->format()); else - m_formattedContent.back() = hex::format("[{}x] ...", (m_operations.size() - 10) + 1); + m_formattedContent.back() = fmt::format("[{}x] ...", (m_operations.size() - 10) + 1); m_operations.emplace_back(std::move(newOperation)); } [[nodiscard]] std::string format() const override { - return hex::format("{}", Lang(m_unlocalizedName)); + return fmt::format("{}", Lang(m_unlocalizedName)); } [[nodiscard]] Region getRegion() const override { diff --git a/lib/libimhex/include/hex/test/tests.hpp b/lib/libimhex/include/hex/test/tests.hpp index 40e0a218f..a4a42801f 100644 --- a/lib/libimhex/include/hex/test/tests.hpp +++ b/lib/libimhex/include/hex/test/tests.hpp @@ -30,7 +30,7 @@ auto ret = (x); \ if (!ret) { \ hex::log::error("Test assert '" #x "' failed {} at {}:{}", \ - hex::format("" __VA_ARGS__), \ + fmt::format("" __VA_ARGS__), \ __FILE__, \ __LINE__); \ return EXIT_FAILURE; \ diff --git a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h index 358e8b915..41c08af95 100644 --- a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h +++ b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h @@ -200,13 +200,13 @@ namespace ImGuiExt { if constexpr (sizeof...(args) == 0) { ImGui::TextUnformatted(fmt.data(), fmt.data() + fmt.size()); } else { - const auto string = hex::format(fmt, std::forward(args)...); + const auto string = fmt::format(fmt::runtime(fmt), std::forward(args)...); ImGui::TextUnformatted(string.c_str(), string.c_str() + string.size()); } } void TextFormattedSelectable(std::string_view fmt, auto &&...args) { - auto text = hex::format(fmt, std::forward(args)...); + auto text = fmt::format(fmt::runtime(fmt), std::forward(args)...); ImGui::PushID(text.c_str()); @@ -254,7 +254,7 @@ namespace ImGuiExt { void TextFormattedWrappedSelectable(std::string_view fmt, auto &&...args) { // Manually wrap text, using the letter M (generally the widest character in non-monospaced fonts) to calculate the character width to use. auto text = wolv::util::trim(wolv::util::wrapMonospacedString( - hex::format(fmt, std::forward(args)...), + fmt::format(fmt::runtime(fmt), std::forward(args)...), ImGui::CalcTextSize("M").x, ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ScrollbarSize - ImGui::GetStyle().FrameBorderSize )); @@ -285,13 +285,13 @@ namespace ImGuiExt { void TextUnformattedCentered(const char *text); void TextFormattedCentered(std::string_view fmt, auto &&...args) { - auto text = hex::format(fmt, std::forward(args)...); + auto text = fmt::format(fmt::runtime(fmt), std::forward(args)...); TextUnformattedCentered(text.c_str()); } void TextFormattedCenteredHorizontal(std::string_view fmt, auto &&...args) { - auto text = hex::format(fmt, std::forward(args)...); + auto text = fmt::format(fmt::runtime(fmt), std::forward(args)...); auto availableSpace = ImGui::GetContentRegionAvail(); auto textSize = ImGui::CalcTextSize(text.c_str(), nullptr, false, availableSpace.x * 0.75F); diff --git a/lib/libimhex/include/hex/ui/view.hpp b/lib/libimhex/include/hex/ui/view.hpp index b21657897..0b729d92a 100644 --- a/lib/libimhex/include/hex/ui/view.hpp +++ b/lib/libimhex/include/hex/ui/view.hpp @@ -143,7 +143,7 @@ namespace hex { void draw() final { if (this->shouldDraw()) { ImGui::SetNextWindowSizeConstraints(this->getMinSize(), this->getMaxSize()); - const auto title = hex::format("{} {}", this->getIcon(), View::toWindowName(this->getUnlocalizedName())); + const auto title = fmt::format("{} {}", this->getIcon(), View::toWindowName(this->getUnlocalizedName())); if (ImGui::Begin(title.c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse | this->getWindowFlags())) { this->drawContent(); } diff --git a/lib/libimhex/source/api/content_registry.cpp b/lib/libimhex/source/api/content_registry.cpp index 6ad37d289..c88e9d22c 100644 --- a/lib/libimhex/source/api/content_registry.cpp +++ b/lib/libimhex/source/api/content_registry.cpp @@ -873,7 +873,7 @@ namespace hex { LocalizationManager::impl::setFallbackLanguage(code.get()); } - impl::s_languages->emplace(code.get(), hex::format("{} ({})", language.get(), country.get())); + impl::s_languages->emplace(code.get(), fmt::format("{} ({})", language.get(), country.get())); std::map translationDefinitions; for (auto &[key, value] : translations.items()) { diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index bcef6d3b7..048d5f7be 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -817,7 +817,7 @@ namespace hex { info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); ::GetVersionExA(&info); - return hex::format("{}.{}.{}", info.dwMajorVersion, info.dwMinorVersion, info.dwBuildNumber); + return fmt::format("{}.{}.{}", info.dwMajorVersion, info.dwMinorVersion, info.dwBuildNumber); #elif defined(OS_LINUX) || defined(OS_MACOS) || defined(OS_WEB) struct utsname details = { }; @@ -950,7 +950,7 @@ namespace hex { EventImHexClosing::subscribe([executablePath, updateTypeString] { hex::startProgram( - hex::format("\"{}\" \"{}\"", + fmt::format("\"{}\" \"{}\"", wolv::util::toUTF8String(executablePath), updateTypeString ) diff --git a/lib/libimhex/source/api/plugin_manager.cpp b/lib/libimhex/source/api/plugin_manager.cpp index e467f1f1a..0787fe251 100644 --- a/lib/libimhex/source/api/plugin_manager.cpp +++ b/lib/libimhex/source/api/plugin_manager.cpp @@ -71,14 +71,14 @@ namespace hex { const auto fileName = path.stem().string(); m_functions.initializePluginFunction = getPluginFunction("initializePlugin"); - m_functions.initializeLibraryFunction = getPluginFunction(hex::format("initializeLibrary_{}", fileName)); + m_functions.initializeLibraryFunction = getPluginFunction(fmt::format("initializeLibrary_{}", fileName)); m_functions.getPluginNameFunction = getPluginFunction("getPluginName"); - m_functions.getLibraryNameFunction = getPluginFunction(hex::format("getLibraryName_{}", fileName)); + m_functions.getLibraryNameFunction = getPluginFunction(fmt::format("getLibraryName_{}", fileName)); m_functions.getPluginAuthorFunction = getPluginFunction("getPluginAuthor"); m_functions.getPluginDescriptionFunction = getPluginFunction("getPluginDescription"); m_functions.getCompatibleVersionFunction = getPluginFunction("getCompatibleVersion"); m_functions.setImGuiContextFunction = getPluginFunction("setImGuiContext"); - m_functions.setImGuiContextLibraryFunction = getPluginFunction(hex::format("setImGuiContext_{}", fileName)); + m_functions.setImGuiContextLibraryFunction = getPluginFunction(fmt::format("setImGuiContext_{}", fileName)); m_functions.getSubCommandsFunction = getPluginFunction("getSubCommands"); m_functions.getFeaturesFunction = getPluginFunction("getFeatures"); m_functions.isBuiltinPluginFunction = getPluginFunction("isBuiltinPlugin"); @@ -176,7 +176,7 @@ namespace hex { if (this->isLibraryPlugin()) return m_functions.getLibraryNameFunction(); else - return hex::format("Unknown Plugin @ 0x{0:016X}", m_handle); + return fmt::format("Unknown Plugin @ 0x{0:016X}", m_handle); } } diff --git a/lib/libimhex/source/data_processor/node.cpp b/lib/libimhex/source/data_processor/node.cpp index 3f8282891..11a0a9945 100644 --- a/lib/libimhex/source/data_processor/node.cpp +++ b/lib/libimhex/source/data_processor/node.cpp @@ -24,7 +24,7 @@ namespace hex::dp { auto attribute = this->getConnectedInputAttribute(index); if (attribute == nullptr) - throwNodeError(hex::format("Nothing connected to input '{0}'", Lang(m_attributes[index].getUnlocalizedName()))); + throwNodeError(fmt::format("Nothing connected to input '{0}'", Lang(m_attributes[index].getUnlocalizedName()))); if (attribute->getType() != Attribute::Type::Buffer) throwNodeError("Tried to read buffer from non-buffer attribute"); diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index b988f6c65..0a1ef026e 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -56,7 +56,7 @@ namespace hex::fs { std::ignore = ShellExecuteW(nullptr, L"open", filePath.c_str(), nullptr, nullptr, SW_SHOWNORMAL); #elif defined(OS_MACOS) std::ignore = system( - hex::format("open {}", wolv::util::toUTF8String(filePath)).c_str() + fmt::format("open {}", wolv::util::toUTF8String(filePath)).c_str() ); #elif defined(OS_LINUX) executeCmd({"xdg-open", wolv::util::toUTF8String(filePath)}); @@ -76,7 +76,7 @@ namespace hex::fs { ShellExecuteW(nullptr, L"open", L"explorer.exe", args.c_str(), nullptr, SW_SHOWNORMAL); #elif defined(OS_MACOS) std::ignore = system( - hex::format("open {}", wolv::util::toUTF8String(dirPath)).c_str() + fmt::format("open {}", wolv::util::toUTF8String(dirPath)).c_str() ); #elif defined(OS_LINUX) executeCmd({"xdg-open", wolv::util::toUTF8String(dirPath)}); @@ -96,7 +96,7 @@ namespace hex::fs { ShellExecuteW(nullptr, L"open", L"explorer.exe", args.c_str(), nullptr, SW_SHOWNORMAL); #elif defined(OS_MACOS) std::ignore = system( - hex::format( + fmt::format( R"(osascript -e 'tell application "Finder" to reveal POSIX file "{}"')", wolv::util::toUTF8String(selectedFilePath) ).c_str() diff --git a/lib/libimhex/source/helpers/http_requests.cpp b/lib/libimhex/source/helpers/http_requests.cpp index ba338b3ea..0531bbc16 100644 --- a/lib/libimhex/source/helpers/http_requests.cpp +++ b/lib/libimhex/source/helpers/http_requests.cpp @@ -29,7 +29,7 @@ namespace hex { if (std::isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') result += c; else - result += hex::format("%02X", c); + result += fmt::format("%02X", c); } return result; } diff --git a/lib/libimhex/source/helpers/http_requests_native.cpp b/lib/libimhex/source/helpers/http_requests_native.cpp index bf60b05fd..a8ce13a1f 100644 --- a/lib/libimhex/source/helpers/http_requests_native.cpp +++ b/lib/libimhex/source/helpers/http_requests_native.cpp @@ -178,7 +178,7 @@ namespace hex { ON_SCOPE_EXIT { curl_slist_free_all(headersList); }; for (auto &[key, value] : headers) { - std::string header = hex::format("{}: {}", key, value); + std::string header = fmt::format("{}: {}", key, value); headersList = curl_slist_append(headersList, header.c_str()); } curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headersList); diff --git a/lib/libimhex/source/helpers/logger.cpp b/lib/libimhex/source/helpers/logger.cpp index 797fc4181..48a299715 100644 --- a/lib/libimhex/source/helpers/logger.cpp +++ b/lib/libimhex/source/helpers/logger.cpp @@ -84,7 +84,7 @@ namespace hex::log { for (const auto &path : paths::Logs.all()) { wolv::io::fs::createDirectories(path); time_t time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - s_loggerFile = wolv::io::File(path / hex::format("{0:%Y%m%d_%H%M%S}.log", *std::localtime(&time)), wolv::io::File::Mode::Create); + s_loggerFile = wolv::io::File(path / fmt::format("{0:%Y%m%d_%H%M%S}.log", *std::localtime(&time)), wolv::io::File::Mode::Create); s_loggerFile.disableBuffering(); if (s_loggerFile.isValid()) { @@ -109,40 +109,43 @@ namespace hex::log { #endif } - - std::vector& getLogEntries() { - static std::vector logEntries; - return logEntries; + static std::vector s_logEntries; + const std::vector& getLogEntries() { + return s_logEntries; } - void addLogEntry(std::string_view project, std::string_view level, std::string_view message) { - getLogEntries().emplace_back(project.data(), level.data(), message.data()); + void addLogEntry(std::string_view project, std::string_view level, std::string message) { + s_logEntries.emplace_back( + std::move(project), + std::move(level), + std::move(message) + ); } - void printPrefix(FILE *dest, const fmt::text_style &ts, const std::string &level, const char *projectName) { + void printPrefix(FILE *dest, fmt::text_style ts, std::string_view level, std::string_view projectName) { const auto time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); const auto now = *std::localtime(&time); - fmt::print(dest, "[{0:%H:%M:%S}] ", now); - - if (s_colorOutputEnabled) - fmt::print(dest, ts, "{0} ", level); - else - fmt::print(dest, "{0} ", level); - - std::string projectThreadTag = projectName; - if (auto threadName = TaskManager::getCurrentThreadName(); !threadName.empty()) - projectThreadTag += fmt::format(" | {0}", threadName); + auto threadName = TaskManager::getCurrentThreadName(); + if (threadName.empty()) [[unlikely]] { + threadName = "???"; + } constexpr static auto MaxTagLength = 25; - if (projectThreadTag.length() > MaxTagLength) - projectThreadTag.resize(MaxTagLength); + const auto totalLength = std::min(static_cast(MaxTagLength), + projectName.length() + (threadName.empty() ? 0 : 3 + threadName.length())); - fmt::print(dest, "[{0}] ", projectThreadTag); + const auto remainingSpace = MaxTagLength - projectName.length() - 3; - const auto projectNameLength = projectThreadTag.length(); - fmt::print(dest, "{0}", std::string(projectNameLength > MaxTagLength ? 0 : MaxTagLength - projectNameLength, ' ')); + fmt::print(dest, "[{0:%H:%M:%S}] {1} [{2} | {3}] {4: <{5}} ", + now, + s_colorOutputEnabled ? fmt::format(ts, "{}", level) : level, + projectName.substr(0, std::min(projectName.length(), static_cast(MaxTagLength))), + threadName.substr(0, remainingSpace), + "", + MaxTagLength - totalLength + ); } void assertionHandler(const char* exprString, const char* file, int line) { diff --git a/lib/libimhex/source/helpers/semantic_version.cpp b/lib/libimhex/source/helpers/semantic_version.cpp index 671feb941..ca284aa8c 100644 --- a/lib/libimhex/source/helpers/semantic_version.cpp +++ b/lib/libimhex/source/helpers/semantic_version.cpp @@ -109,7 +109,7 @@ namespace hex { auto result = wolv::util::combineStrings(m_parts, "."); if (withBuildType && !m_buildType.empty()) - result += hex::format("-{}", m_buildType); + result += fmt::format("-{}", m_buildType); return result; } diff --git a/lib/libimhex/source/helpers/tar.cpp b/lib/libimhex/source/helpers/tar.cpp index df401f471..7cbd86130 100644 --- a/lib/libimhex/source/helpers/tar.cpp +++ b/lib/libimhex/source/helpers/tar.cpp @@ -95,7 +95,7 @@ namespace hex { } std::string Tar::getOpenErrorString() const { - return hex::format("{}: {}", mtar_strerror(m_tarOpenErrno), std::strerror(m_fileOpenErrno)); + return fmt::format("{}: {}", mtar_strerror(m_tarOpenErrno), std::strerror(m_fileOpenErrno)); } void Tar::close() { diff --git a/lib/libimhex/source/helpers/utils.cpp b/lib/libimhex/source/helpers/utils.cpp index e3fd35cc6..eaff41d08 100644 --- a/lib/libimhex/source/helpers/utils.cpp +++ b/lib/libimhex/source/helpers/utils.cpp @@ -158,9 +158,9 @@ namespace hex { std::string result; if (unitIndex == 0) - result = hex::format("{0:}", value); + result = fmt::format("{0:}", value); else - result = hex::format("{0:.2f}", value); + result = fmt::format("{0:.2f}", value); switch (unitIndex) { case 0: @@ -197,7 +197,7 @@ namespace hex { if (std::isprint(c)) result += c; else - result += hex::format("\\x{0:02X}", u8(c)); + result += fmt::format("\\x{0:02X}", u8(c)); } return result; @@ -302,9 +302,9 @@ namespace hex { void startProgram(const std::string &command) { #if defined(OS_WINDOWS) - std::ignore = system(hex::format("start \"\" {0}", command).c_str()); + std::ignore = system(fmt::format("start \"\" {0}", command).c_str()); #elif defined(OS_MACOS) - std::ignore = system(hex::format("{0}", command).c_str()); + std::ignore = system(fmt::format("{0}", command).c_str()); #elif defined(OS_LINUX) executeCmd({"xdg-open", command}); #elif defined(OS_WEB) @@ -377,7 +377,7 @@ namespace hex { result += "\\v"; break; default: - result += hex::format("\\x{:02X}", byte); + result += fmt::format("\\x{:02X}", byte); break; } } @@ -682,8 +682,8 @@ namespace hex { u8 byte = *it; if ((address % 0x10) == 0) { - result += hex::format(" {}", asciiRow); - result += hex::format("\n{0:08X} ", address); + result += fmt::format(" {}", asciiRow); + result += fmt::format("\n{0:08X} ", address); asciiRow.clear(); @@ -700,7 +700,7 @@ namespace hex { } } - result += hex::format("{0:02X} ", byte); + result += fmt::format("{0:02X} ", byte); asciiRow += std::isprint(byte) ? char(byte) : '.'; if ((address % 0x10) == 0x07) result += " "; @@ -712,7 +712,7 @@ namespace hex { for (u32 i = 0; i < (0x10 - (address % 0x10)); i++) result += " "; - result += hex::format(" {}", asciiRow); + result += fmt::format(" {}", asciiRow); return result; } diff --git a/lib/libimhex/source/subcommands/subcommands.cpp b/lib/libimhex/source/subcommands/subcommands.cpp index 557ec6ae5..33b8a17cf 100644 --- a/lib/libimhex/source/subcommands/subcommands.cpp +++ b/lib/libimhex/source/subcommands/subcommands.cpp @@ -15,7 +15,7 @@ namespace hex::subcommands { std::optional findSubCommand(const std::string &arg) { for (auto &plugin : PluginManager::getPlugins()) { for (auto &subCommand : plugin.getSubCommands()) { - if (hex::format("--{}", subCommand.commandLong) == arg || hex::format("-{}", subCommand.commandShort) == arg) { + if (fmt::format("--{}", subCommand.commandLong) == arg || fmt::format("-{}", subCommand.commandShort) == arg) { return subCommand; } } @@ -106,13 +106,13 @@ namespace hex::subcommands { data.pop_back(); } - SendMessageToMainInstance::post(hex::format("command/{}", cmdName), data); + SendMessageToMainInstance::post(fmt::format("command/{}", cmdName), data); } void registerSubCommand(const std::string &cmdName, const ForwardCommandHandler &handler) { log::debug("Registered new forward command handler: {}", cmdName); - ImHexApi::Messaging::registerHandler(hex::format("command/{}", cmdName), [handler](const std::vector &eventData){ + ImHexApi::Messaging::registerHandler(fmt::format("command/{}", cmdName), [handler](const std::vector &eventData){ std::string string(reinterpret_cast(eventData.data()), eventData.size()); std::vector args; diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 88050d869..0ded79a80 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -964,13 +964,13 @@ namespace ImGuiExt { std::string format; if (*value < 1024) { - format = hex::format("{} Bytes", *value); + format = fmt::format("{} Bytes", *value); } else if (*value < 1024 * 1024) { - format = hex::format("{:.2f} KB", *value / 1024.0); + format = fmt::format("{:.2f} KB", *value / 1024.0); } else if (*value < 1024 * 1024 * 1024) { - format = hex::format("{:.2f} MB", *value / (1024.0 * 1024.0)); + format = fmt::format("{:.2f} MB", *value / (1024.0 * 1024.0)); } else { - format = hex::format("{:.2f} GB", *value / (1024.0 * 1024.0 * 1024.0)); + format = fmt::format("{:.2f} GB", *value / (1024.0 * 1024.0 * 1024.0)); } *value /= stepSize; @@ -1266,7 +1266,7 @@ namespace ImGuiExt { bool result = false; ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0F); - if (ImGui::BeginChild(hex::format("{}##SubWindow", label).c_str(), size, ImGuiChildFlags_Borders | ImGuiChildFlags_AutoResizeY | flags, hasMenuBar ? ImGuiWindowFlags_MenuBar : ImGuiWindowFlags_None)) { + if (ImGui::BeginChild(fmt::format("{}##SubWindow", label).c_str(), size, ImGuiChildFlags_Borders | ImGuiChildFlags_AutoResizeY | flags, hasMenuBar ? ImGuiWindowFlags_MenuBar : ImGuiWindowFlags_None)) { result = true; if (hasMenuBar && ImGui::BeginMenuBar()) { diff --git a/main/gui/source/crash_handlers.cpp b/main/gui/source/crash_handlers.cpp index 8d461436a..3294c0a92 100644 --- a/main/gui/source/crash_handlers.cpp +++ b/main/gui/source/crash_handlers.cpp @@ -39,7 +39,7 @@ namespace hex::crash { void resetCrashHandlers(); static void sendNativeMessage(const std::string& message) { - hex::nativeErrorMessage(hex::format("ImHex crashed during initial setup!\nError: {}", message)); + hex::nativeErrorMessage(fmt::format("ImHex crashed during initial setup!\nError: {}", message)); } // Function that decides what should happen on a crash @@ -48,9 +48,9 @@ namespace hex::crash { static CrashCallback crashCallback = sendNativeMessage; static void saveCrashFile(const std::string& message) { - log::fatal(message); + log::fatal("{}", message); - nlohmann::json crashData { + const nlohmann::json crashData { { "logFile", wolv::io::fs::toNormalizedPathString(hex::log::impl::getFile().getPath()) }, { "project", wolv::io::fs::toNormalizedPathString(ProjectFile::getPath()) }, }; @@ -123,8 +123,8 @@ namespace hex::crash { printStackTrace(); // Flush all streams - fflush(stdout); - fflush(stderr); + std::fflush(stdout); + std::fflush(stderr); #if defined(IMGUI_TEST_ENGINE) ImGuiTestEngine_CrashHandler(); @@ -144,7 +144,7 @@ namespace hex::crash { resetCrashHandlers(); // Actually handle the crash - handleCrash(hex::format("Received signal '{}' ({})", signalName, signalNumber)); + handleCrash(fmt::format("Received signal '{}' ({})", signalName, signalNumber)); // Detect if the crash was due to an uncaught exception if (std::uncaught_exceptions() > 0) { @@ -162,7 +162,7 @@ namespace hex::crash { try { std::rethrow_exception(std::current_exception()); } catch (std::exception &ex) { - std::string exceptionStr = hex::format("{}()::what() -> {}", trace::demangle(typeid(ex).name()), ex.what()); + std::string exceptionStr = fmt::format("{}()::what() -> {}", trace::demangle(typeid(ex).name()), ex.what()); handleCrash(exceptionStr); log::fatal("Program terminated with uncaught exception: {}", exceptionStr); diff --git a/main/gui/source/init/run/web.cpp b/main/gui/source/init/run/web.cpp index 7b10f6469..1f667b207 100644 --- a/main/gui/source/init/run/web.cpp +++ b/main/gui/source/init/run/web.cpp @@ -70,7 +70,7 @@ return ""; } catch (const std::exception &e) { static std::string message; - message = hex::format("Failed to deinitialize ImHex!\nThis is just a message warning you of this, the application has already closed, you probably can't do anything about it.\n\nError: {}", e.what()); + message = fmt::format("Failed to deinitialize ImHex!\nThis is just a message warning you of this, the application has already closed, you probably can't do anything about it.\n\nError: {}", e.what()); return message.c_str(); } }); diff --git a/main/gui/source/init/splash_window.cpp b/main/gui/source/init/splash_window.cpp index 5c5b79063..dfc5cfa50 100644 --- a/main/gui/source/init/splash_window.cpp +++ b/main/gui/source/init/splash_window.cpp @@ -356,14 +356,14 @@ namespace hex::init { drawList->AddImage(m_splashTextTexture, ImVec2(0, 0), WindowSize); // Draw the "copyright" notice - drawList->AddText(ImVec2(35, 85), ImColor(0xFF, 0xFF, 0xFF, 0xFF), hex::format("WerWolv\n2020 - {0}", &__DATE__[7]).c_str()); + drawList->AddText(ImVec2(35, 85), ImColor(0xFF, 0xFF, 0xFF, 0xFF), fmt::format("WerWolv\n2020 - {0}", &__DATE__[7]).c_str()); // Draw version information // In debug builds, also display the current commit hash and branch #if defined(DEBUG) - const static auto VersionInfo = hex::format("{0} : {1}@{2}", ImHexApi::System::getImHexVersion().get(), ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash()); + const static auto VersionInfo = fmt::format("{0} : {1}@{2}", ImHexApi::System::getImHexVersion().get(), ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash()); #else - const static auto VersionInfo = hex::format("{0}", ImHexApi::System::getImHexVersion().get()); + const static auto VersionInfo = fmt::format("{0}", ImHexApi::System::getImHexVersion().get()); #endif drawList->AddText(ImVec2((WindowSize.x - ImGui::CalcTextSize(VersionInfo.c_str()).x) / 2, 105), ImColor(0xFF, 0xFF, 0xFF, 0xFF), VersionInfo.c_str()); @@ -384,7 +384,7 @@ namespace hex::init { // Draw task names separated by | characters drawList->PushClipRect(progressBackgroundStart, progressBackgroundStart + progressBackgroundSize, true); - drawList->AddText(progressStart + ImVec2(5, -20), ImColor(0xFF, 0xFF, 0xFF, 0xFF), m_currTaskNames.empty() ? "Ready!" : hex::format("{}", fmt::join(m_currTaskNames, " | ")).c_str()); + drawList->AddText(progressStart + ImVec2(5, -20), ImColor(0xFF, 0xFF, 0xFF, 0xFF), m_currTaskNames.empty() ? "Ready!" : fmt::format("{}", fmt::join(m_currTaskNames, " | ")).c_str()); drawList->PopClipRect(); } @@ -472,7 +472,7 @@ namespace hex::init { // Create the splash screen window m_window = glfwCreateWindow(1, 1, "Starting ImHex...", nullptr, nullptr); if (m_window == nullptr) { - hex::nativeErrorMessage(hex::format( + hex::nativeErrorMessage(fmt::format( "Failed to create GLFW window: [{}] {}.\n" "You may not have a renderer available.\n" "The most common cause of this is using a virtual machine\n" diff --git a/main/gui/source/window/linux_window.cpp b/main/gui/source/window/linux_window.cpp index 3e82e6e43..29b45563a 100644 --- a/main/gui/source/window/linux_window.cpp +++ b/main/gui/source/window/linux_window.cpp @@ -46,7 +46,7 @@ namespace hex { } void nativeErrorMessage(const std::string &message) { - log::fatal(message); + log::fatal("{}", message); if (isFileInPath("zenity")) { executeCmd({"zenity", "--error", "--text", message}); } else if (isFileInPath("notify-send")) { @@ -138,7 +138,7 @@ namespace hex { // Add plugin library folders to dll search path for (const auto &path : paths::Libraries.read()) { if (std::fs::exists(path)) - setenv("LD_LIBRARY_PATH", hex::format("{};{}", hex::getEnvironmentVariable("LD_LIBRARY_PATH").value_or(""), path.string().c_str()).c_str(), true); + setenv("LD_LIBRARY_PATH", fmt::format("{};{}", hex::getEnvironmentVariable("LD_LIBRARY_PATH").value_or(""), path.string().c_str()).c_str(), true); } // Redirect stdout to log file if we're not running in a terminal diff --git a/main/gui/source/window/macos_window.cpp b/main/gui/source/window/macos_window.cpp index 323e00f7c..9d6e01307 100644 --- a/main/gui/source/window/macos_window.cpp +++ b/main/gui/source/window/macos_window.cpp @@ -41,7 +41,7 @@ namespace hex { // Add plugin library folders to dll search path for (const auto &path : paths::Libraries.read()) { if (std::fs::exists(path)) - setenv("LD_LIBRARY_PATH", hex::format("{};{}", hex::getEnvironmentVariable("LD_LIBRARY_PATH").value_or(""), path.string().c_str()).c_str(), true); + setenv("LD_LIBRARY_PATH", fmt::format("{};{}", hex::getEnvironmentVariable("LD_LIBRARY_PATH").value_or(""), path.string().c_str()).c_str(), true); } // Redirect stdout to log file if we're not running in a terminal diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index b8694e272..2cc157717 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -656,7 +656,7 @@ namespace hex { ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5_scaled); ImGui::SetNextWindowSize(ImVec2(350_scaled, toastHeight)); ImGui::SetNextWindowPos((ImHexApi::System::getMainWindowPosition() + ImHexApi::System::getMainWindowSize()) - scaled({ 10, 10 }) - scaled({ 0, (10 + toastHeight) * index }), ImGuiCond_Always, ImVec2(1, 1)); - if (ImGui::Begin(hex::format("##Toast_{}", index).c_str(), nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing)) { + if (ImGui::Begin(fmt::format("##Toast_{}", index).c_str(), nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing)) { auto drawList = ImGui::GetWindowDrawList(); const auto min = ImGui::GetWindowPos(); diff --git a/main/updater/source/main.cpp b/main/updater/source/main.cpp index 17f1744fc..9322ebd36 100644 --- a/main/updater/source/main.cpp +++ b/main/updater/source/main.cpp @@ -134,7 +134,7 @@ int installUpdate(const std::string &type, std::fs::path updatePath) { std::fs::rename(originalPath, updatePath); // Install the update using the correct command - const auto command = hex::format(handler.command, updatePath.string()); + const auto command = fmt::format(fmt::runtime(handler.command), updatePath.string()); hex::log::info("Starting update process with command: '{}'", command); hex::startProgram(command); diff --git a/plugins/builtin/include/content/popups/popup_crash_recovered.hpp b/plugins/builtin/include/content/popups/popup_crash_recovered.hpp index ddf25769f..d2a736415 100644 --- a/plugins/builtin/include/content/popups/popup_crash_recovered.hpp +++ b/plugins/builtin/include/content/popups/popup_crash_recovered.hpp @@ -19,7 +19,7 @@ namespace hex::plugin::builtin { void drawContent() override { ImGuiExt::TextFormattedWrapped("hex.builtin.popup.crash_recover.message"_lang); - ImGuiExt::TextFormattedWrapped(hex::format("Error: {}: {}", trace::demangle(this->m_errorType), this->m_errorMessage)); + ImGuiExt::TextFormattedWrapped(fmt::format("Error: {}: {}", trace::demangle(this->m_errorType), this->m_errorMessage)); if (ImGui::Button("hex.ui.common.okay"_lang)) { this->close(); diff --git a/plugins/builtin/include/content/popups/popup_docs_question.hpp b/plugins/builtin/include/content/popups/popup_docs_question.hpp index 6c085fba0..bb183ea55 100644 --- a/plugins/builtin/include/content/popups/popup_docs_question.hpp +++ b/plugins/builtin/include/content/popups/popup_docs_question.hpp @@ -90,7 +90,7 @@ namespace hex::plugin::builtin { for (auto space : { "xj7sbzGbHH260vbpZOu1", "WZzDdGjxmgMSIE3xly6o" }) { m_answer.clear(); - auto request = HttpRequest("POST", hex::format("https://api.gitbook.com/v1/spaces/{}/search/ask", space)); + auto request = HttpRequest("POST", fmt::format("https://api.gitbook.com/v1/spaces/{}/search/ask", space)); // Documentation API often takes a long time to respond, so we set a timeout of 30 seconds request.setTimeout(30'000); diff --git a/plugins/builtin/include/content/providers/process_memory_provider.hpp b/plugins/builtin/include/content/providers/process_memory_provider.hpp index edc255a72..aaedbdb19 100644 --- a/plugins/builtin/include/content/providers/process_memory_provider.hpp +++ b/plugins/builtin/include/content/providers/process_memory_provider.hpp @@ -50,7 +50,7 @@ namespace hex::plugin::builtin { void save() override {} - [[nodiscard]] std::string getName() const override { return hex::format("hex.builtin.provider.process_memory.name"_lang, m_selectedProcess != nullptr ? m_selectedProcess->name : ""); } + [[nodiscard]] std::string getName() const override { return fmt::format("hex.builtin.provider.process_memory.name"_lang, m_selectedProcess != nullptr ? m_selectedProcess->name : ""); } [[nodiscard]] std::vector getDataDescription() const override { return { { "hex.builtin.provider.process_memory.process_name"_lang, m_selectedProcess->name }, diff --git a/plugins/builtin/include/content/providers/udp_provider.hpp b/plugins/builtin/include/content/providers/udp_provider.hpp index 23964e97c..d153e471b 100644 --- a/plugins/builtin/include/content/providers/udp_provider.hpp +++ b/plugins/builtin/include/content/providers/udp_provider.hpp @@ -39,7 +39,7 @@ namespace hex::plugin::builtin { return "hex.builtin.provider.udp"; } - std::string getName() const override { return hex::format("hex.builtin.provider.udp.name"_lang, m_port); } + std::string getName() const override { return fmt::format("hex.builtin.provider.udp.name"_lang, m_port); } protected: void receive(std::span data); diff --git a/plugins/builtin/include/content/providers/undo_operations/operation_bookmark.hpp b/plugins/builtin/include/content/providers/undo_operations/operation_bookmark.hpp index 08572f7af..1a5c3ec4f 100644 --- a/plugins/builtin/include/content/providers/undo_operations/operation_bookmark.hpp +++ b/plugins/builtin/include/content/providers/undo_operations/operation_bookmark.hpp @@ -26,7 +26,7 @@ namespace hex::plugin::builtin::undo { } [[nodiscard]] std::string format() const override { - return hex::format("Bookmark {} created", m_entry.name); + return fmt::format("Bookmark {} created", m_entry.name); } std::unique_ptr clone() const override { diff --git a/plugins/builtin/include/content/providers/undo_operations/operation_insert.hpp b/plugins/builtin/include/content/providers/undo_operations/operation_insert.hpp index 94fe6bf96..8610a1d82 100644 --- a/plugins/builtin/include/content/providers/undo_operations/operation_insert.hpp +++ b/plugins/builtin/include/content/providers/undo_operations/operation_insert.hpp @@ -21,7 +21,7 @@ namespace hex::plugin::builtin::undo { } [[nodiscard]] std::string format() const override { - return hex::format("hex.builtin.undo_operation.insert"_lang, hex::toByteString(m_size), m_offset); + return fmt::format("hex.builtin.undo_operation.insert"_lang, hex::toByteString(m_size), m_offset); } std::unique_ptr clone() const override { diff --git a/plugins/builtin/include/content/providers/undo_operations/operation_remove.hpp b/plugins/builtin/include/content/providers/undo_operations/operation_remove.hpp index 2562ea7da..efba6d6c3 100644 --- a/plugins/builtin/include/content/providers/undo_operations/operation_remove.hpp +++ b/plugins/builtin/include/content/providers/undo_operations/operation_remove.hpp @@ -26,7 +26,7 @@ namespace hex::plugin::builtin::undo { } [[nodiscard]] std::string format() const override { - return hex::format("hex.builtin.undo_operation.remove"_lang, hex::toByteString(m_size), m_offset); + return fmt::format("hex.builtin.undo_operation.remove"_lang, hex::toByteString(m_size), m_offset); } std::unique_ptr clone() const override { diff --git a/plugins/builtin/include/content/providers/undo_operations/operation_write.hpp b/plugins/builtin/include/content/providers/undo_operations/operation_write.hpp index b571bca3d..1b8508710 100644 --- a/plugins/builtin/include/content/providers/undo_operations/operation_write.hpp +++ b/plugins/builtin/include/content/providers/undo_operations/operation_write.hpp @@ -26,12 +26,12 @@ namespace hex::plugin::builtin::undo { } [[nodiscard]] std::string format() const override { - return hex::format("hex.builtin.undo_operation.write"_lang, hex::toByteString(m_newData.size()), m_offset); + return fmt::format("hex.builtin.undo_operation.write"_lang, hex::toByteString(m_newData.size()), m_offset); } std::vector formatContent() const override { return { - hex::format("{} {} {}", hex::crypt::encode16(m_oldData), ICON_VS_ARROW_RIGHT, hex::crypt::encode16(m_newData)), + fmt::format("{} {} {}", hex::crypt::encode16(m_oldData), ICON_VS_ARROW_RIGHT, hex::crypt::encode16(m_newData)), }; } diff --git a/plugins/builtin/include/content/views/view_pattern_editor.hpp b/plugins/builtin/include/content/views/view_pattern_editor.hpp index f7f356df4..8172b1500 100644 --- a/plugins/builtin/include/content/views/view_pattern_editor.hpp +++ b/plugins/builtin/include/content/views/view_pattern_editor.hpp @@ -419,7 +419,7 @@ namespace hex::plugin::builtin { literal = std::get(it->value); string = std::get_if(&literal); if (string != nullptr) { - m_patternNames[path] = hex::format("{} ({})", *string, fileName); + m_patternNames[path] = fmt::format("{} ({})", *string, fileName); } } } diff --git a/plugins/builtin/source/content/background_services.cpp b/plugins/builtin/source/content/background_services.cpp index 0e1733581..96148643a 100644 --- a/plugins/builtin/source/content/background_services.cpp +++ b/plugins/builtin/source/content/background_services.cpp @@ -86,7 +86,7 @@ namespace hex::plugin::builtin { } for (const auto &path : paths::Backups.write()) { - const auto backupPath = path / hex::format("auto_backup.{:%y%m%d_%H%M%S}.hexproj", fmt::gmtime(std::chrono::system_clock::now())); + const auto backupPath = path / fmt::format("auto_backup.{:%y%m%d_%H%M%S}.hexproj", fmt::gmtime(std::chrono::system_clock::now())); if (ProjectFile::store(backupPath, false)) { log::info("Created auto-backup file '{}'", wolv::util::toUTF8String(backupPath)); break; diff --git a/plugins/builtin/source/content/command_line_interface.cpp b/plugins/builtin/source/content/command_line_interface.cpp index 07ebea558..e4b81d4c5 100644 --- a/plugins/builtin/source/content/command_line_interface.cpp +++ b/plugins/builtin/source/content/command_line_interface.cpp @@ -34,7 +34,7 @@ namespace hex::plugin::builtin { void handleVersionCommand(const std::vector &args) { std::ignore = args; - hex::log::print(std::string(romfs::get("logo.ans").string()), + hex::log::print(fmt::runtime(romfs::get("logo.ans").string()), ImHexApi::System::getImHexVersion().get(), ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash(), __DATE__, __TIME__, @@ -161,7 +161,7 @@ namespace hex::plugin::builtin { wolv::math_eval::MathEvaluator evaluator; - auto input = hex::format("{}", fmt::join(args, " ")); + auto input = fmt::format("{}", fmt::join(args, " ")); auto result = evaluator.evaluate(input); if (!result.has_value()) @@ -347,7 +347,7 @@ namespace hex::plugin::builtin { processedArgs.emplace_back("--help"); } else { for (const auto &path : paths::PatternsInclude.read()) - processedArgs.emplace_back(hex::format("--includes={}", wolv::util::toUTF8String(path))); + processedArgs.emplace_back(fmt::format("--includes={}", wolv::util::toUTF8String(path))); } std::exit(pl::cli::executeCommandLineInterface(processedArgs)); diff --git a/plugins/builtin/source/content/command_palette_commands.cpp b/plugins/builtin/source/content/command_palette_commands.cpp index e08cea03e..20112d415 100644 --- a/plugins/builtin/source/content/command_palette_commands.cpp +++ b/plugins/builtin/source/content/command_palette_commands.cpp @@ -77,17 +77,17 @@ namespace hex::plugin::builtin { case Unit::Unitless: case Unit::Decimal: if (isInteger) - return hex::format("{0}", i64(value / multipler)); + return fmt::format("{0}", i64(value / multipler)); else - return hex::format("{0:.3f}", double(value / multipler)); + return fmt::format("{0:.3f}", double(value / multipler)); case Unit::Hexadecimal: - return hex::format("0x{0:x}", u64(value / multipler)); + return fmt::format("0x{0:x}", u64(value / multipler)); case Unit::Binary: - return hex::format("0b{0:b}", u64(value / multipler)); + return fmt::format("0b{0:b}", u64(value / multipler)); case Unit::Octal: - return hex::format("0o{0:o}", u64(value / multipler)); + return fmt::format("0o{0:o}", u64(value / multipler)); case Unit::Bytes: - return hex::format("{0}", u64(value / multipler)); + return fmt::format("{0}", u64(value / multipler)); default: return "hex.builtin.command.convert.invalid_conversion"_lang; } @@ -100,17 +100,17 @@ namespace hex::plugin::builtin { case Unit::Bits: case Unit::Decimal: if (isInteger) - return hex::format("{0}", i64(value / multipler)); + return fmt::format("{0}", i64(value / multipler)); else - return hex::format("{0:.3f}", double(value / multipler)); + return fmt::format("{0:.3f}", double(value / multipler)); case Unit::Hexadecimal: - return hex::format("0x{0:x}", u64(value / multipler)); + return fmt::format("0x{0:x}", u64(value / multipler)); case Unit::Binary: - return hex::format("0b{0:b}", u64(value / multipler)); + return fmt::format("0b{0:b}", u64(value / multipler)); case Unit::Octal: - return hex::format("0o{0:o}", u64(value / multipler)); + return fmt::format("0o{0:o}", u64(value / multipler)); case Unit::Bytes: - return hex::format("{0}", u64((value / multipler) / 8)); + return fmt::format("{0}", u64((value / multipler) / 8)); default: return "hex.builtin.command.convert.invalid_conversion"_lang; } @@ -123,17 +123,17 @@ namespace hex::plugin::builtin { case Unit::Bytes: case Unit::Decimal: if (isInteger) - return hex::format("{0}", i64(value / multipler)); + return fmt::format("{0}", i64(value / multipler)); else - return hex::format("{0:.3f}", double(value / multipler)); + return fmt::format("{0:.3f}", double(value / multipler)); case Unit::Hexadecimal: - return hex::format("0x{0:x}", u64(value / multipler)); + return fmt::format("0x{0:x}", u64(value / multipler)); case Unit::Binary: - return hex::format("0b{0:b}", u64(value / multipler)); + return fmt::format("0b{0:b}", u64(value / multipler)); case Unit::Octal: - return hex::format("0o{0:o}", u64(value / multipler)); + return fmt::format("0o{0:o}", u64(value / multipler)); case Unit::Bits: - return hex::format("{0}", u64((value / multipler) * 8)); + return fmt::format("{0}", u64((value / multipler) * 8)); default: return "hex.builtin.command.convert.invalid_conversion"_lang; } @@ -260,9 +260,9 @@ namespace hex::plugin::builtin { std::optional result = evaluator.evaluate(input); if (result.has_value()) - return hex::format("{0} = {1}", input.data(), result.value()); + return fmt::format("{0} = {1}", input.data(), result.value()); else if (evaluator.hasError()) - return hex::format("Error: {}", *evaluator.getLastError()); + return fmt::format("Error: {}", *evaluator.getLastError()); else return std::string("???"); }, [](auto input) -> std::optional { @@ -272,7 +272,7 @@ namespace hex::plugin::builtin { std::optional result = evaluator.evaluate(input); if (result.has_value()) { - return hex::format("= {}", result.value()); + return fmt::format("= {}", result.value()); } else { return std::nullopt; } @@ -289,9 +289,9 @@ namespace hex::plugin::builtin { std::optional result = evaluator.evaluate(input); if (result.has_value()) - return hex::format("hex.builtin.command.goto.result"_lang, result.value()); + return fmt::format("hex.builtin.command.goto.result"_lang, result.value()); else if (evaluator.hasError()) - return hex::format("Error: {}", *evaluator.getLastError()); + return fmt::format("Error: {}", *evaluator.getLastError()); else return std::string("???"); }, [](auto input) -> std::optional { @@ -311,7 +311,7 @@ namespace hex::plugin::builtin { "/web", "hex.builtin.command.web.desc", [](auto input) { - return hex::format("hex.builtin.command.web.result"_lang, input.data()); + return fmt::format("hex.builtin.command.web.result"_lang, input.data()); }, [](auto input) { hex::openWebpage(input); @@ -323,7 +323,7 @@ namespace hex::plugin::builtin { "$", "hex.builtin.command.cmd.desc", [](auto input) { - return hex::format("hex.builtin.command.cmd.result"_lang, input.data()); + return fmt::format("hex.builtin.command.cmd.result"_lang, input.data()); }, [](auto input) { if (input.starts_with("imhex ")) { @@ -372,7 +372,7 @@ namespace hex::plugin::builtin { return result; }, [](auto input) { - return hex::format("Menu Item: {}", input.data()); + return fmt::format("Menu Item: {}", input.data()); }); ContentRegistry::CommandPaletteCommands::addHandler( @@ -398,7 +398,7 @@ namespace hex::plugin::builtin { return result; }, [](auto input) { - return hex::format("Provider: {}", input.data()); + return fmt::format("Provider: {}", input.data()); }); ContentRegistry::CommandPaletteCommands::add( diff --git a/plugins/builtin/source/content/data_formatters.cpp b/plugins/builtin/source/content/data_formatters.cpp index 5c0ae5671..21ead5754 100644 --- a/plugins/builtin/source/content/data_formatters.cpp +++ b/plugins/builtin/source/content/data_formatters.cpp @@ -19,7 +19,7 @@ namespace hex::plugin::builtin { constexpr static auto LineLength = 16; std::string result; - result.reserve(start.size() + hex::format(byteFormat, 0x00).size() * size + std::string(NewLineIndent).size() / LineLength + end.size()); + result.reserve(start.size() + fmt::format(fmt::runtime(byteFormat), 0x00).size() * size + std::string(NewLineIndent).size() / LineLength + end.size()); result += start; @@ -35,7 +35,7 @@ namespace hex::plugin::builtin { result += NewLineIndent; } - result += hex::format(byteFormat, byte); + result += fmt::format(fmt::runtime(byteFormat), byte); index++; } @@ -55,7 +55,7 @@ namespace hex::plugin::builtin { void registerDataFormatters() { ContentRegistry::DataFormatter::addExportMenuEntry("hex.builtin.view.hex_editor.copy.c", [](prv::Provider *provider, u64 offset, size_t size, bool) { - return formatLanguageArray(provider, offset, size, hex::format("const uint8_t data[{0}] = {{", size), "0x{0:02X}, ", "};"); + return formatLanguageArray(provider, offset, size, fmt::format("const uint8_t data[{0}] = {{", size), "0x{0:02X}, ", "};"); }); ContentRegistry::DataFormatter::addExportMenuEntry("hex.builtin.view.hex_editor.copy.cpp", [](prv::Provider *provider, u64 offset, size_t size, bool preview) { @@ -63,7 +63,7 @@ namespace hex::plugin::builtin { AchievementManager::unlockAchievement("hex.builtin.achievement.hex_editor", "hex.builtin.achievement.hex_editor.copy_as.name"); } - return formatLanguageArray(provider, offset, size, hex::format("constexpr std::array data = {{", size), "0x{0:02X}, ", "};"); + return formatLanguageArray(provider, offset, size, fmt::format("constexpr std::array data = {{", size), "0x{0:02X}, ", "};"); }); ContentRegistry::DataFormatter::addExportMenuEntry("hex.builtin.view.hex_editor.copy.java", [](prv::Provider *provider, u64 offset, size_t size, bool) { @@ -75,7 +75,7 @@ namespace hex::plugin::builtin { }); ContentRegistry::DataFormatter::addExportMenuEntry("hex.builtin.view.hex_editor.copy.rust", [](prv::Provider *provider, u64 offset, size_t size, bool) { - return formatLanguageArray(provider, offset, size, hex::format("let data: [u8; 0x{0:02X}] = [", size), "0x{0:02X}, ", "];"); + return formatLanguageArray(provider, offset, size, fmt::format("let data: [u8; 0x{0:02X}] = [", size), "0x{0:02X}, ", "];"); }); ContentRegistry::DataFormatter::addExportMenuEntry("hex.builtin.view.hex_editor.copy.python", [](prv::Provider *provider, u64 offset, size_t size, bool) { @@ -103,7 +103,7 @@ namespace hex::plugin::builtin { }); ContentRegistry::DataFormatter::addExportMenuEntry("hex.builtin.view.hex_editor.copy.pascal", [](prv::Provider *provider, u64 offset, size_t size, bool) { - return formatLanguageArray(provider, offset, size, hex::format("data: array[0..{0}] of Byte = (", size - 1), "${0:02X}, ", ")"); + return formatLanguageArray(provider, offset, size, fmt::format("data: array[0..{0}] of Byte = (", size - 1), "${0:02X}, ", ")"); }); ContentRegistry::DataFormatter::addExportMenuEntry("hex.builtin.view.hex_editor.copy.base64", [](prv::Provider *provider, u64 offset, size_t size, bool) { @@ -158,8 +158,8 @@ namespace hex::plugin::builtin { std::string asciiRow; for (u8 byte : reader) { if ((address % 0x10) == 0) { - result += hex::format(" {}", asciiRow); - result += hex::format("
\n {0:08X}  ", address); + result += fmt::format(" {}", asciiRow); + result += fmt::format("
\n {0:08X}  ", address); asciiRow.clear(); @@ -180,7 +180,7 @@ namespace hex::plugin::builtin { tagEnd = ""; } - result += hex::format("{0}{2:02X}{1} ", tagStart, tagEnd, byte); + result += fmt::format("{0}{2:02X}{1} ", tagStart, tagEnd, byte); asciiRow += html_safe(byte); if ((address % 0x10) == 0x07) result += " "; diff --git a/plugins/builtin/source/content/data_information_sections.cpp b/plugins/builtin/source/content/data_information_sections.cpp index bf7390eb8..0a6fa08da 100644 --- a/plugins/builtin/source/content/data_information_sections.cpp +++ b/plugins/builtin/source/content/data_information_sections.cpp @@ -275,7 +275,7 @@ namespace hex::plugin::builtin { ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.1F); ImGui::PushStyleColor(ImGuiCol_FrameBg, ImGui::GetColorU32(ImGuiCol_TableRowBgAlt)); ImGui::PushStyleColor(ImGuiCol_PlotHistogram, ImColor::HSV(0.3F - (0.3F * entropy), 0.6F, 0.8F, 1.0F).Value); - ImGui::ProgressBar(entropy, ImVec2(200_scaled, ImGui::GetTextLineHeight()), hex::format("{:.5f}", entropy).c_str()); + ImGui::ProgressBar(entropy, ImVec2(200_scaled, ImGui::GetTextLineHeight()), fmt::format("{:.5f}", entropy).c_str()); ImGui::PopStyleColor(2); ImGui::PopStyleVar(); } @@ -295,7 +295,7 @@ namespace hex::plugin::builtin { ImGui::PushID("##HighestBlockEntropyAddress"); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - if (ImGui::Button(hex::format("0x{:06X}", m_highestBlockEntropyAddress).c_str())) { + if (ImGui::Button(fmt::format("0x{:06X}", m_highestBlockEntropyAddress).c_str())) { ImHexApi::HexEditor::setSelection(m_highestBlockEntropyAddress, m_inputChunkSize); } ImGui::PopStyleColor(); @@ -319,7 +319,7 @@ namespace hex::plugin::builtin { ImGui::PushID("##LowestBlockEntropyAddress"); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - if (ImGui::Button(hex::format("0x{:06X}", m_lowestBlockEntropyAddress).c_str())) { + if (ImGui::Button(fmt::format("0x{:06X}", m_lowestBlockEntropyAddress).c_str())) { ImHexApi::HexEditor::setSelection(m_lowestBlockEntropyAddress, m_inputChunkSize); } ImGui::PopStyleColor(); diff --git a/plugins/builtin/source/content/data_inspector.cpp b/plugins/builtin/source/content/data_inspector.cpp index 18d99c07c..b0a4df360 100644 --- a/plugins/builtin/source/content/data_inspector.cpp +++ b/plugins/builtin/source/content/data_inspector.cpp @@ -105,8 +105,8 @@ namespace hex::plugin::builtin { if (buffer.size() < Size) return { }; - const auto formatString = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? hex::format("0x{{0:0{}X}}", Size * 2) : hex::format("0o{{0:0{}o}}", Size * 3)); - return hex::format(formatString, bufferToInteger(buffer, endian)); + const auto formatString = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? fmt::format("0x{{0:0{}X}}", Size * 2) : fmt::format("0o{{0:0{}o}}", Size * 3)); + return fmt::format(fmt::runtime(formatString), bufferToInteger(buffer, endian)); } template @@ -146,7 +146,7 @@ namespace hex::plugin::builtin { std::ignore = endian; std::ignore = style; - std::string binary = hex::format("0b{:08b}", buffer[0]); + std::string binary = fmt::format("0b{:08b}", buffer[0]); return [binary] { ImGui::TextUnformatted(binary.c_str()); @@ -237,7 +237,7 @@ namespace hex::plugin::builtin { const auto formatString = style == Style::Hexadecimal ? "{0:a}" : "{0:G}"; - auto value = hex::format(formatString, customFloatToFloat32<5, 10>(hex::changeEndianness(result, endian))); + auto value = fmt::format(fmt::runtime(formatString), customFloatToFloat32<5, 10>(hex::changeEndianness(result, endian))); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; } @@ -250,7 +250,7 @@ namespace hex::plugin::builtin { const auto formatString = style == Style::Hexadecimal ? "{0:a}" : "{0:G}"; - auto value = hex::format(formatString, hex::changeEndianness(result, endian)); + auto value = fmt::format(fmt::runtime(formatString), hex::changeEndianness(result, endian)); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; }, stringToFloat @@ -263,7 +263,7 @@ namespace hex::plugin::builtin { const auto formatString = style == Style::Hexadecimal ? "{0:a}" : "{0:G}"; - auto value = hex::format(formatString, hex::changeEndianness(result, endian)); + auto value = fmt::format(fmt::runtime(formatString), hex::changeEndianness(result, endian)); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; }, stringToFloat @@ -276,7 +276,7 @@ namespace hex::plugin::builtin { const auto formatString = style == Style::Hexadecimal ? "{0:a}" : "{0:G}"; - auto value = hex::format(formatString, hex::changeEndianness(result, endian)); + auto value = fmt::format(fmt::runtime(formatString), hex::changeEndianness(result, endian)); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; }, stringToFloat @@ -289,7 +289,7 @@ namespace hex::plugin::builtin { const auto formatString = style == Style::Hexadecimal ? "{0:a}" : "{0:G}"; - auto value = hex::format(formatString, customFloatToFloat32<8, 7>(hex::changeEndianness(result, endian))); + auto value = fmt::format(fmt::runtime(formatString), customFloatToFloat32<8, 7>(hex::changeEndianness(result, endian))); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; } @@ -302,7 +302,7 @@ namespace hex::plugin::builtin { const auto formatString = style == Style::Hexadecimal ? "{0:a}" : "{0:G}"; - auto value = hex::format(formatString, customFloatToFloat32<7, 16>(hex::changeEndianness(result, endian))); + auto value = fmt::format(fmt::runtime(formatString), customFloatToFloat32<7, 16>(hex::changeEndianness(result, endian))); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; } @@ -312,12 +312,11 @@ namespace hex::plugin::builtin { [](auto buffer, auto endian, auto style) { std::ignore = endian; - auto format = (style == Style::Decimal) ? "{0}{1:d}" : ((style == Style::Hexadecimal) ? "{0}0x{1:X}" : "{0}0o{1:o}"); - + auto formatString = (style == Style::Decimal) ? "{0}{1:d}" : ((style == Style::Hexadecimal) ? "{0}0x{1:X}" : "{0}0o{1:o}"); auto number = hex::crypt::decodeSleb128(buffer); bool negative = number < 0; - auto value = hex::format(format, negative ? "-" : "", negative ? -number : number); + auto value = fmt::format(fmt::runtime(formatString), negative ? "-" : "", negative ? -number : number); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; }, @@ -332,9 +331,9 @@ namespace hex::plugin::builtin { [](auto buffer, auto endian, auto style) { std::ignore = endian; - auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "0o{0:o}"); + auto formatString = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "0o{0:o}"); - auto value = hex::format(format, hex::crypt::decodeUleb128(buffer)); + auto value = fmt::format(fmt::runtime(formatString), hex::crypt::decodeUleb128(buffer)); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; }, @@ -391,7 +390,7 @@ namespace hex::plugin::builtin { auto c = hex::changeEndianness(wideChar, endian); - auto value = hex::format("{0}", c <= 255 ? makePrintable(c) : wolv::util::wstringToUtf8(std::wstring(&c, 1)).value_or("???")); + auto value = fmt::format("{0}", c <= 255 ? makePrintable(c) : wolv::util::wstringToUtf8(std::wstring(&c, 1)).value_or("???")); return [value] { ImGuiExt::TextFormatted("'{0}'", value.c_str()); return value; }; }, [](const std::string &value, std::endian endian) -> std::vector { @@ -419,7 +418,7 @@ namespace hex::plugin::builtin { auto c = hex::changeEndianness(wideChar, endian); - auto value = hex::format("{0}", c <= 255 ? makePrintable(c) : wolv::util::utf16ToUtf8(std::u16string(&c, 1)).value_or("???")); + auto value = fmt::format("{0}", c <= 255 ? makePrintable(c) : wolv::util::utf16ToUtf8(std::u16string(&c, 1)).value_or("???")); return [value] { ImGuiExt::TextFormatted("'{0}'", value.c_str()); return value; }; }, [](const std::string &value, std::endian endian) -> std::vector { @@ -447,7 +446,7 @@ namespace hex::plugin::builtin { auto c = hex::changeEndianness(wideChar, endian); - auto value = hex::format("{0}", c <= 255 ? makePrintable(c) : wolv::util::utf32ToUtf8(std::u32string(&c, 1)).value_or("???")); + auto value = fmt::format("{0}", c <= 255 ? makePrintable(c) : wolv::util::utf32ToUtf8(std::u32string(&c, 1)).value_or("???")); return [value] { ImGuiExt::TextFormatted("'{0}'", value.c_str()); return value; }; }, [](const std::string &value, std::endian endian) -> std::vector { @@ -479,7 +478,7 @@ namespace hex::plugin::builtin { u8 codepointSize = ImTextCharFromUtf8(&codepoint, utf8Buffer, nullptr); std::memcpy(codepointString, utf8Buffer, std::min(codepointSize, u8(4))); - auto value = hex::format("'{0}' (U+0x{1:04X})", + auto value = fmt::format("'{0}' (U+0x{1:04X})", codepoint == 0xFFFD ? "Invalid" : (codepointSize == 1 ? makePrintable(codepointString[0]) : codepointString), codepoint); @@ -714,7 +713,7 @@ namespace hex::plugin::builtin { if (time == nullptr) { value = "Invalid"; } else { - value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", *time); + value = fmt::format("{0:%a, %d.%m.%Y %H:%M:%S}", *time); } } catch (fmt::format_error &) { value = "Invalid"; @@ -734,7 +733,7 @@ namespace hex::plugin::builtin { if (time == nullptr) { value = "Invalid"; } else { - value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", *time); + value = fmt::format("{0:%a, %d.%m.%Y %H:%M:%S}", *time); } } catch (fmt::format_error &) { value = "Invalid"; @@ -756,7 +755,7 @@ namespace hex::plugin::builtin { if (time == nullptr) { value = "Invalid"; } else { - value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", *time); + value = fmt::format("{0:%a, %d.%m.%Y %H:%M:%S}", *time); } } catch (const fmt::format_error &e) { value = "Invalid"; @@ -786,7 +785,7 @@ namespace hex::plugin::builtin { std::memcpy(&date, buffer.data(), sizeof(DOSDate)); date = hex::changeEndianness(date, endian); - auto value = hex::format("{}/{}/{}", date.day, date.month, date.year + 1980); + auto value = fmt::format("{}/{}/{}", u8(date.day), u8(date.month), u8(date.year) + 1980); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; }); @@ -798,7 +797,7 @@ namespace hex::plugin::builtin { std::memcpy(&time, buffer.data(), sizeof(DOSTime)); time = hex::changeEndianness(time, endian); - auto value = hex::format("{:02}:{:02}:{:02}", time.hours, time.minutes, time.seconds * 2); + auto value = fmt::format("{:02}:{:02}:{:02}", u8(time.hours), u8(time.minutes), u8(time.seconds) * 2); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; }); @@ -808,7 +807,7 @@ namespace hex::plugin::builtin { GUID guid = { }; std::memcpy(&guid, buffer.data(), sizeof(GUID)); - auto value = hex::format("{}{{{:08X}-{:04X}-{:04X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}}}", + auto value = fmt::format("{}{{{:08X}-{:04X}-{:04X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}}}", (hex::changeEndianness(guid.data3, endian) >> 12) <= 5 && ((guid.data4[0] >> 4) >= 8 || (guid.data4[0] >> 4) == 0) ? "" : "Invalid ", hex::changeEndianness(guid.data1, endian), hex::changeEndianness(guid.data2, endian), @@ -830,7 +829,7 @@ namespace hex::plugin::builtin { ImColor value(hex::changeEndianness(*reinterpret_cast(buffer.data()), endian)); - auto copyValue = hex::format("#{:02X}{:02X}{:02X}{:02X}", u8(0xFF * (value.Value.x)), u8(0xFF * (value.Value.y)), u8(0xFF * (value.Value.z)), u8(0xFF * (value.Value.w))); + auto copyValue = fmt::format("#{:02X}{:02X}{:02X}{:02X}", u8(0xFF * (value.Value.x)), u8(0xFF * (value.Value.y)), u8(0xFF * (value.Value.z)), u8(0xFF * (value.Value.w))); return [value, copyValue] { ImGui::ColorButton("##inspectorColor", value, ImGuiColorEditFlags_None, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight())); @@ -844,7 +843,7 @@ namespace hex::plugin::builtin { auto value = hex::changeEndianness(*reinterpret_cast(buffer.data()), endian); ImColor color((value & 0x1F) << 3, ((value >> 5) & 0x3F) << 2, ((value >> 11) & 0x1F) << 3, 0xFF); - auto copyValue = hex::format("#{:02X}{:02X}{:02X}", u8(0xFF * (color.Value.x)), u8(0xFF * (color.Value.y)), u8(0xFF * (color.Value.z)), 0xFF); + auto copyValue = fmt::format("#{:02X}{:02X}{:02X}", u8(0xFF * (color.Value.x)), u8(0xFF * (color.Value.y)), u8(0xFF * (color.Value.z)), 0xFF); return [color, copyValue] { ImGui::ColorButton("##inspectorColor", color, ImGuiColorEditFlags_AlphaOpaque, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight())); diff --git a/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp index 74d83e49d..ecd3d9bb4 100644 --- a/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp @@ -341,7 +341,7 @@ namespace hex::plugin::builtin { const size_t requiredBytes = width * height * 4; if (requiredBytes > rawData.size()) - throwNodeError(hex::format("Image requires at least {} bytes of data, but only {} bytes are available", requiredBytes, rawData.size())); + throwNodeError(fmt::format("Image requires at least {} bytes of data, but only {} bytes are available", requiredBytes, rawData.size())); m_data = rawData; m_width = width; @@ -430,7 +430,7 @@ namespace hex::plugin::builtin { } }, outVars.at(m_name)); } else { - throwNodeError(hex::format("Out variable '{}' has not been defined!", m_name)); + throwNodeError(fmt::format("Out variable '{}' has not been defined!", m_name)); } } diff --git a/plugins/builtin/source/content/data_processor_nodes/visual_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/visual_nodes.cpp index e7628badc..1858597b5 100644 --- a/plugins/builtin/source/content/data_processor_nodes/visual_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/visual_nodes.cpp @@ -78,10 +78,10 @@ namespace hex::plugin::builtin { for (auto y = clipper.DisplayStart; y < clipper.DisplayEnd; y++) { auto lineSize = ((size - y * 0x10) < 0x10) ? size % 0x10 : 0x10; - std::string line = hex::format(" {:08X}: ", y * 0x10); + std::string line = fmt::format(" {:08X}: ", y * 0x10); for (u32 x = 0; x < 0x10; x++) { if (x < lineSize) - line += hex::format("{:02X} ", m_buffer[y * 0x10 + x]); + line += fmt::format("{:02X} ", m_buffer[y * 0x10 + x]); else line += " "; diff --git a/plugins/builtin/source/content/data_visualizers.cpp b/plugins/builtin/source/content/data_visualizers.cpp index bf1b2c4b4..8d60dc76e 100644 --- a/plugins/builtin/source/content/data_visualizers.cpp +++ b/plugins/builtin/source/content/data_visualizers.cpp @@ -39,8 +39,8 @@ namespace hex::plugin::builtin { constexpr static auto ByteCount = sizeof(T); constexpr static auto CharCount = ByteCount * 2; - const static inline auto FormattingUpperCase = hex::format("%0{}{}X", CharCount, ImGuiExt::getFormatLengthSpecifier()); - const static inline auto FormattingLowerCase = hex::format("%0{}{}x", CharCount, ImGuiExt::getFormatLengthSpecifier()); + const static inline auto FormattingUpperCase = fmt::format("%0{}{}X", CharCount, ImGuiExt::getFormatLengthSpecifier()); + const static inline auto FormattingLowerCase = fmt::format("%0{}{}x", CharCount, ImGuiExt::getFormatLengthSpecifier()); const char *getFormatString(bool upperCase) { if (upperCase) @@ -93,8 +93,8 @@ namespace hex::plugin::builtin { constexpr static inline auto ByteCount = 1; constexpr static inline auto CharCount = ByteCount * 2; - const static inline auto FormattingUpperCase = hex::format("%0{}{}X", CharCount, ImGuiExt::getFormatLengthSpecifier()); - const static inline auto FormattingLowerCase = hex::format("%0{}{}x", CharCount, ImGuiExt::getFormatLengthSpecifier()); + const static inline auto FormattingUpperCase = fmt::format("%0{}{}X", CharCount, ImGuiExt::getFormatLengthSpecifier()); + const static inline auto FormattingLowerCase = fmt::format("%0{}{}x", CharCount, ImGuiExt::getFormatLengthSpecifier()); static const char *getFormatString(bool upperCase) { if (upperCase) @@ -139,7 +139,7 @@ namespace hex::plugin::builtin { constexpr static auto ByteCount = sizeof(T); constexpr static auto CharCount = std::numeric_limits::digits10 + 2; - const static inline auto FormatString = hex::format("%{}{}{}", CharCount, ImGuiExt::getFormatLengthSpecifier(), std::is_signed_v ? "d" : "u"); + const static inline auto FormatString = fmt::format("%{}{}{}", CharCount, ImGuiExt::getFormatLengthSpecifier(), std::is_signed_v ? "d" : "u"); const char *getFormatString() { return FormatString.c_str(); @@ -178,8 +178,8 @@ namespace hex::plugin::builtin { constexpr static inline auto ByteCount = sizeof(T); constexpr static inline auto CharCount = 14; - const static inline auto FormatStringUpperCase = hex::format("%{}G", CharCount); - const static inline auto FormatStringLowerCase = hex::format("%{}g", CharCount); + const static inline auto FormatStringUpperCase = fmt::format("%{}G", CharCount); + const static inline auto FormatStringLowerCase = fmt::format("%{}g", CharCount); const char *getFormatString(bool upperCase) const { if (upperCase) @@ -214,8 +214,8 @@ namespace hex::plugin::builtin { constexpr static auto ByteCount = sizeof(Float16); constexpr static auto CharCount = 14; - const static inline auto FormatStringUpperCase = hex::format("%{}G", CharCount); - const static inline auto FormatStringLowerCase = hex::format("%{}g", CharCount); + const static inline auto FormatStringUpperCase = fmt::format("%{}G", CharCount); + const static inline auto FormatStringLowerCase = fmt::format("%{}g", CharCount); static const char *getFormatString(bool upperCase) { if (upperCase) @@ -285,7 +285,7 @@ namespace hex::plugin::builtin { std::ignore = startedEditing; if (startedEditing) { - m_inputBuffer = hex::format("{:08b}", *data); + m_inputBuffer = fmt::format("{:08b}", *data); } if (drawDefaultTextEditingTextBox(address, m_inputBuffer, ImGuiInputTextFlags_None)) { diff --git a/plugins/builtin/source/content/events.cpp b/plugins/builtin/source/content/events.cpp index 65ddd2cda..00d8d0206 100644 --- a/plugins/builtin/source/content/events.cpp +++ b/plugins/builtin/source/content/events.cpp @@ -40,7 +40,7 @@ namespace hex::plugin::builtin { static void openFile(const std::fs::path &path) { if (path.extension() == ".hexproj") { if (!ProjectFile::load(path)) { - ui::ToastError::open(hex::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(path))); + ui::ToastError::open(fmt::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(path))); } return; @@ -50,7 +50,7 @@ namespace hex::plugin::builtin { if (auto *fileProvider = dynamic_cast(provider); fileProvider != nullptr) { fileProvider->setPath(path); if (!provider->open() || !provider->isAvailable()) { - ui::ToastError::open(hex::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage())); + ui::ToastError::open(fmt::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage())); TaskManager::doLater([provider] { ImHexApi::Provider::remove(provider); }); } else { EventProviderOpened::post(fileProvider); @@ -187,7 +187,7 @@ namespace hex::plugin::builtin { fs::openFileBrowser(fs::DialogMode::Open, { }, [](const auto &path) { if (path.extension() == ".hexproj") { if (!ProjectFile::load(path)) { - ui::ToastError::open(hex::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(path))); + ui::ToastError::open(fmt::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(path))); } else { return; } @@ -212,7 +212,7 @@ namespace hex::plugin::builtin { fs::openFileBrowser(fs::DialogMode::Open, { {"Project File", "hexproj"} }, [](const auto &path) { if (!ProjectFile::load(path)) { - ui::ToastError::open(hex::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(path))); + ui::ToastError::open(fmt::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(path))); } }); } @@ -235,7 +235,7 @@ namespace hex::plugin::builtin { TaskManager::createBlockingTask("hex.builtin.provider.opening", TaskManager::NoProgress, [provider]() { if (!provider->open()) { - ui::ToastError::open(hex::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage())); + ui::ToastError::open(fmt::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage())); TaskManager::doLater([provider] { ImHexApi::Provider::remove(provider); }); } else { TaskManager::doLater([provider]{ EventProviderOpened::post(provider); }); @@ -245,7 +245,7 @@ namespace hex::plugin::builtin { else if (dynamic_cast(provider) == nullptr) { TaskManager::createBlockingTask("hex.builtin.provider.opening", TaskManager::NoProgress, [provider]() { if (!provider->open() || !provider->isAvailable()) { - ui::ToastError::open(hex::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage())); + ui::ToastError::open(fmt::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage())); TaskManager::doLater([provider] { ImHexApi::Provider::remove(provider); }); } else { TaskManager::doLater([provider]{ EventProviderOpened::post(provider); }); @@ -358,9 +358,9 @@ namespace hex::plugin::builtin { fs::setFileBrowserErrorCallback([](const std::string& errMsg){ #if defined(NFD_PORTAL) - ui::PopupError::open(hex::format("hex.builtin.popup.error.file_dialog.portal"_lang, errMsg)); + ui::PopupError::open(fmt::format("hex.builtin.popup.error.file_dialog.portal"_lang, errMsg)); #else - ui::PopupError::open(hex::format("hex.builtin.popup.error.file_dialog.common"_lang, errMsg)); + ui::PopupError::open(fmt::format("hex.builtin.popup.error.file_dialog.common"_lang, errMsg)); #endif }); diff --git a/plugins/builtin/source/content/global_actions.cpp b/plugins/builtin/source/content/global_actions.cpp index c9b3f69a6..60e6c1052 100644 --- a/plugins/builtin/source/content/global_actions.cpp +++ b/plugins/builtin/source/content/global_actions.cpp @@ -14,7 +14,7 @@ namespace hex::plugin::builtin { fs::openFileBrowser(fs::DialogMode::Open, { {"Project File", "hexproj"} }, [](const auto &path) { if (!ProjectFile::load(path)) { - ui::ToastError::open(hex::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(path))); + ui::ToastError::open(fmt::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(path))); } }); } diff --git a/plugins/builtin/source/content/main_menu_items.cpp b/plugins/builtin/source/content/main_menu_items.cpp index cdea529c2..7ab26f47f 100644 --- a/plugins/builtin/source/content/main_menu_items.cpp +++ b/plugins/builtin/source/content/main_menu_items.cpp @@ -250,7 +250,7 @@ namespace hex::plugin::builtin { std::string data; for (const auto &provider : ImHexApi::Provider::getProviders()) { - data += hex::format("# {}", provider->getName()); + data += fmt::format("# {}", provider->getName()); data += "\n\n"; for (const auto &generator : ContentRegistry::Reports::impl::getGenerators()) { @@ -586,7 +586,7 @@ namespace hex::plugin::builtin { bool shiftPressed = ImGui::GetIO().KeyShift; for (auto &[name, path] : LayoutManager::getLayouts()) { - if (menu::menuItem(hex::format("{}{}", name, shiftPressed ? " " ICON_VS_CHROME_CLOSE : "").c_str(), Shortcut::None, false, ImHexApi::Provider::isValid())) { + if (menu::menuItem(fmt::format("{}{}", name, shiftPressed ? " " ICON_VS_CHROME_CLOSE : "").c_str(), Shortcut::None, false, ImHexApi::Provider::isValid())) { if (shiftPressed) { LayoutManager::removeLayout(name); break; @@ -619,7 +619,7 @@ namespace hex::plugin::builtin { const auto &[name, workspace] = *it; bool canRemove = shiftPressed && !workspace.builtin; - if (menu::menuItem(hex::format("{}{}", name, canRemove ? " " ICON_VS_CHROME_CLOSE : "").c_str(), Shortcut::None, it == WorkspaceManager::getCurrentWorkspace(), ImHexApi::Provider::isValid())) { + if (menu::menuItem(fmt::format("{}{}", name, canRemove ? " " ICON_VS_CHROME_CLOSE : "").c_str(), Shortcut::None, it == WorkspaceManager::getCurrentWorkspace(), ImHexApi::Provider::isValid())) { if (canRemove) { WorkspaceManager::removeWorkspace(name); break; diff --git a/plugins/builtin/source/content/out_of_box_experience.cpp b/plugins/builtin/source/content/out_of_box_experience.cpp index 8e11970a4..c8eb6825f 100644 --- a/plugins/builtin/source/content/out_of_box_experience.cpp +++ b/plugins/builtin/source/content/out_of_box_experience.cpp @@ -184,7 +184,7 @@ namespace hex::plugin::builtin { const auto buttonSize = scaled({ 100, 50 }); ImGui::SetCursorPos(ImHexApi::System::getMainWindowSize() - buttonSize - scaled({ 10, 10 })); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, buttonFadeIn); - if (ImGuiExt::DimmedButton(hex::format("{} {}", "hex.ui.common.continue"_lang, ICON_VS_ARROW_RIGHT).c_str(), buttonSize)) + if (ImGuiExt::DimmedButton(fmt::format("{} {}", "hex.ui.common.continue"_lang, ICON_VS_ARROW_RIGHT).c_str(), buttonSize)) page += 1; ImGui::PopStyleVar(); } @@ -259,7 +259,7 @@ namespace hex::plugin::builtin { // Continue button const auto buttonSize = scaled({ 100, 50 }); ImGui::SetCursorPos(ImHexApi::System::getMainWindowSize() - buttonSize - scaled({ 10, 10 })); - if (ImGuiExt::DimmedButton(hex::format("{} {}", "hex.ui.common.continue"_lang, ICON_VS_ARROW_RIGHT).c_str(), buttonSize)) + if (ImGuiExt::DimmedButton(fmt::format("{} {}", "hex.ui.common.continue"_lang, ICON_VS_ARROW_RIGHT).c_str(), buttonSize)) page += 1; break; @@ -446,7 +446,7 @@ namespace hex::plugin::builtin { ImHexApi::System::setWindowResizable(false); const auto imageTheme = ThemeManager::getImageTheme(); - s_imhexBanner = ImGuiExt::Texture::fromSVG(romfs::get(hex::format("assets/{}/banner.svg", imageTheme)).span()); + s_imhexBanner = ImGuiExt::Texture::fromSVG(romfs::get(fmt::format("assets/{}/banner.svg", imageTheme)).span()); s_compassTexture = ImGuiExt::Texture::fromImage(romfs::get("assets/common/compass.png").span()); s_globeTexture = ImGuiExt::Texture::fromImage(romfs::get("assets/common/globe.png").span()); s_screenshotDescriptions = nlohmann::json::parse(romfs::get("assets/screenshot_descriptions.json").string()); diff --git a/plugins/builtin/source/content/project.cpp b/plugins/builtin/source/content/project.cpp index c20e5a1ac..1b15bf345 100644 --- a/plugins/builtin/source/content/project.cpp +++ b/plugins/builtin/source/content/project.cpp @@ -24,8 +24,8 @@ namespace hex::plugin::builtin { bool load(const std::fs::path &filePath) { if (!wolv::io::fs::exists(filePath) || !wolv::io::fs::isRegularFile(filePath)) { - ui::ToastError::open(hex::format("hex.builtin.popup.error.project.load"_lang, - hex::format("hex.builtin.popup.error.project.load.file_not_found"_lang, + ui::ToastError::open(fmt::format("hex.builtin.popup.error.project.load"_lang, + fmt::format("hex.builtin.popup.error.project.load.file_not_found"_lang, wolv::util::toUTF8String(filePath) ))); @@ -34,8 +34,8 @@ namespace hex::plugin::builtin { Tar tar(filePath, Tar::Mode::Read); if (!tar.isValid()) { - ui::ToastError::open(hex::format("hex.builtin.popup.error.project.load"_lang, - hex::format("hex.builtin.popup.error.project.load.invalid_tar"_lang, + ui::ToastError::open(fmt::format("hex.builtin.popup.error.project.load"_lang, + fmt::format("hex.builtin.popup.error.project.load.invalid_tar"_lang, tar.getOpenErrorString() ))); @@ -43,8 +43,8 @@ namespace hex::plugin::builtin { } if (!tar.contains(MetadataPath)) { - ui::ToastError::open(hex::format("hex.builtin.popup.error.project.load"_lang, - hex::format("hex.builtin.popup.error.project.load.invalid_magic"_lang) + ui::ToastError::open(fmt::format("hex.builtin.popup.error.project.load"_lang, + fmt::format("hex.builtin.popup.error.project.load.invalid_magic"_lang) )); return false; @@ -54,8 +54,8 @@ namespace hex::plugin::builtin { const auto metadataContent = tar.readVector(MetadataPath); if (!std::string(metadataContent.begin(), metadataContent.end()).starts_with(MetadataHeaderMagic)) { - ui::ToastError::open(hex::format("hex.builtin.popup.error.project.load"_lang, - hex::format("hex.builtin.popup.error.project.load.invalid_magic"_lang) + ui::ToastError::open(fmt::format("hex.builtin.popup.error.project.load"_lang, + fmt::format("hex.builtin.popup.error.project.load.invalid_magic"_lang) )); return false; @@ -159,7 +159,7 @@ namespace hex::plugin::builtin { } { - const auto metadataContent = hex::format("{}\n{}", MetadataHeaderMagic, ImHexApi::System::getImHexVersion().get(false)); + const auto metadataContent = fmt::format("{}\n{}", MetadataHeaderMagic, ImHexApi::System::getImHexVersion().get(false)); tar.writeString(MetadataPath, metadataContent); } diff --git a/plugins/builtin/source/content/providers.cpp b/plugins/builtin/source/content/providers.cpp index fa6e0a2fc..d704bb352 100644 --- a/plugins/builtin/source/content/providers.cpp +++ b/plugins/builtin/source/content/providers.cpp @@ -53,7 +53,7 @@ namespace hex::plugin::builtin { bool success = true; std::map providerWarnings; for (const auto &id : providerIds) { - auto providerSettings = nlohmann::json::parse(tar.readString(basePath / hex::format("{}.json", id))); + auto providerSettings = nlohmann::json::parse(tar.readString(basePath / fmt::format("{}.json", id))); auto providerType = providerSettings.at("type").get(); auto newProvider = ImHexApi::Provider::createProvider(providerType, true, false); @@ -73,8 +73,8 @@ namespace hex::plugin::builtin { // If a provider is not created, it will be overwritten when saving the project, // so we should prevent the project from loading at all ui::ToastError::open( - hex::format("hex.builtin.popup.error.project.load"_lang, - hex::format("hex.builtin.popup.error.project.load.create_provider"_lang, providerType) + fmt::format("hex.builtin.popup.error.project.load"_lang, + fmt::format("hex.builtin.popup.error.project.load.create_provider"_lang, providerType) ) ); success = false; @@ -102,13 +102,13 @@ namespace hex::plugin::builtin { for (const auto &warning : providerWarnings){ ImHexApi::Provider::remove(warning.first); warningMessage.append( - hex::format("\n - {} : {}", warning.first->getName(), warning.second)); + fmt::format("\n - {} : {}", warning.first->getName(), warning.second)); } // If no providers were opened, display an error with // the warnings that happened when opening them if (ImHexApi::Provider::getProviders().empty()) { - ui::ToastError::open(hex::format("{}{}", "hex.builtin.popup.error.project.load"_lang, "hex.builtin.popup.error.project.load.no_providers"_lang, warningMessage)); + ui::ToastError::open(fmt::format("{}{}", "hex.builtin.popup.error.project.load"_lang, "hex.builtin.popup.error.project.load.no_providers"_lang, warningMessage)); return false; } else { @@ -116,7 +116,7 @@ namespace hex::plugin::builtin { if (warningMessage.empty()) { return true; } else { - ui::ToastWarning::open(hex::format("hex.builtin.popup.error.project.load.some_providers_failed"_lang, warningMessage)); + ui::ToastWarning::open(fmt::format("hex.builtin.popup.error.project.load.some_providers_failed"_lang, warningMessage)); } return success; @@ -132,7 +132,7 @@ namespace hex::plugin::builtin { json["type"] = provider->getTypeName(); json["settings"] = provider->storeSettings({}); - tar.writeString(basePath / hex::format("{}.json", id), json.dump(4)); + tar.writeString(basePath / fmt::format("{}.json", id), json.dump(4)); } tar.writeString(basePath / "providers.json", diff --git a/plugins/builtin/source/content/providers/disk_provider.cpp b/plugins/builtin/source/content/providers/disk_provider.cpp index ae1349653..731e74927 100644 --- a/plugins/builtin/source/content/providers/disk_provider.cpp +++ b/plugins/builtin/source/content/providers/disk_provider.cpp @@ -207,15 +207,15 @@ namespace hex::plugin::builtin { m_diskHandle = ::open(path.c_str(), O_RDWR); if (m_diskHandle == -1) { - this->setErrorMessage(hex::format("hex.builtin.provider.disk.error.read_rw"_lang, path, formatSystemError(errno))); - log::warn(this->getErrorMessage()); + this->setErrorMessage(fmt::format("hex.builtin.provider.disk.error.read_rw"_lang, path, formatSystemError(errno))); + log::warn("{}", this->getErrorMessage()); m_diskHandle = ::open(path.c_str(), O_RDONLY); m_writable = false; } if (m_diskHandle == -1) { - this->setErrorMessage(hex::format("hex.builtin.provider.disk.error.read_ro"_lang, path, formatSystemError(errno))); - log::warn(this->getErrorMessage()); + this->setErrorMessage(fmt::format("hex.builtin.provider.disk.error.read_ro"_lang, path, formatSystemError(errno))); + log::warn("{}", this->getErrorMessage()); m_readable = false; return false; } @@ -442,7 +442,7 @@ namespace hex::plugin::builtin { for (char i = 0; i < 26; i++) { if (drives[i]) { char letter = 'A' + i; - m_availableDrives.insert({ hex::format(R"(\\.\{:c}:)", letter), hex::format(R"({:c}:/)", letter) }); + m_availableDrives.insert({ fmt::format(R"(\\.\{:c}:)", letter), fmt::format(R"({:c}:/)", letter) }); } } diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index f4bbff73e..d5e813008 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -135,13 +135,13 @@ namespace hex::plugin::builtin { if (m_fileStats.has_value()) { std::string creationTime, accessTime, modificationTime; - try { creationTime = hex::format("{:%Y-%m-%d %H:%M:%S}", *std::localtime(&m_fileStats->st_ctime)); } + try { creationTime = fmt::format("{:%Y-%m-%d %H:%M:%S}", *std::localtime(&m_fileStats->st_ctime)); } catch (const fmt::format_error&) { creationTime = "???"; } - try { accessTime = hex::format("{:%Y-%m-%d %H:%M:%S}", *std::localtime(&m_fileStats->st_atime)); } + try { accessTime = fmt::format("{:%Y-%m-%d %H:%M:%S}", *std::localtime(&m_fileStats->st_atime)); } catch (const fmt::format_error&) { accessTime = "???"; } - try { modificationTime = hex::format("{:%Y-%m-%d %H:%M:%S}", *std::localtime(&m_fileStats->st_mtime)); } + try { modificationTime = fmt::format("{:%Y-%m-%d %H:%M:%S}", *std::localtime(&m_fileStats->st_mtime)); } catch (const fmt::format_error&) { modificationTime = "???"; } result.emplace_back("hex.builtin.provider.file.creation"_lang, creationTime); @@ -204,7 +204,7 @@ namespace hex::plugin::builtin { { wolv::io::File file(m_path, wolv::io::File::Mode::Read); if (!file.isValid()) { - this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, m_path.string(), formatSystemError(file.getOpenError().value_or(0)))); + this->setErrorMessage(fmt::format("hex.builtin.provider.file.error.open"_lang, m_path.string(), formatSystemError(file.getOpenError().value_or(0)))); return false; } @@ -237,7 +237,7 @@ namespace hex::plugin::builtin { file = wolv::io::File(m_path, wolv::io::File::Mode::Read); if (!file.isValid()) { m_readable = false; - this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, m_path.string(), formatSystemError(file.getOpenError().value_or(0)))); + this->setErrorMessage(fmt::format("hex.builtin.provider.file.error.open"_lang, m_path.string(), formatSystemError(file.getOpenError().value_or(0)))); return false; } @@ -313,7 +313,7 @@ namespace hex::plugin::builtin { fullPath = path; if (!wolv::io::fs::exists(fullPath)) { - this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, m_path.string(), formatSystemError(ENOENT))); + this->setErrorMessage(fmt::format("hex.builtin.provider.file.error.open"_lang, m_path.string(), formatSystemError(ENOENT))); } path = std::move(fullPath); diff --git a/plugins/builtin/source/content/providers/gdb_provider.cpp b/plugins/builtin/source/content/providers/gdb_provider.cpp index 543a22ece..d097f8d17 100644 --- a/plugins/builtin/source/content/providers/gdb_provider.cpp +++ b/plugins/builtin/source/content/providers/gdb_provider.cpp @@ -29,7 +29,7 @@ namespace hex::plugin::builtin { } std::string createPacket(const std::string &data) { - return hex::format("${}#{:02x}", data, calculateChecksum(data)); + return fmt::format("${}#{:02x}", data, calculateChecksum(data)); } std::optional parsePacket(const std::string &packet) { @@ -151,7 +151,7 @@ namespace hex::plugin::builtin { } std::vector readMemory(const wolv::net::SocketClient &socket, u64 address, size_t size) { - std::string packet = createPacket(hex::format("m{:X},{:X}", address, size)); + std::string packet = createPacket(fmt::format("m{:X},{:X}", address, size)); std::string receivedPacket = sendReceivePackage(socket, packet); @@ -174,7 +174,7 @@ namespace hex::plugin::builtin { std::memcpy(bytes.data(), buffer, size); std::string byteString = crypt::encode16(bytes); - std::string packet = createPacket(hex::format("M{:X},{:X}:{}", address, size, byteString)); + std::string packet = createPacket(fmt::format("M{:X},{:X}:{}", address, size, byteString)); std::string receivedPacket = sendReceivePackage(socket, packet); auto receivedData = parsePacket(receivedPacket); @@ -245,12 +245,12 @@ namespace hex::plugin::builtin { port = std::to_string(m_port); } - return hex::format("hex.builtin.provider.gdb.name"_lang, address, port); + return fmt::format("hex.builtin.provider.gdb.name"_lang, address, port); } std::vector GDBProvider::getDataDescription() const { return { - {"hex.builtin.provider.gdb.server"_lang, hex::format("{}:{}", m_ipAddress, m_port)}, + {"hex.builtin.provider.gdb.server"_lang, fmt::format("{}:{}", m_ipAddress, m_port)}, }; } diff --git a/plugins/builtin/source/content/providers/intel_hex_provider.cpp b/plugins/builtin/source/content/providers/intel_hex_provider.cpp index 244968dec..d92916b49 100644 --- a/plugins/builtin/source/content/providers/intel_hex_provider.cpp +++ b/plugins/builtin/source/content/providers/intel_hex_provider.cpp @@ -197,7 +197,7 @@ namespace hex::plugin::builtin { bool IntelHexProvider::open() { auto file = wolv::io::File(m_sourceFilePath, wolv::io::File::Mode::Read); if (!file.isValid()) { - this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, m_sourceFilePath.string(), formatSystemError(errno))); + this->setErrorMessage(fmt::format("hex.builtin.provider.file.error.open"_lang, m_sourceFilePath.string(), formatSystemError(errno))); return false; } @@ -231,7 +231,7 @@ namespace hex::plugin::builtin { } [[nodiscard]] std::string IntelHexProvider::getName() const { - return hex::format("hex.builtin.provider.intel_hex.name"_lang, wolv::util::toUTF8String(m_sourceFilePath.filename())); + return fmt::format("hex.builtin.provider.intel_hex.name"_lang, wolv::util::toUTF8String(m_sourceFilePath.filename())); } [[nodiscard]] std::vector IntelHexProvider::getDataDescription() const { diff --git a/plugins/builtin/source/content/providers/motorola_srec_provider.cpp b/plugins/builtin/source/content/providers/motorola_srec_provider.cpp index ef9ccef20..7819b8d35 100644 --- a/plugins/builtin/source/content/providers/motorola_srec_provider.cpp +++ b/plugins/builtin/source/content/providers/motorola_srec_provider.cpp @@ -174,7 +174,7 @@ namespace hex::plugin::builtin { bool MotorolaSRECProvider::open() { auto file = wolv::io::File(m_sourceFilePath, wolv::io::File::Mode::Read); if (!file.isValid()) { - this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, m_sourceFilePath.string(), formatSystemError(errno))); + this->setErrorMessage(fmt::format("hex.builtin.provider.file.error.open"_lang, m_sourceFilePath.string(), formatSystemError(errno))); return false; } @@ -208,7 +208,7 @@ namespace hex::plugin::builtin { } [[nodiscard]] std::string MotorolaSRECProvider::getName() const { - return hex::format("hex.builtin.provider.motorola_srec.name"_lang, wolv::util::toUTF8String(m_sourceFilePath.filename())); + return fmt::format("hex.builtin.provider.motorola_srec.name"_lang, wolv::util::toUTF8String(m_sourceFilePath.filename())); } diff --git a/plugins/builtin/source/content/providers/process_memory_provider.cpp b/plugins/builtin/source/content/providers/process_memory_provider.cpp index dc0b2f3f5..d706448b7 100644 --- a/plugins/builtin/source/content/providers/process_memory_provider.cpp +++ b/plugins/builtin/source/content/providers/process_memory_provider.cpp @@ -342,7 +342,7 @@ namespace hex::plugin::builtin { if (loadLibraryW != nullptr) { if (auto threadHandle = CreateRemoteThread(m_processHandle, nullptr, 0, loadLibraryW, pathAddress, 0, nullptr); threadHandle != nullptr) { WaitForSingleObject(threadHandle, INFINITE); - ui::ToastInfo::open(hex::format("hex.builtin.provider.process_memory.utils.inject_dll.success"_lang, path.filename().string())); + ui::ToastInfo::open(fmt::format("hex.builtin.provider.process_memory.utils.inject_dll.success"_lang, path.filename().string())); this->reloadProcessModules(); CloseHandle(threadHandle); return; @@ -351,7 +351,7 @@ namespace hex::plugin::builtin { } } - ui::ToastError::open(hex::format("hex.builtin.provider.process_memory.utils.inject_dll.failure"_lang, path.filename().string())); + ui::ToastError::open(fmt::format("hex.builtin.provider.process_memory.utils.inject_dll.failure"_lang, path.filename().string())); }); } #endif @@ -394,10 +394,10 @@ namespace hex::plugin::builtin { std::string name; if (memoryInfo.State & MEM_IMAGE) continue; if (memoryInfo.State & MEM_FREE) continue; - if (memoryInfo.State & MEM_COMMIT) name += hex::format("{} ", "hex.builtin.provider.process_memory.region.commit"_lang); - if (memoryInfo.State & MEM_RESERVE) name += hex::format("{} ", "hex.builtin.provider.process_memory.region.reserve"_lang); - if (memoryInfo.State & MEM_PRIVATE) name += hex::format("{} ", "hex.builtin.provider.process_memory.region.private"_lang); - if (memoryInfo.State & MEM_MAPPED) name += hex::format("{} ", "hex.builtin.provider.process_memory.region.mapped"_lang); + if (memoryInfo.State & MEM_COMMIT) name += fmt::format("{} ", "hex.builtin.provider.process_memory.region.commit"_lang); + if (memoryInfo.State & MEM_RESERVE) name += fmt::format("{} ", "hex.builtin.provider.process_memory.region.reserve"_lang); + if (memoryInfo.State & MEM_PRIVATE) name += fmt::format("{} ", "hex.builtin.provider.process_memory.region.private"_lang); + if (memoryInfo.State & MEM_MAPPED) name += fmt::format("{} ", "hex.builtin.provider.process_memory.region.mapped"_lang); m_memoryRegions.insert({ { reinterpret_cast(memoryInfo.BaseAddress), reinterpret_cast(memoryInfo.BaseAddress) + memoryInfo.RegionSize }, name }); } diff --git a/plugins/builtin/source/content/providers/view_provider.cpp b/plugins/builtin/source/content/providers/view_provider.cpp index 8cf8ed7e9..549034f3c 100644 --- a/plugins/builtin/source/content/providers/view_provider.cpp +++ b/plugins/builtin/source/content/providers/view_provider.cpp @@ -122,7 +122,7 @@ namespace hex::plugin::builtin { if (m_provider == nullptr) return "View"; else - return hex::format("{} View", m_provider->getName()); + return fmt::format("{} View", m_provider->getName()); } [[nodiscard]] std::vector ViewProvider::getDataDescription() const { diff --git a/plugins/builtin/source/content/recent.cpp b/plugins/builtin/source/content/recent.cpp index 51f775d37..e342b978c 100644 --- a/plugins/builtin/source/content/recent.cpp +++ b/plugins/builtin/source/content/recent.cpp @@ -49,7 +49,7 @@ namespace hex::plugin::builtin::recent { wolv::io::File backupFile(entry.path(), wolv::io::File::Mode::Read); m_backups.emplace_back( - hex::format("hex.builtin.welcome.start.recent.auto_backups.backup"_lang, fmt::gmtime(backupFile.getFileInfo()->st_ctime)), + fmt::format("hex.builtin.welcome.start.recent.auto_backups.backup"_lang, fmt::gmtime(backupFile.getFileInfo()->st_ctime)), entry.path() ); } @@ -90,7 +90,7 @@ namespace hex::plugin::builtin::recent { // Save every opened provider as a "recent" shortcut (void)EventProviderOpened::subscribe([](const prv::Provider *provider) { if (ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.save_recent_providers", true)) { - auto fileName = hex::format("{:%y%m%d_%H%M%S}.json", fmt::gmtime(std::chrono::system_clock::now())); + auto fileName = fmt::format("{:%y%m%d_%H%M%S}.json", fmt::gmtime(std::chrono::system_clock::now())); // Do not save to recents if the provider is part of a project if (ProjectFile::hasPath()) @@ -124,7 +124,7 @@ namespace hex::plugin::builtin::recent { // Save opened projects as a "recent" shortcut (void)EventProjectOpened::subscribe([] { if (ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.save_recent_providers", true)) { - auto fileName = hex::format("{:%y%m%d_%H%M%S}.json", fmt::gmtime(std::chrono::system_clock::now())); + auto fileName = fmt::format("{:%y%m%d_%H%M%S}.json", fmt::gmtime(std::chrono::system_clock::now())); auto projectFileName = ProjectFile::getPath().filename(); if (projectFileName == BackupFileName) @@ -234,7 +234,7 @@ namespace hex::plugin::builtin::recent { if (recentEntry.type == "project") { std::fs::path projectPath = recentEntry.data["path"].get(); if (!ProjectFile::load(projectPath)) { - ui::ToastError::open(hex::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(projectPath))); + ui::ToastError::open(fmt::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(projectPath))); } return; } @@ -245,7 +245,7 @@ namespace hex::plugin::builtin::recent { TaskManager::createBlockingTask("hex.builtin.provider.opening", TaskManager::NoProgress, [provider]() { if (!provider->open() || !provider->isAvailable()) { - ui::ToastError::open(hex::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage())); + ui::ToastError::open(fmt::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage())); TaskManager::doLater([provider] { ImHexApi::Provider::remove(provider); }); } else { TaskManager::doLater([provider]{ EventProviderOpened::post(provider); }); @@ -318,7 +318,7 @@ namespace hex::plugin::builtin::recent { } // Detect right click on recent provider - std::string popupID = hex::format("RecentEntryMenu.{}", recentEntry.getHash()); + std::string popupID = fmt::format("RecentEntryMenu.{}", recentEntry.getHash()); if (ImGui::IsMouseReleased(1) && ImGui::IsItemHovered()) { ImGui::OpenPopup(popupID.c_str()); } diff --git a/plugins/builtin/source/content/report_generators.cpp b/plugins/builtin/source/content/report_generators.cpp index 286b38074..983c77809 100644 --- a/plugins/builtin/source/content/report_generators.cpp +++ b/plugins/builtin/source/content/report_generators.cpp @@ -23,7 +23,7 @@ namespace hex::plugin::builtin { result += "| ---- | ----- |\n"; for (const auto &[type, value] : dataDescriptionProvider->getDataDescription()) - result += hex::format("| {} | {} |\n", type, value); + result += fmt::format("| {} | {} |\n", type, value); } } @@ -42,7 +42,7 @@ namespace hex::plugin::builtin { result += "## Overlays\n\n"; for (const auto &overlay : overlays) { - result += hex::format("### Overlay 0x{:04X} - 0x{:04X}", overlay->getAddress(), overlay->getAddress() + overlay->getSize() - 1); + result += fmt::format("### Overlay 0x{:04X} - 0x{:04X}", overlay->getAddress(), overlay->getAddress() + overlay->getSize() - 1); result += "\n\n"; result += "```\n"; diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index 2e021bc20..adc366b2c 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -183,7 +183,7 @@ namespace hex::plugin::builtin { bool draw(const std::string &name) override { auto format = [this]() -> std::string { if (m_value == 0) - return hex::format("{} (x{:.1f})", "hex.builtin.setting.interface.scaling.native"_lang, ImHexApi::System::getNativeScale()); + return fmt::format("{} (x{:.1f})", "hex.builtin.setting.interface.scaling.native"_lang, ImHexApi::System::getNativeScale()); else return "x%.1f"; }(); @@ -223,9 +223,9 @@ namespace hex::plugin::builtin { if (value == 0) return "hex.ui.common.off"_lang; else if (value < 60) - return hex::format("hex.builtin.setting.general.auto_backup_time.format.simple"_lang, value); + return fmt::format("hex.builtin.setting.general.auto_backup_time.format.simple"_lang, value); else - return hex::format("hex.builtin.setting.general.auto_backup_time.format.extended"_lang, value / 60, value % 60); + return fmt::format("hex.builtin.setting.general.auto_backup_time.format.extended"_lang, value / 60, value % 60); }(); if (ImGui::SliderInt(name.data(), &m_value, 0, (30 * 60) / 30, format.c_str(), ImGuiSliderFlags_AlwaysClamp | ImGuiSliderFlags_NoInput)) { @@ -349,6 +349,10 @@ namespace hex::plugin::builtin { } nlohmann::json store() override { + // Don't store shortcuts that were not changed by the user + if (m_shortcut == m_defaultShortcut) + return {}; + std::vector keys; for (const auto &key : m_shortcut.getKeys()) { @@ -449,11 +453,11 @@ namespace hex::plugin::builtin { std::string name = Lang(unlocalizedName); if (menuItem.view != nullptr) { - name += hex::format(" ({})", Lang(menuItem.view->getUnlocalizedName())); + name += fmt::format(" ({})", Lang(menuItem.view->getUnlocalizedName())); } // Draw the menu item - ImGui::Selectable(hex::format("{} {}", menuItem.icon.glyph, name).c_str(), false, ImGuiSelectableFlags_SpanAllColumns); + ImGui::Selectable(fmt::format("{} {}", menuItem.icon.glyph, name).c_str(), false, ImGuiSelectableFlags_SpanAllColumns); ImGui::SetItemTooltip("%s", name.c_str()); // Handle dragging the menu item to the toolbar box @@ -586,7 +590,7 @@ namespace hex::plugin::builtin { // Draw all the color buttons for (auto color : Colors) { ImGui::PushID(&color); - if (ImGui::ColorButton(hex::format("##color{}", u32(color)).c_str(), ImGuiExt::GetCustomColorVec4(color), ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoPicker, ImVec2(20, 20))) { + if (ImGui::ColorButton(fmt::format("##color{}", u32(color)).c_str(), ImGuiExt::GetCustomColorVec4(color), ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoPicker, ImVec2(20, 20))) { menuItem->icon.color = color; ImGui::CloseCurrentPopup(); changed = true; @@ -613,7 +617,7 @@ namespace hex::plugin::builtin { name = name.substr(0, name.size() - 3); if (menuItem->view != nullptr) { - name += hex::format(" ({})", Lang(menuItem->view->getUnlocalizedName())); + name += fmt::format(" ({})", Lang(menuItem->view->getUnlocalizedName())); } auto textSize = ImGui::CalcTextSize(name.c_str(), nullptr, false, max.x - min.x); diff --git a/plugins/builtin/source/content/tools/base_converter.cpp b/plugins/builtin/source/content/tools/base_converter.cpp index 5d0937564..f0bc0d447 100644 --- a/plugins/builtin/source/content/tools/base_converter.cpp +++ b/plugins/builtin/source/content/tools/base_converter.cpp @@ -32,8 +32,8 @@ namespace hex::plugin::builtin { } buffers[0] = std::to_string(number); - buffers[1] = hex::format("0x{0:X}", number); - buffers[2] = hex::format("{0:#o}", number); + buffers[1] = fmt::format("0x{0:X}", number); + buffers[2] = fmt::format("{0:#o}", number); buffers[3] = hex::toBinaryString(number); }; diff --git a/plugins/builtin/source/content/tools/color_picker.cpp b/plugins/builtin/source/content/tools/color_picker.cpp index 7b6e2fd0f..ef48bc370 100644 --- a/plugins/builtin/source/content/tools/color_picker.cpp +++ b/plugins/builtin/source/content/tools/color_picker.cpp @@ -30,9 +30,9 @@ namespace hex::plugin::builtin { }; if (ImGui::BeginTable("##color_picker_table", 3, ImGuiTableFlags_BordersInnerV)) { - ImGui::TableSetupColumn(hex::format(" {}", "hex.builtin.tools.color"_lang).c_str(), ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, 300_scaled); - ImGui::TableSetupColumn(hex::format(" {}", "hex.builtin.tools.color.components"_lang).c_str(), ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, 105_scaled); - ImGui::TableSetupColumn(hex::format(" {}", "hex.builtin.tools.color.formats"_lang).c_str(), ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_NoResize); + ImGui::TableSetupColumn(fmt::format(" {}", "hex.builtin.tools.color"_lang).c_str(), ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, 300_scaled); + ImGui::TableSetupColumn(fmt::format(" {}", "hex.builtin.tools.color.components"_lang).c_str(), ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, 105_scaled); + ImGui::TableSetupColumn(fmt::format(" {}", "hex.builtin.tools.color.formats"_lang).c_str(), ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_NoResize); ImGui::TableHeadersRow(); @@ -49,7 +49,7 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); - const auto colorFormatName = hex::format("{}{}{}{}", + const auto colorFormatName = fmt::format("{}{}{}{}", bitValues[0].bits > 0 ? bitValues[0].name : "", bitValues[1].bits > 0 ? bitValues[1].name : "", bitValues[2].bits > 0 ? bitValues[2].name : "", @@ -69,7 +69,7 @@ namespace hex::plugin::builtin { // Draw slider ImGui::PushID(&bitValue->bits); - auto format = hex::format("%d\n{}", bitValue->name); + auto format = fmt::format("%d\n{}", bitValue->name); ImGui::VSliderInt("##slider", ImVec2(18_scaled, 350_scaled), &bitValue->bits, 0, 16, format.c_str(), ImGuiSliderFlags_AlwaysClamp); ImGui::PopID(); @@ -165,19 +165,19 @@ namespace hex::plugin::builtin { index += 1; } - return hex::format("#{0:0{1}X}", hexValue, bitCount / 4); + return fmt::format("#{0:0{1}X}", hexValue, bitCount / 4); }); drawValue(colorFormatName.c_str(), [&] { - return hex::format("{}({}, {}, {}, {})", colorFormatName, intColor[0], intColor[1], intColor[2], intColor[3]); + return fmt::format("{}({}, {}, {}, {})", colorFormatName, intColor[0], intColor[1], intColor[2], intColor[3]); }); drawValue("hex.builtin.tools.color.formats.vec4"_lang, [&] { - return hex::format("{{ {:.2}F, {:.2}F, {:.2}F, {:.2}F }}", floatColor[0], floatColor[1], floatColor[2], floatColor[3]); + return fmt::format("{{ {:.2}F, {:.2}F, {:.2}F, {:.2}F }}", floatColor[0], floatColor[1], floatColor[2], floatColor[3]); }); drawValue("hex.builtin.tools.color.formats.percent"_lang, [&] { - return hex::format("{{ {}%, {}%, {}%, {}% }}", u32(floatColor[0] * 100), u32(floatColor[1] * 100), u32(floatColor[2] * 100), u32(floatColor[3] * 100)); + return fmt::format("{{ {}%, {}%, {}%, {}% }}", u32(floatColor[0] * 100), u32(floatColor[1] * 100), u32(floatColor[2] * 100), u32(floatColor[3] * 100)); }); drawValue("hex.builtin.tools.color.formats.color_name"_lang, [&]() -> std::string { diff --git a/plugins/builtin/source/content/tools/file_tool_combiner.cpp b/plugins/builtin/source/content/tools/file_tool_combiner.cpp index 3fc25041b..88427d46d 100644 --- a/plugins/builtin/source/content/tools/file_tool_combiner.cpp +++ b/plugins/builtin/source/content/tools/file_tool_combiner.cpp @@ -125,7 +125,7 @@ namespace hex::plugin::builtin { wolv::io::File input(file, wolv::io::File::Mode::Read); if (!input.isValid()) { - ui::ToastError::open(hex::format("hex.builtin.tools.file_tools.combiner.open_input"_lang, wolv::util::toUTF8String(file))); + ui::ToastError::open(fmt::format("hex.builtin.tools.file_tools.combiner.open_input"_lang, wolv::util::toUTF8String(file))); return; } diff --git a/plugins/builtin/source/content/tools/file_tool_splitter.cpp b/plugins/builtin/source/content/tools/file_tool_splitter.cpp index b7a43330a..62844f8a6 100644 --- a/plugins/builtin/source/content/tools/file_tool_splitter.cpp +++ b/plugins/builtin/source/content/tools/file_tool_splitter.cpp @@ -118,12 +118,12 @@ namespace hex::plugin::builtin { task.update(offset); std::fs::path path = baseOutputPath; - path += hex::format(".{:05}", index); + path += fmt::format(".{:05}", index); wolv::io::File partFile(path, wolv::io::File::Mode::Create); if (!partFile.isValid()) { - ui::ToastError::open(hex::format("hex.builtin.tools.file_tools.splitter.picker.error.create"_lang, index)); + ui::ToastError::open(fmt::format("hex.builtin.tools.file_tools.splitter.picker.error.create"_lang, index)); return; } diff --git a/plugins/builtin/source/content/tools/file_uploader.cpp b/plugins/builtin/source/content/tools/file_uploader.cpp index 524dc3adf..8e5a0695c 100644 --- a/plugins/builtin/source/content/tools/file_uploader.cpp +++ b/plugins/builtin/source/content/tools/file_uploader.cpp @@ -85,7 +85,7 @@ namespace hex::plugin::builtin { } } else if (response.getStatusCode() == 0) { // Canceled by user, no action needed - } else ui::PopupError::open(hex::format("hex.builtin.tools.file_uploader.error"_lang, response.getStatusCode())); + } else ui::PopupError::open(fmt::format("hex.builtin.tools.file_uploader.error"_lang, response.getStatusCode())); uploadProcess = {}; currFile.clear(); diff --git a/plugins/builtin/source/content/tools/ieee_decoder.cpp b/plugins/builtin/source/content/tools/ieee_decoder.cpp index b5efa7393..1daa83eff 100644 --- a/plugins/builtin/source/content/tools/ieee_decoder.cpp +++ b/plugins/builtin/source/content/tools/ieee_decoder.cpp @@ -646,7 +646,7 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); const auto mask = u64(hex::bitmask(totalBitCount + 1)); - std::string maskString = hex::format("0x{:X} ", mask); + std::string maskString = fmt::format("0x{:X} ", mask); auto style = ImGui::GetStyle(); inputFieldWidth = std::fmax(inputFieldWidth, diff --git a/plugins/builtin/source/content/tools/perms_calc.cpp b/plugins/builtin/source/content/tools/perms_calc.cpp index f4e55bee7..c02f6f94f 100644 --- a/plugins/builtin/source/content/tools/perms_calc.cpp +++ b/plugins/builtin/source/content/tools/perms_calc.cpp @@ -43,7 +43,7 @@ namespace hex::plugin::builtin { ImGuiExt::Header("hex.builtin.tools.permissions.absolute"_lang); - auto result = hex::format("{}{}{}{}", + auto result = fmt::format("{}{}{}{}", (setuid << 2) | (setgid << 1) | (sticky << 0), (r[0] << 2) | (w[0] << 1) | (x[0] << 0), (r[1] << 2) | (w[1] << 1) | (x[1] << 0), diff --git a/plugins/builtin/source/content/ui_items.cpp b/plugins/builtin/source/content/ui_items.cpp index 172269b3d..3e1709440 100644 --- a/plugins/builtin/source/content/ui_items.cpp +++ b/plugins/builtin/source/content/ui_items.cpp @@ -47,7 +47,7 @@ namespace hex::plugin::builtin { // Task exception toast for (const auto &task : TaskManager::getRunningTasks()) { if (task->hadException()) { - ui::ToastError::open(hex::format("hex.builtin.popup.error.task_exception"_lang, Lang(task->getUnlocalizedName()), task->getExceptionMessage())); + ui::ToastError::open(fmt::format("hex.builtin.popup.error.task_exception"_lang, Lang(task->getUnlocalizedName()), task->getExceptionMessage())); task->clearException(); break; } @@ -291,7 +291,7 @@ namespace hex::plugin::builtin { const auto widgetStart = ImGui::GetCursorPos(); { - ImGuiExt::TextSpinner(hex::format("({})", taskCount).c_str()); + ImGuiExt::TextSpinner(fmt::format("({})", taskCount).c_str()); ImGui::SameLine(); ImGuiExt::ProgressBar(progress, scaled({ 100, 5 }), (ImGui::GetCurrentWindowRead()->MenuBarHeight - 10_scaled) / 2.0); ImGui::SameLine(); @@ -306,9 +306,9 @@ namespace hex::plugin::builtin { if (progress < 0) progressString = ""; else - progressString = hex::format("[ {}/{} ({:.1f}%) ] ", frontTask->getValue(), frontTask->getMaxValue(), std::min(progress, 1.0F) * 100.0F); + progressString = fmt::format("[ {}/{} ({:.1f}%) ] ", frontTask->getValue(), frontTask->getMaxValue(), std::min(progress, 1.0F) * 100.0F); - ImGuiExt::InfoTooltip(hex::format("{}{}", progressString, Lang(frontTask->getUnlocalizedName())).c_str()); + ImGuiExt::InfoTooltip(fmt::format("{}{}", progressString, Lang(frontTask->getUnlocalizedName())).c_str()); if (ImGui::BeginPopupContextItem("RestTasks", ImGuiPopupFlags_MouseButtonLeft)) { for (const auto &task : tasks) { @@ -562,7 +562,7 @@ namespace hex::plugin::builtin { ImHexApi::System::updateImHex(ImHexApi::System::UpdateType::Stable); }); - ui::ToastInfo::open(hex::format("hex.builtin.welcome.update.desc"_lang, it->second)); + ui::ToastInfo::open(fmt::format("hex.builtin.welcome.update.desc"_lang, it->second)); } }); } diff --git a/plugins/builtin/source/content/views.cpp b/plugins/builtin/source/content/views.cpp index 39d8317ea..4f31fa59b 100644 --- a/plugins/builtin/source/content/views.cpp +++ b/plugins/builtin/source/content/views.cpp @@ -53,7 +53,7 @@ namespace hex::plugin::builtin { if (!view->shouldStoreWindowState()) continue; - std::string format = hex::format("{}=%d", view->getUnlocalizedName().get()); + std::string format = fmt::format("{}=%d", view->getUnlocalizedName().get()); sscanf(line.data(), format.c_str(), &view->getWindowOpenState()); } }); diff --git a/plugins/builtin/source/content/views/fullscreen/view_fullscreen_save_editor.cpp b/plugins/builtin/source/content/views/fullscreen/view_fullscreen_save_editor.cpp index 492679296..055dfd5dd 100644 --- a/plugins/builtin/source/content/views/fullscreen/view_fullscreen_save_editor.cpp +++ b/plugins/builtin/source/content/views/fullscreen/view_fullscreen_save_editor.cpp @@ -59,7 +59,7 @@ namespace hex::plugin::builtin { ImGui::NewLine(); - if (ImGuiExt::DimmedButton(hex::format("{} {}", ICON_VS_OPEN_PREVIEW, "Select Save File").c_str(), ImVec2(-1, 0))) { + if (ImGuiExt::DimmedButton(fmt::format("{} {}", ICON_VS_OPEN_PREVIEW, "Select Save File").c_str(), ImVec2(-1, 0))) { fs::openFileBrowser(fs::DialogMode::Open, {}, [this](const std::fs::path &path) { this->m_provider.setPath(path); if (!this->m_provider.open()) { diff --git a/plugins/builtin/source/content/views/view_about.cpp b/plugins/builtin/source/content/views/view_about.cpp index 3d8da0b9d..450159008 100644 --- a/plugins/builtin/source/content/views/view_about.cpp +++ b/plugins/builtin/source/content/views/view_about.cpp @@ -216,7 +216,7 @@ namespace hex::plugin::builtin { ImGui::SameLine(0, 0); // Draw a clickable link to the current commit - if (ImGuiExt::Hyperlink(hex::format("{0}@{1}", ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash()).c_str())) + if (ImGuiExt::Hyperlink(fmt::format("{0}@{1}", ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash()).c_str())) hex::openWebpage("https://github.com/WerWolv/ImHex/commit/" + ImHexApi::System::getCommitHash(true)); } @@ -365,7 +365,7 @@ namespace hex::plugin::builtin { ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, scaled({ 12, 3 })); if (ImGui::BeginChild(library.link, ImVec2(), ImGuiChildFlags_Borders | ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY)) { - if (ImGuiExt::Hyperlink(hex::format("{}/{}", library.author, library.name).c_str())) { + if (ImGuiExt::Hyperlink(fmt::format("{}/{}", library.author, library.name).c_str())) { hex::openWebpage(library.link); } ImGui::SetItemTooltip("%s", library.link); @@ -612,7 +612,7 @@ namespace hex::plugin::builtin { // Draw the release title if (!notes.title.empty()) { - auto title = hex::format("{}: {}", notes.versionString, notes.title); + auto title = fmt::format("{}: {}", notes.versionString, notes.title); ImGuiExt::Header(title.c_str(), true); ImGui::Separator(); } @@ -683,7 +683,7 @@ namespace hex::plugin::builtin { auto url = commit["html_url"].get(); auto sha = commit["sha"].get(); auto date = commit["commit"]["author"]["date"].get(); - auto author = hex::format("{} <{}>", + auto author = fmt::format("{} <{}>", commit["commit"]["author"]["name"].get(), commit["commit"]["author"]["email"].get() ); diff --git a/plugins/builtin/source/content/views/view_achievements.cpp b/plugins/builtin/source/content/views/view_achievements.cpp index 95da203e8..1a4f09605 100644 --- a/plugins/builtin/source/content/views/view_achievements.cpp +++ b/plugins/builtin/source/content/views/view_achievements.cpp @@ -188,7 +188,7 @@ namespace hex::plugin::builtin { const auto visibleCount = achievements.size() - invisibleCount; // Construct number of unlocked achievements text - auto unlockedText = hex::format("{}: {} / {}{}", "hex.builtin.view.achievements.unlocked_count"_lang, unlockedCount, visibleCount, invisibleCount > 0 ? "+" : " "); + auto unlockedText = fmt::format("{}: {} / {}{}", "hex.builtin.view.achievements.unlocked_count"_lang, unlockedCount, visibleCount, invisibleCount > 0 ? "+" : " "); // Calculate overlay size auto &style = ImGui::GetStyle(); diff --git a/plugins/builtin/source/content/views/view_bookmarks.cpp b/plugins/builtin/source/content/views/view_bookmarks.cpp index 89414a5a8..34c6284a6 100644 --- a/plugins/builtin/source/content/views/view_bookmarks.cpp +++ b/plugins/builtin/source/content/views/view_bookmarks.cpp @@ -26,7 +26,7 @@ namespace hex::plugin::builtin { // Handle bookmark add requests sent by the API RequestAddBookmark::subscribe(this, [this](Region region, std::string name, std::string comment, color_t color, u64 *id) { if (name.empty()) { - name = hex::format("hex.builtin.view.bookmarks.default_title"_lang, region.address, region.address + region.size - 1); + name = fmt::format("hex.builtin.view.bookmarks.default_title"_lang, region.address, region.address + region.size - 1); } if (color == 0x00) @@ -182,10 +182,10 @@ namespace hex::plugin::builtin { result += "## Bookmarks\n\n"; for (const auto &[bookmark, highlightVisible] : bookmarks) { - result += hex::format("### {} [0x{:04X} - 0x{:04X}]\n\n", hex::changeEndianness(bookmark.color, std::endian::big) >> 8, bookmark.name, bookmark.region.getStartAddress(), bookmark.region.getEndAddress()); + result += fmt::format("### {} [0x{:04X} - 0x{:04X}]\n\n", hex::changeEndianness(bookmark.color, std::endian::big) >> 8, bookmark.name, bookmark.region.getStartAddress(), bookmark.region.getEndAddress()); for (const auto &line : wolv::util::splitString(bookmark.comment, "\n")) - result += hex::format("> {}\n", line); + result += fmt::format("> {}\n", line); result += "\n"; result += "```\n"; @@ -338,7 +338,7 @@ namespace hex::plugin::builtin { bool notDeleted = true; ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2()); - auto expanded = ImGui::CollapsingHeader(hex::format("{}###bookmark", name).c_str(), ¬Deleted); + auto expanded = ImGui::CollapsingHeader(fmt::format("{}###bookmark", name).c_str(), ¬Deleted); ImGui::PopStyleVar(); if (!expanded) { @@ -385,7 +385,7 @@ namespace hex::plugin::builtin { auto newProvider = ImHexApi::Provider::createProvider("hex.builtin.provider.view", true); if (auto *viewProvider = dynamic_cast(newProvider); viewProvider != nullptr) { viewProvider->setProvider(region.getStartAddress(), region.getSize(), provider); - viewProvider->setName(hex::format("'{}' View", name)); + viewProvider->setName(fmt::format("'{}' View", name)); if (viewProvider->open()) { EventProviderOpened::post(viewProvider); diff --git a/plugins/builtin/source/content/views/view_command_palette.cpp b/plugins/builtin/source/content/views/view_command_palette.cpp index 84c87a2a2..8c7fe87f7 100644 --- a/plugins/builtin/source/content/views/view_command_palette.cpp +++ b/plugins/builtin/source/content/views/view_command_palette.cpp @@ -186,7 +186,7 @@ namespace hex::plugin::builtin { if (auto [match, value] = MatchCommand(input, command); match != MatchType::NoMatch) { if (match != MatchType::PerfectMatch) { - results.push_back({ hex::format("{} ({})", command, Lang(unlocalizedDescription)), "", AutoComplete }); + results.push_back({ fmt::format("{} ({})", command, Lang(unlocalizedDescription)), "", AutoComplete }); } else { auto matchedCommand = wolv::util::trim(input.substr(command.length())); results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback }); @@ -198,7 +198,7 @@ namespace hex::plugin::builtin { if (auto [match, value] = MatchCommand(input, command + " "); match != MatchType::NoMatch) { if (match != MatchType::PerfectMatch) { - results.push_back({ hex::format("{} ({})", command, Lang(unlocalizedDescription)), "", AutoComplete }); + results.push_back({ fmt::format("{} ({})", command, Lang(unlocalizedDescription)), "", AutoComplete }); } else { auto matchedCommand = wolv::util::trim(input.substr(command.length() + 1)); results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback }); @@ -218,11 +218,11 @@ namespace hex::plugin::builtin { for (const auto &[description, callback] : queryCallback(processedInput)) { if (type == ContentRegistry::CommandPaletteCommands::Type::SymbolCommand) { if (auto [match, value] = MatchCommand(input, command); match != MatchType::NoMatch) { - results.push_back({ hex::format("{} ({})", command, description), "", [callback](auto ... args){ callback(args...); return std::nullopt; } }); + results.push_back({ fmt::format("{} ({})", command, description), "", [callback](auto ... args){ callback(args...); return std::nullopt; } }); } } else if (type == ContentRegistry::CommandPaletteCommands::Type::KeywordCommand) { if (auto [match, value] = MatchCommand(input, command + " "); match != MatchType::NoMatch) { - results.push_back({ hex::format("{} ({})", command, description), "", [callback](auto ... args){ callback(args...); return std::nullopt; } }); + results.push_back({ fmt::format("{} ({})", command, description), "", [callback](auto ... args){ callback(args...); return std::nullopt; } }); } } } diff --git a/plugins/builtin/source/content/views/view_data_inspector.cpp b/plugins/builtin/source/content/views/view_data_inspector.cpp index 1e37b9ba9..7b13430ce 100644 --- a/plugins/builtin/source/content/views/view_data_inspector.cpp +++ b/plugins/builtin/source/content/views/view_data_inspector.cpp @@ -505,8 +505,8 @@ namespace hex::plugin::builtin { }(); std::array options = { - hex::format("{}: {}", "hex.ui.common.endian"_lang, "hex.ui.common.little"_lang), - hex::format("{}: {}", "hex.ui.common.endian"_lang, "hex.ui.common.big"_lang) + fmt::format("{}: {}", "hex.ui.common.endian"_lang, "hex.ui.common.little"_lang), + fmt::format("{}: {}", "hex.ui.common.endian"_lang, "hex.ui.common.big"_lang) }; if (ImGui::SliderInt("##endian", &selection, 0, options.size() - 1, options[selection].c_str(), ImGuiSliderFlags_NoInput)) { @@ -538,9 +538,9 @@ namespace hex::plugin::builtin { }(); std::array options = { - hex::format("{}: {}", "hex.ui.common.number_format"_lang, "hex.ui.common.decimal"_lang), - hex::format("{}: {}", "hex.ui.common.number_format"_lang, "hex.ui.common.hexadecimal"_lang), - hex::format("{}: {}", "hex.ui.common.number_format"_lang, "hex.ui.common.octal"_lang) + fmt::format("{}: {}", "hex.ui.common.number_format"_lang, "hex.ui.common.decimal"_lang), + fmt::format("{}: {}", "hex.ui.common.number_format"_lang, "hex.ui.common.hexadecimal"_lang), + fmt::format("{}: {}", "hex.ui.common.number_format"_lang, "hex.ui.common.octal"_lang) }; if (ImGui::SliderInt("##format", &selection, 0, options.size() - 1, options[selection].c_str(), ImGuiSliderFlags_NoInput)) { @@ -565,8 +565,8 @@ namespace hex::plugin::builtin { int selection = m_invert ? 1 : 0; std::array options = { - hex::format("{}: {}", "hex.builtin.view.data_inspector.invert"_lang, "hex.ui.common.no"_lang), - hex::format("{}: {}", "hex.builtin.view.data_inspector.invert"_lang, "hex.ui.common.yes"_lang) + fmt::format("{}: {}", "hex.builtin.view.data_inspector.invert"_lang, "hex.ui.common.no"_lang), + fmt::format("{}: {}", "hex.builtin.view.data_inspector.invert"_lang, "hex.ui.common.yes"_lang) }; if (ImGui::SliderInt("##invert", &selection, 0, options.size() - 1, options[selection].c_str(), ImGuiSliderFlags_NoInput)) { @@ -581,10 +581,10 @@ namespace hex::plugin::builtin { std::string errorMessage; if (const auto &compileErrors = m_runtime.getCompileErrors(); !compileErrors.empty()) { for (const auto &error : compileErrors) { - errorMessage += hex::format("{}\n", error.format()); + errorMessage += fmt::format("{}\n", error.format()); } } else if (const auto &evalError = m_runtime.getEvalError(); evalError.has_value()) { - errorMessage += hex::format("{}:{} {}\n", evalError->line, evalError->column, evalError->message); + errorMessage += fmt::format("{}:{} {}\n", evalError->line, evalError->column, evalError->message); } // Create a dummy display function that displays the error message diff --git a/plugins/builtin/source/content/views/view_data_processor.cpp b/plugins/builtin/source/content/views/view_data_processor.cpp index 2fb484c68..1642ceffc 100644 --- a/plugins/builtin/source/content/views/view_data_processor.cpp +++ b/plugins/builtin/source/content/views/view_data_processor.cpp @@ -1283,7 +1283,7 @@ namespace hex::plugin::builtin { m_updateNodePositions = true; } catch (nlohmann::json::exception &e) { - ui::ToastError::open(hex::format("Failed to load nodes: {}", e.what())); + ui::ToastError::open(fmt::format("Failed to load nodes: {}", e.what())); } } diff --git a/plugins/builtin/source/content/views/view_find.cpp b/plugins/builtin/source/content/views/view_find.cpp index 2316b9b4c..48e1219d6 100644 --- a/plugins/builtin/source/content/views/view_find.cpp +++ b/plugins/builtin/source/content/views/view_find.cpp @@ -168,7 +168,7 @@ namespace hex::plugin::builtin { if (std::signed_integral) value = T(hex::signExtend(bytes.size() * 8, value)); - return hex::format("{}", value); + return fmt::format("{}", value); } std::vector ViewFind::searchStrings(Task &task, prv::Provider *provider, hex::Region searchRegion, const SearchSettings::Strings &settings) { @@ -731,8 +731,8 @@ namespace hex::plugin::builtin { "hex.ui.common.encoding.utf8"_lang, "hex.ui.common.encoding.utf16le"_lang, "hex.ui.common.encoding.utf16be"_lang, - hex::format("{} + {}", "hex.ui.common.encoding.ascii"_lang, "hex.ui.common.encoding.utf16le"_lang), - hex::format("{} + {}", "hex.ui.common.encoding.ascii"_lang, "hex.ui.common.encoding.utf16be"_lang) + fmt::format("{} + {}", "hex.ui.common.encoding.ascii"_lang, "hex.ui.common.encoding.utf16le"_lang), + fmt::format("{} + {}", "hex.ui.common.encoding.ascii"_lang, "hex.ui.common.encoding.utf16be"_lang) }; auto &mode = m_searchSettings.mode; @@ -760,13 +760,13 @@ namespace hex::plugin::builtin { ImGui::Checkbox("hex.builtin.view.find.strings.null_term"_lang, &settings.nullTermination); ImGuiExt::Header("hex.builtin.view.find.strings.chars"_lang); - ImGui::Checkbox(hex::format("{} [a-z]", "hex.builtin.view.find.strings.lower_case"_lang.get()).c_str(), &settings.lowerCaseLetters); - ImGui::Checkbox(hex::format("{} [A-Z]", "hex.builtin.view.find.strings.upper_case"_lang.get()).c_str(), &settings.upperCaseLetters); - ImGui::Checkbox(hex::format("{} [0-9]", "hex.builtin.view.find.strings.numbers"_lang.get()).c_str(), &settings.numbers); - ImGui::Checkbox(hex::format("{} [_]", "hex.builtin.view.find.strings.underscores"_lang.get()).c_str(), &settings.underscores); - ImGui::Checkbox(hex::format("{} [!\"#$%...]", "hex.builtin.view.find.strings.symbols"_lang.get()).c_str(), &settings.symbols); - ImGui::Checkbox(hex::format("{} [ \\f\\t\\v]", "hex.builtin.view.find.strings.spaces"_lang.get()).c_str(), &settings.spaces); - ImGui::Checkbox(hex::format("{} [\\r\\n]", "hex.builtin.view.find.strings.line_feeds"_lang.get()).c_str(), &settings.lineFeeds); + ImGui::Checkbox(fmt::format("{} [a-z]", "hex.builtin.view.find.strings.lower_case"_lang.get()).c_str(), &settings.lowerCaseLetters); + ImGui::Checkbox(fmt::format("{} [A-Z]", "hex.builtin.view.find.strings.upper_case"_lang.get()).c_str(), &settings.upperCaseLetters); + ImGui::Checkbox(fmt::format("{} [0-9]", "hex.builtin.view.find.strings.numbers"_lang.get()).c_str(), &settings.numbers); + ImGui::Checkbox(fmt::format("{} [_]", "hex.builtin.view.find.strings.underscores"_lang.get()).c_str(), &settings.underscores); + ImGui::Checkbox(fmt::format("{} [!\"#$%...]", "hex.builtin.view.find.strings.symbols"_lang.get()).c_str(), &settings.symbols); + ImGui::Checkbox(fmt::format("{} [ \\f\\t\\v]", "hex.builtin.view.find.strings.spaces"_lang.get()).c_str(), &settings.spaces); + ImGui::Checkbox(fmt::format("{} [\\r\\n]", "hex.builtin.view.find.strings.line_feeds"_lang.get()).c_str(), &settings.lineFeeds); } m_settingsValid = true; diff --git a/plugins/builtin/source/content/views/view_hex_editor.cpp b/plugins/builtin/source/content/views/view_hex_editor.cpp index b64b83fd4..3408fcbaa 100644 --- a/plugins/builtin/source/content/views/view_hex_editor.cpp +++ b/plugins/builtin/source/content/views/view_hex_editor.cpp @@ -114,7 +114,7 @@ namespace hex::plugin::builtin { ImGui::BeginDisabled(!m_newAddress.has_value() || !isOffsetValid); { - const auto label = hex::format("{} {}", "hex.builtin.view.hex_editor.menu.file.goto"_lang, m_newAddress.has_value() ? hex::format("0x{:08X}", *m_newAddress) : "???"); + const auto label = fmt::format("{} {}", "hex.builtin.view.hex_editor.menu.file.goto"_lang, m_newAddress.has_value() ? fmt::format("0x{:08X}", *m_newAddress) : "???"); const auto buttonWidth = ImGui::GetWindowWidth() - ImGui::GetStyle().WindowPadding.x * 2; if (ImGuiExt::DimmedButton(label.c_str(), ImVec2(buttonWidth, 0))) { executeGoto = true; @@ -672,7 +672,7 @@ namespace hex::plugin::builtin { } if (m_currPopup != nullptr) { - if (ImGui::Begin(hex::format("##{}", m_currPopup->getTitle().get()).c_str(), &open, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDocking)) { + if (ImGui::Begin(fmt::format("##{}", m_currPopup->getTitle().get()).c_str(), &open, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDocking)) { if (ImGui::IsKeyPressed(ImGuiKey_Escape)) { this->closePopup(); } else { @@ -1294,7 +1294,7 @@ namespace hex::plugin::builtin { [] { auto selection = ImHexApi::HexEditor::getSelection(); if (selection.has_value() && selection != Region::Invalid()) - ImGui::SetClipboardText(hex::format("0x{:08X}", selection->getStartAddress()).c_str()); + ImGui::SetClipboardText(fmt::format("0x{:08X}", selection->getStartAddress()).c_str()); }, ImHexApi::HexEditor::isSelectionValid, this); @@ -1495,13 +1495,13 @@ namespace hex::plugin::builtin { }; ImGui::PushID(1); - if (menu::menuItem(hex::format("{} | 0x{:08X}", "hex.ui.common.little_endian"_lang, littleEndianValue).c_str(), Shortcut::None, false, canJumpTo(littleEndianValue))) { + if (menu::menuItem(fmt::format("{} | 0x{:08X}", "hex.ui.common.little_endian"_lang, littleEndianValue).c_str(), Shortcut::None, false, canJumpTo(littleEndianValue))) { ImHexApi::HexEditor::setSelection(littleEndianValue, 1); } ImGui::PopID(); ImGui::PushID(2); - if (menu::menuItem(hex::format("{} | 0x{:08X}", "hex.ui.common.big_endian"_lang, bigEndianValue).c_str(), Shortcut::None, false, canJumpTo(bigEndianValue))) { + if (menu::menuItem(fmt::format("{} | 0x{:08X}", "hex.ui.common.big_endian"_lang, bigEndianValue).c_str(), Shortcut::None, false, canJumpTo(bigEndianValue))) { ImHexApi::HexEditor::setSelection(bigEndianValue, 1); } ImGui::PopID(); diff --git a/plugins/builtin/source/content/views/view_information.cpp b/plugins/builtin/source/content/views/view_information.cpp index 3a208fe87..4ec15d5c5 100644 --- a/plugins/builtin/source/content/views/view_information.cpp +++ b/plugins/builtin/source/content/views/view_information.cpp @@ -83,7 +83,7 @@ namespace hex::plugin::builtin { section->markValid(); } catch (const std::exception &e) { // Show a toast with the error if the section failed to process - ui::ToastError::open(hex::format("hex.builtin.view.information.error_processing_section"_lang, Lang(section->getUnlocalizedName()), e.what())); + ui::ToastError::open(fmt::format("hex.builtin.view.information.error_processing_section"_lang, Lang(section->getUnlocalizedName()), e.what())); } } diff --git a/plugins/builtin/source/content/views/view_logs.cpp b/plugins/builtin/source/content/views/view_logs.cpp index b9af84d40..b7a9a4c05 100644 --- a/plugins/builtin/source/content/views/view_logs.cpp +++ b/plugins/builtin/source/content/views/view_logs.cpp @@ -53,17 +53,17 @@ namespace hex::plugin::builtin { ImGui::TableHeadersRow(); const auto &logs = log::impl::getLogEntries(); - for (const auto &log : logs | std::views::reverse) { - if (!shouldDisplay(log.level, m_logLevel)) { + for (const auto &[project, level, message] : logs | std::views::reverse) { + if (!shouldDisplay(level, m_logLevel)) { continue; } ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::TextUnformatted(log.project.c_str()); + ImGui::TextUnformatted(project.begin(), project.end()); ImGui::TableNextColumn(); - ImGui::PushStyleColor(ImGuiCol_Text, getColor(log.level).Value); - ImGui::TextUnformatted(log.message.c_str()); + ImGui::PushStyleColor(ImGuiCol_Text, getColor(level).Value); + ImGui::TextUnformatted(message.c_str()); ImGui::PopStyleColor(); } diff --git a/plugins/builtin/source/content/views/view_patches.cpp b/plugins/builtin/source/content/views/view_patches.cpp index d1bbcbe54..1e213013e 100644 --- a/plugins/builtin/source/content/views/view_patches.cpp +++ b/plugins/builtin/source/content/views/view_patches.cpp @@ -166,7 +166,7 @@ namespace hex::plugin::builtin { ImGui::BeginDisabled(size_t(i) < undoneOperationsCount); - if (ImGui::Selectable(hex::format("{} {}", index == undoneOperationsCount ? ICON_VS_ARROW_SMALL_RIGHT : " ", index).c_str(), false, ImGuiSelectableFlags_SpanAllColumns)) { + if (ImGui::Selectable(fmt::format("{} {}", index == undoneOperationsCount ? ICON_VS_ARROW_SMALL_RIGHT : " ", index).c_str(), false, ImGuiSelectableFlags_SpanAllColumns)) { ImHexApi::HexEditor::setSelection(address, size); } if (ImGui::IsItemHovered()) { diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index e66a35faf..00c49cdc6 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -786,12 +786,12 @@ namespace hex::plugin::builtin { if (position > 1999) counterString = "? "; else - counterString = hex::format("{} ", position); + counterString = fmt::format("{} ", position); counterString += "hex.builtin.view.pattern_editor.of"_lang.operator const char *(); if (count > 1999) counterString += " 1999+"; else - counterString += hex::format(" {}", count); + counterString += fmt::format(" {}", count); } } auto resultSize = ImGui::CalcTextSize(counterString.c_str()); @@ -1257,12 +1257,12 @@ namespace hex::plugin::builtin { if (*m_breakpointHit) { auto displayValue = [&](const auto &parent, size_t index) { - return hex::format("{0} {1} [{2}]", + return fmt::format("{0} {1} [{2}]", "hex.builtin.view.pattern_editor.debugger.scope"_lang, evaluator->getScopeCount() - index - 1, parent == nullptr ? "hex.builtin.view.pattern_editor.debugger.scope.global"_lang : - hex::format("0x{0:08X}", parent->getOffset()) + fmt::format("0x{0:08X}", parent->getOffset()) ); }; @@ -1795,10 +1795,10 @@ namespace hex::plugin::builtin { switch (level) { using enum pl::core::LogConsole::Level; - case Debug: line = hex::format("D: {}", line); break; - case Info: line = hex::format("I: {}", line); break; - case Warning: line = hex::format("W: {}", line); break; - case Error: line = hex::format("E: {}", line); break; + case Debug: line = fmt::format("D: {}", line); break; + case Info: line = fmt::format("I: {}", line); break; + case Warning: line = fmt::format("W: {}", line); break; + case Error: line = fmt::format("E: {}", line); break; default: break; } } @@ -1821,7 +1821,7 @@ namespace hex::plugin::builtin { std::scoped_lock lock(m_logMutex); m_console.get(provider).emplace_back( - hex::format("I: Evaluation took {}", std::chrono::duration(runtime.getLastRunningTime())) + fmt::format("I: Evaluation took {}", std::chrono::duration(runtime.getLastRunningTime())) ); m_consoleNeedsUpdate = true; }; @@ -1966,14 +1966,14 @@ namespace hex::plugin::builtin { void ViewPatternEditor::appendVariable(const std::string &type) { const auto &selection = ImHexApi::HexEditor::getSelection(); - appendEditorText(hex::format("{0} {0}_at_0x{1:02X} @ 0x{1:02X};", type, selection->getStartAddress())); + appendEditorText(fmt::format("{0} {0}_at_0x{1:02X} @ 0x{1:02X};", type, selection->getStartAddress())); AchievementManager::unlockAchievement("hex.builtin.achievement.patterns", "hex.builtin.achievement.patterns.place_menu.name"); } void ViewPatternEditor::appendArray(const std::string &type, size_t size) { const auto &selection = ImHexApi::HexEditor::getSelection(); - appendEditorText(hex::format("{0} {0}_array_at_0x{1:02X}[0x{2:02X}] @ 0x{1:02X};", type, selection->getStartAddress(), (selection->getSize() + (size - 1)) / size)); + appendEditorText(fmt::format("{0} {0}_array_at_0x{1:02X}[0x{2:02X}] @ 0x{1:02X};", type, selection->getStartAddress(), (selection->getSize() + (size - 1)) / size)); } TextEditor *ViewPatternEditor::getEditorFromFocusedWindow() { @@ -2253,9 +2253,9 @@ namespace hex::plugin::builtin { std::string variableName; for (const char c : wolv::util::replaceStrings(typeName, "::", "_")) variableName += static_cast(std::tolower(c)); - variableName += hex::format("_at_0x{:02X}", selection->getStartAddress()); + variableName += fmt::format("_at_0x{:02X}", selection->getStartAddress()); - appendEditorText(hex::format("{0} {1} @ 0x{2:02X};", typeName, variableName, selection->getStartAddress())); + appendEditorText(fmt::format("{0} {1} @ 0x{2:02X};", typeName, variableName, selection->getStartAddress())); }); } diff --git a/plugins/builtin/source/content/views/view_provider_settings.cpp b/plugins/builtin/source/content/views/view_provider_settings.cpp index 504addb12..dc13595d7 100644 --- a/plugins/builtin/source/content/views/view_provider_settings.cpp +++ b/plugins/builtin/source/content/views/view_provider_settings.cpp @@ -54,7 +54,7 @@ namespace hex::plugin::builtin { if (errorMessage.empty()) { ui::ToastError::open("hex.builtin.view.provider_settings.load_error"_lang); } else { - ui::ToastError::open(hex::format("hex.builtin.view.provider_settings.load_error_details"_lang, errorMessage)); + ui::ToastError::open(fmt::format("hex.builtin.view.provider_settings.load_error_details"_lang, errorMessage)); } TaskManager::doLater([=] { ImHexApi::Provider::remove(provider); }); } diff --git a/plugins/builtin/source/content/views/view_store.cpp b/plugins/builtin/source/content/views/view_store.cpp index 47dac3bdb..8bdf702c5 100644 --- a/plugins/builtin/source/content/views/view_store.cpp +++ b/plugins/builtin/source/content/views/view_store.cpp @@ -211,7 +211,7 @@ namespace hex::plugin::builtin { if (ImGuiExt::IconButton(ICON_VS_CLOUD_DOWNLOAD, ImGui::GetStyleColorVec4(ImGuiCol_Text))) { this->updateAll(); } - ImGuiExt::InfoTooltip(hex::format("hex.builtin.view.store.update_count"_lang, m_updateCount.load()).c_str()); + ImGuiExt::InfoTooltip(fmt::format("hex.builtin.view.store.update_count"_lang, m_updateCount.load()).c_str()); ImGui::EndDisabled(); diff --git a/plugins/builtin/source/content/views/view_tools.cpp b/plugins/builtin/source/content/views/view_tools.cpp index 1af0e894e..22f886a50 100644 --- a/plugins/builtin/source/content/views/view_tools.cpp +++ b/plugins/builtin/source/content/views/view_tools.cpp @@ -38,7 +38,7 @@ namespace hex::plugin::builtin { if (m_detachedTools[unlocalizedName]) continue; // Draw the tool - if (ImGui::CollapsingHeader(hex::format("{} {}", icon, Lang(unlocalizedName)).c_str())) { + if (ImGui::CollapsingHeader(fmt::format("{} {}", icon, Lang(unlocalizedName)).c_str())) { function(); ImGui::NewLine(); } else { @@ -75,7 +75,7 @@ namespace hex::plugin::builtin { if (!m_detachedTools[unlocalizedName]) continue; // Load the window height that is dependent on the tool content - const auto windowName = hex::format("{} {}", icon, View::toWindowName(unlocalizedName)); + const auto windowName = fmt::format("{} {}", icon, View::toWindowName(unlocalizedName)); const auto height = m_windowHeights[ImGui::FindWindowByName(windowName.c_str())]; if (height > 0) ImGui::SetNextWindowSizeConstraints(ImVec2(400_scaled, height), ImVec2(FLT_MAX, height)); diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index a05e9f2ff..ae2413c51 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -310,7 +310,7 @@ namespace hex::plugin::builtin { ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5_scaled); ImGui::Image(*s_nightlyTexture, s_nightlyTexture->getSize()); - ImGuiExt::InfoTooltip(hex::format("{0}\n\nCommit: {1}@{2}", "hex.builtin.welcome.nightly_build"_lang, ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash(true)).c_str()); + ImGuiExt::InfoTooltip(fmt::format("{0}\n\nCommit: {1}@{2}", "hex.builtin.welcome.nightly_build"_lang, ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash(true)).c_str()); ImGui::SetCursorPos(cursor); } @@ -455,7 +455,7 @@ namespace hex::plugin::builtin { hovered = ImGui::IsItemHovered(); if (ImGui::IsItemClicked()) { - hex::openWebpage(ImHexApiURL + hex::format("/info/{}/link", hex::toLower(ImHexApi::System::getOSName()))); + hex::openWebpage(ImHexApiURL + fmt::format("/info/{}/link", hex::toLower(ImHexApi::System::getOSName()))); } } ImGuiExt::EndSubWindow(); @@ -643,9 +643,9 @@ namespace hex::plugin::builtin { return ImGuiExt::Texture::fromSVG(romfs::get(path).span(), width, 0, ImGuiExt::Texture::Filter::Linear); }; - s_bannerTexture = changeTextureSvg(hex::format("assets/{}/banner.svg", ThemeManager::getImageTheme()), 300 * scale); - s_nightlyTexture = changeTextureSvg(hex::format("assets/{}/nightly.svg", "common"), 35 * scale); - s_backdropTexture = changeTexture(hex::format("assets/{}/backdrop.png", ThemeManager::getImageTheme())); + s_bannerTexture = changeTextureSvg(fmt::format("assets/{}/banner.svg", ThemeManager::getImageTheme()), 300 * scale); + s_nightlyTexture = changeTextureSvg(fmt::format("assets/{}/nightly.svg", "common"), 35 * scale); + s_backdropTexture = changeTexture(fmt::format("assets/{}/backdrop.png", ThemeManager::getImageTheme())); }; RequestChangeTheme::subscribe([]() { updateTextures(ImHexApi::System::getGlobalScale()); }); @@ -729,7 +729,7 @@ namespace hex::plugin::builtin { } RequestUpdateWindowTitle::post(); } else { - ui::ToastError::open(hex::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(backupFilePath))); + ui::ToastError::open(fmt::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(backupFilePath))); } } else { if (hasProject) { @@ -803,7 +803,7 @@ namespace hex::plugin::builtin { if (!s_infoBannerTexture->isValid() && allowNetworking) { TaskManager::createBackgroundTask("hex.builtin.task.loading_banner", [](auto&) { HttpRequest request("GET", - ImHexApiURL + hex::format("/info/{}/image", hex::toLower(ImHexApi::System::getOSName()))); + ImHexApiURL + fmt::format("/info/{}/image", hex::toLower(ImHexApi::System::getOSName()))); auto response = request.downloadFile().get(); diff --git a/plugins/diffing/source/content/views/view_diff.cpp b/plugins/diffing/source/content/views/view_diff.cpp index e097f2604..85ac27600 100644 --- a/plugins/diffing/source/content/views/view_diff.cpp +++ b/plugins/diffing/source/content/views/view_diff.cpp @@ -327,7 +327,7 @@ namespace hex::plugin::diffing { // Draw start address ImGui::TableNextColumn(); - if (ImGui::Selectable(hex::format("0x{:04X} - 0x{:04X}", regionA.start, regionA.end).c_str(), false, ImGuiSelectableFlags_SpanAllColumns)) { + if (ImGui::Selectable(fmt::format("0x{:04X} - 0x{:04X}", regionA.start, regionA.end).c_str(), false, ImGuiSelectableFlags_SpanAllColumns)) { const Region selectionA = { regionA.start, ((regionA.end - regionA.start) + 1) }; const Region selectionB = { regionB.start, ((regionB.end - regionB.start) + 1) }; @@ -347,7 +347,7 @@ namespace hex::plugin::diffing { // Draw end address ImGui::TableNextColumn(); - ImGui::TextUnformatted(hex::format("0x{:04X} - 0x{:04X}", regionB.start, regionB.end).c_str()); + ImGui::TextUnformatted(fmt::format("0x{:04X} - 0x{:04X}", regionB.start, regionB.end).c_str()); const auto &providers = ImHexApi::Provider::getProviders(); std::vector data; diff --git a/plugins/disassembler/source/content/disassemblers/capstone_architectures.cpp b/plugins/disassembler/source/content/disassemblers/capstone_architectures.cpp index 8eabdfc30..3982636cd 100644 --- a/plugins/disassembler/source/content/disassemblers/capstone_architectures.cpp +++ b/plugins/disassembler/source/content/disassemblers/capstone_architectures.cpp @@ -67,7 +67,7 @@ namespace hex::plugin::disasm { disassembly.operators = m_instruction->op_str; for (u16 j = 0; j < m_instruction->size; j++) - disassembly.bytes += hex::format("{0:02X} ", m_instruction->bytes[j]); + disassembly.bytes += fmt::format("{0:02X} ", m_instruction->bytes[j]); disassembly.bytes.pop_back(); return disassembly; diff --git a/plugins/disassembler/source/content/disassemblers/custom_architectures.cpp b/plugins/disassembler/source/content/disassemblers/custom_architectures.cpp index c89d6d266..9ce1924e2 100644 --- a/plugins/disassembler/source/content/disassemblers/custom_architectures.cpp +++ b/plugins/disassembler/source/content/disassemblers/custom_architectures.cpp @@ -47,7 +47,7 @@ namespace hex::plugin::disasm { disassembly.operators = instruction.operands; for (u8 byte : instruction.bytes) - disassembly.bytes += hex::format("{0:02X} ", byte); + disassembly.bytes += fmt::format("{0:02X} ", byte); if (!disassembly.bytes.empty()) disassembly.bytes.pop_back(); diff --git a/plugins/disassembler/source/content/pl_builtin_types.cpp b/plugins/disassembler/source/content/pl_builtin_types.cpp index 4b56f49de..1ae24623a 100644 --- a/plugins/disassembler/source/content/pl_builtin_types.cpp +++ b/plugins/disassembler/source/content/pl_builtin_types.cpp @@ -100,7 +100,7 @@ namespace hex::plugin::disasm { else if (equalsIgnoreCase(syntaxString, "motorola")) syntax = CS_OPT_SYNTAX_MOTOROLA; else - err::E0012.throwError(hex::format("Invalid disassembler syntax name '{}'", syntaxString)); + err::E0012.throwError(fmt::format("Invalid disassembler syntax name '{}'", syntaxString)); cs_option(capstone, CS_OPT_SYNTAX, syntax); cs_option(capstone, CS_OPT_SKIPDATA, CS_OPT_ON); diff --git a/plugins/disassembler/source/content/pl_visualizers/disassembler.cpp b/plugins/disassembler/source/content/pl_visualizers/disassembler.cpp index 480c4bcb1..970208bc4 100644 --- a/plugins/disassembler/source/content/pl_visualizers/disassembler.cpp +++ b/plugins/disassembler/source/content/pl_visualizers/disassembler.cpp @@ -37,7 +37,7 @@ namespace hex::plugin::disasm { size_t instructionCount = cs_disasm(capstone, data.data(), data.size(), u64(baseAddress), 0, &instructions); for (size_t i = 0; i < instructionCount; i++) { - disassembly.push_back({ instructions[i].address, { instructions[i].bytes, instructions[i].bytes + instructions[i].size }, hex::format("{} {}", instructions[i].mnemonic, instructions[i].op_str) }); + disassembly.push_back({ instructions[i].address, { instructions[i].bytes, instructions[i].bytes + instructions[i].size }, fmt::format("{} {}", instructions[i].mnemonic, instructions[i].op_str) }); } cs_free(instructions, instructionCount); cs_close(&capstone); @@ -58,7 +58,7 @@ namespace hex::plugin::disasm { ImGui::TableNextColumn(); std::string bytes; for (auto byte : entry.bytes) - bytes += hex::format("{0:02X} ", byte); + bytes += fmt::format("{0:02X} ", byte); ImGui::TextUnformatted(bytes.c_str()); ImGui::TableNextColumn(); ImGui::TextUnformatted(entry.instruction.c_str()); diff --git a/plugins/disassembler/source/content/views/view_disassembler.cpp b/plugins/disassembler/source/content/views/view_disassembler.cpp index aa0de0657..f3ceae792 100644 --- a/plugins/disassembler/source/content/views/view_disassembler.cpp +++ b/plugins/disassembler/source/content/views/view_disassembler.cpp @@ -111,7 +111,7 @@ namespace hex::plugin::disasm { fs::openFileBrowser(fs::DialogMode::Save, {}, [this, provider](const std::fs::path &path) { auto p = path; if (p.extension() != ".asm") - p.replace_filename(hex::format("{}{}", p.filename().string(), ".asm")); + p.replace_filename(fmt::format("{}{}", p.filename().string(), ".asm")); auto file = wolv::io::File(p, wolv::io::File::Mode::Create); if (!file.isValid()) { @@ -126,9 +126,9 @@ namespace hex::plugin::disasm { continue; if (instruction.operators.empty()) - file.writeString(hex::format("{}\n", instruction.mnemonic)); + file.writeString(fmt::format("{}\n", instruction.mnemonic)); else - file.writeString(hex::format("{} {}\n", instruction.mnemonic, instruction.operators)); + file.writeString(fmt::format("{} {}\n", instruction.mnemonic, instruction.operators)); } }); }); diff --git a/plugins/hashes/source/content/views/view_hashes.cpp b/plugins/hashes/source/content/views/view_hashes.cpp index a67001695..ab4be6804 100644 --- a/plugins/hashes/source/content/views/view_hashes.cpp +++ b/plugins/hashes/source/content/views/view_hashes.cpp @@ -176,7 +176,7 @@ namespace hex::plugin::hashes { } if (m_newHashName.empty() && m_selectedHash != nullptr) - m_newHashName = hex::format("{} {}", Lang(m_selectedHash->getUnlocalizedName()), static_cast("hex.hashes.view.hashes.hash"_lang)); + m_newHashName = fmt::format("{} {}", Lang(m_selectedHash->getUnlocalizedName()), static_cast("hex.hashes.view.hashes.hash"_lang)); if (ImGuiExt::BeginSubWindow("hex.ui.common.settings"_lang, nullptr, scaled({ 0, 250 }))) { if (m_selectedHash != nullptr) { diff --git a/plugins/remote/source/content/helpers/sftp_client.cpp b/plugins/remote/source/content/helpers/sftp_client.cpp index c25aa06b5..f63020f50 100644 --- a/plugins/remote/source/content/helpers/sftp_client.cpp +++ b/plugins/remote/source/content/helpers/sftp_client.cpp @@ -239,7 +239,7 @@ namespace hex::plugin::remote { int length = 0; libssh2_session_last_error(session, &errorString, &length, false); - return hex::format("{} ({})", std::string(errorString, static_cast(length)), libssh2_session_last_errno(session)); + return fmt::format("{} ({})", std::string(errorString, static_cast(length)), libssh2_session_last_errno(session)); } SFTPClient::RemoteFile::RemoteFile(LIBSSH2_SFTP_HANDLE* handle, OpenMode mode) : m_handle(handle), m_mode(mode) {} diff --git a/plugins/remote/source/content/providers/ssh_provider.cpp b/plugins/remote/source/content/providers/ssh_provider.cpp index c617611fd..7a5d30667 100644 --- a/plugins/remote/source/content/providers/ssh_provider.cpp +++ b/plugins/remote/source/content/providers/ssh_provider.cpp @@ -64,7 +64,7 @@ namespace hex::plugin::remote { } std::string SSHProvider::getName() const { - return hex::format("{} [{}@{}:{}]", m_remoteFilePath.filename().string(), m_username, m_host, m_port); + return fmt::format("{} [{}@{}:{}]", m_remoteFilePath.filename().string(), m_username, m_host, m_port); } @@ -104,7 +104,7 @@ namespace hex::plugin::remote { m_sftpClient = std::move(client); } } catch (const std::exception& e) { - ui::ToastError::open(hex::format("Failed to connect to SSH server: {}", e.what())); + ui::ToastError::open(fmt::format("Failed to connect to SSH server: {}", e.what())); return false; } } diff --git a/plugins/script_loader/source/loaders/dotnet/dotnet_loader.cpp b/plugins/script_loader/source/loaders/dotnet/dotnet_loader.cpp index 7462f011a..8ea6be508 100644 --- a/plugins/script_loader/source/loaders/dotnet/dotnet_loader.cpp +++ b/plugins/script_loader/source/loaders/dotnet/dotnet_loader.cpp @@ -88,7 +88,7 @@ namespace hex::script::loader { u32 result = get_hostfxr_path_ptr(buffer.data(), &bufferSize, nullptr); if (result != 0) { - log::error(hex::format("Could not get hostfxr path! 0x{:X}", result)); + log::error("Could not get hostfxr path! 0x{:X}", result); return false; } @@ -137,13 +137,13 @@ namespace hex::script::loader { log::warn("Please install version {} or later of the .NET runtime if you plan to use them. Otherwise this error can be safely ignored.", IMHEX_DOTNET_RUNTIME_VERSION); } - throw std::runtime_error(hex::format("Command line init failed 0x{:X}", result)); + throw std::runtime_error(fmt::format("Command line init failed 0x{:X}", result)); } #if defined (OS_WINDOWS) - hostfxr_set_runtime_property_value(ctx, STRING("PINVOKE_OVERRIDE"), utf8ToUtf16(hex::format("{}", reinterpret_cast(pInvokeOverride))).c_str()); + hostfxr_set_runtime_property_value(ctx, STRING("PINVOKE_OVERRIDE"), utf8ToUtf16(fmt::format("{}", reinterpret_cast(pInvokeOverride))).c_str()); #else - hostfxr_set_runtime_property_value(ctx, STRING("PINVOKE_OVERRIDE"), hex::format("{}", reinterpret_cast(pInvokeOverride)).c_str()); + hostfxr_set_runtime_property_value(ctx, STRING("PINVOKE_OVERRIDE"), fmt::format("{}", reinterpret_cast(pInvokeOverride)).c_str()); #endif hostfxr_set_error_writer([](const char_t *message) { @@ -161,7 +161,7 @@ namespace hex::script::loader { ); if (result != 0 || loadAssemblyFunction == nullptr) { - throw std::runtime_error(hex::format("Failed to get load_assembly_and_get_function_pointer delegate 0x{:X}", result)); + throw std::runtime_error(fmt::format("Failed to get load_assembly_and_get_function_pointer delegate 0x{:X}", result)); } return loadAssemblyFunction; @@ -204,7 +204,7 @@ namespace hex::script::loader { m_runMethod = [entryPoint](const std::string &methodName, bool keepLoaded, const std::fs::path &path) -> int { auto pathString = wolv::util::toUTF8String(path); - auto string = hex::format("{}||{}||{}", keepLoaded ? "LOAD" : "EXEC", methodName, pathString); + auto string = fmt::format("{}||{}||{}", keepLoaded ? "LOAD" : "EXEC", methodName, pathString); auto result = entryPoint(string.data(), string.size()); return result; @@ -213,7 +213,7 @@ namespace hex::script::loader { m_methodExists = [entryPoint](const std::string &methodName, const std::fs::path &path) -> bool { auto pathString = wolv::util::toUTF8String(path); - auto string = hex::format("CHECK||{}||{}", methodName, pathString); + auto string = fmt::format("CHECK||{}||{}", methodName, pathString); auto result = entryPoint(string.data(), string.size()); return result == 0; @@ -266,18 +266,18 @@ namespace hex::script::loader { } if (hasMain) { - this->addScript(scriptName, scriptPath, false, [this, scriptPath] { - auto result = m_runMethod("Main", false, scriptPath); + this->addScript(scriptName, scriptPath, false, [this, scriptName, scriptPath] { + const auto result = m_runMethod("Main", false, scriptPath); if (result != 0) { - ui::ToastError::open(hex::format("Script '{}' running failed with code {}", result)); + ui::ToastError::open(fmt::format("Script '{}' running failed with code {}", scriptName, result)); } }); } else if (hasOnLoad) { this->addScript(scriptName, scriptPath, true, [] {}); - auto result = m_runMethod("OnLoad", true, scriptPath); + const auto result = m_runMethod("OnLoad", true, scriptPath); if (result != 0) { TaskManager::doLater([=] { - ui::ToastError::open(hex::format("Script '{}' loading failed with code {}", scriptName, result)); + ui::ToastError::open(fmt::format("Script '{}' loading failed with code {}", scriptName, result)); }); } } diff --git a/plugins/ui/include/banners/banner_button.hpp b/plugins/ui/include/banners/banner_button.hpp index f5f15082d..f37c039d4 100644 --- a/plugins/ui/include/banners/banner_button.hpp +++ b/plugins/ui/include/banners/banner_button.hpp @@ -13,7 +13,7 @@ namespace hex::ui { : Banner(color), m_icon(icon), m_message(std::move(message)), m_buttonText(std::move(buttonText)), m_buttonCallback(std::move(buttonCallback)) { } void drawContent() override { - const std::string buttonText = hex::format(" {} ", Lang(m_buttonText).get()); + const std::string buttonText = fmt::format(" {} ", Lang(m_buttonText).get()); const auto buttonSize = ImGui::CalcTextSize(buttonText.c_str()); const auto iconSize = ImGui::CalcTextSize(m_icon); const auto textHeight = std::max(ImGui::CalcTextSize(Lang(m_message)).y, iconSize.y); diff --git a/plugins/ui/source/ui/hex_editor.cpp b/plugins/ui/source/ui/hex_editor.cpp index 68566bf57..8bfaf4b02 100644 --- a/plugins/ui/source/ui/hex_editor.cpp +++ b/plugins/ui/source/ui/hex_editor.cpp @@ -160,9 +160,9 @@ namespace hex::ui { switch (m_addressFormat) { using enum AddressFormat; default: - case Hexadecimal: return hex::format(m_upperCaseHex ? "{0}{1:0{2}X}" : "{0}{1:0{2}x}", prefix ? "0x" : "", address, width); - case Decimal: return hex::format("{0: >{1}d}", address, width); - case Octal: return hex::format("{0}{1:0{2}o}", prefix ? "0o" : "", address, width); + case Hexadecimal: return fmt::format(fmt::runtime(m_upperCaseHex ? "{0}{1:0{2}X}" : "{0}{1:0{2}x}"), prefix ? "0x" : "", address, width); + case Decimal: return fmt::format("{0: >{1}d}", address, width); + case Octal: return fmt::format("{0}{1:0{2}o}", prefix ? "0o" : "", address, width); } } @@ -849,7 +849,7 @@ namespace hex::ui { ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(0, 0)); if (ImGui::BeginTable("##ascii_column", bytesPerRow)) { for (u64 x = 0; x < bytesPerRow; x++) - ImGui::TableSetupColumn(hex::format("##ascii_cell{}", x).c_str(), ImGuiTableColumnFlags_WidthFixed, CharacterSize.x + (m_characterCellPadding * 1_scaled)); + ImGui::TableSetupColumn(fmt::format("##ascii_cell{}", x).c_str(), ImGuiTableColumnFlags_WidthFixed, CharacterSize.x + (m_characterCellPadding * 1_scaled)); ImGui::TableNextRow(); @@ -1208,7 +1208,7 @@ namespace hex::ui { ImGui::NewLine(); int byteColumnCount = m_autoFitColumns ? 0 : m_bytesPerRow / this->getBytesPerCell(); - if (ImGui::SliderInt("##byte_column_count", &byteColumnCount, 0, 128 / this->getBytesPerCell(), m_autoFitColumns ? "hex.ui.hex_editor.fit_columns"_lang : hex::format("{} {}", byteColumnCount * this->getBytesPerCell(), "hex.ui.hex_editor.columns"_lang).c_str())) { + if (ImGui::SliderInt("##byte_column_count", &byteColumnCount, 0, 128 / this->getBytesPerCell(), m_autoFitColumns ? "hex.ui.hex_editor.fit_columns"_lang : fmt::format("{} {}", byteColumnCount * this->getBytesPerCell(), "hex.ui.hex_editor.columns"_lang).c_str())) { m_bytesPerRow = byteColumnCount * this->getBytesPerCell(); m_encodingLineStartAddresses.clear(); } @@ -1217,7 +1217,7 @@ namespace hex::ui { { const u64 min = 0; const u64 max = m_provider->getActualSize(); - ImGui::SliderScalar("##separator_stride", ImGuiDataType_U64, &m_separatorStride, &min, &max, m_separatorStride == 0 ? "hex.ui.hex_editor.no_separator"_lang : hex::format("hex.ui.hex_editor.separator_stride"_lang, m_separatorStride).c_str()); + ImGui::SliderScalar("##separator_stride", ImGuiDataType_U64, &m_separatorStride, &min, &max, m_separatorStride == 0 ? "hex.ui.hex_editor.no_separator"_lang : fmt::format("hex.ui.hex_editor.separator_stride"_lang, m_separatorStride).c_str()); } { int selection = [this] { @@ -1233,9 +1233,9 @@ namespace hex::ui { }(); std::array options = { - hex::format("{}: {}", "hex.ui.common.number_format"_lang, "hex.ui.common.hexadecimal"_lang), - hex::format("{}: {}", "hex.ui.common.number_format"_lang, "hex.ui.common.decimal"_lang), - hex::format("{}: {}", "hex.ui.common.number_format"_lang, "hex.ui.common.octal"_lang) + fmt::format("{}: {}", "hex.ui.common.number_format"_lang, "hex.ui.common.hexadecimal"_lang), + fmt::format("{}: {}", "hex.ui.common.number_format"_lang, "hex.ui.common.decimal"_lang), + fmt::format("{}: {}", "hex.ui.common.number_format"_lang, "hex.ui.common.octal"_lang) }; if (ImGui::SliderInt("##format", &selection, 0, options.size() - 1, options[selection].c_str(), ImGuiSliderFlags_NoInput)) { @@ -1301,7 +1301,7 @@ namespace hex::ui { { ImGui::PushItemWidth(-1); if (ImGui::SliderScalar("##page_selection", ImGuiDataType_U32, &page, &MinPage, &pageCount, - hex::format("%llu / {0} [{1} - {2}]", + fmt::format("%llu / {0} [{1} - {2}]", pageCount, formatAddress(pageAddress, 4, true), formatAddress(pageSize == 0 ? 0 : (pageAddress + pageSize - 1), 4, true) @@ -1321,7 +1321,7 @@ namespace hex::ui { formatAddress(m_provider->getBaseAddress(), 8, true), formatAddress(m_provider->getBaseAddress() + m_provider->getActualSize(), 1, true), ImGui::GetIO().KeyCtrl - ? hex::format("{}", m_provider->getActualSize()) + ? fmt::format("{}", m_provider->getActualSize()) : hex::toByteString(m_provider->getActualSize()) ); ImGui::SetItemTooltip("%s", "hex.ui.hex_editor.data_size"_lang.get()); diff --git a/plugins/ui/source/ui/pattern_drawer.cpp b/plugins/ui/source/ui/pattern_drawer.cpp index f587a8ff0..9d9283ca6 100644 --- a/plugins/ui/source/ui/pattern_drawer.cpp +++ b/plugins/ui/source/ui/pattern_drawer.cpp @@ -151,9 +151,9 @@ namespace hex::ui { std::string text; if (bytes != 0) { if (bytes == 1) - text += hex::format("{0} byte", bytes); + text += fmt::format("{0} byte", bytes); else - text += hex::format("{0} bytes", bytes); + text += fmt::format("{0} bytes", bytes); if (bits != 0) text += ", "; @@ -161,9 +161,9 @@ namespace hex::ui { if (bits != 0) { if (bits == 1) - text += hex::format("{0} bit", bits); + text += fmt::format("{0} bit", bits); else - text += hex::format("{0} bits", bits); + text += fmt::format("{0} bits", bits); } if (bytes == 0 && bits == 0) { @@ -359,7 +359,7 @@ namespace hex::ui { ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0.5F)); bool shouldReset = false; - if (ImGui::Button(hex::format(" {} {}", ICON_VS_EYE, value).c_str(), ImVec2(width, ImGui::GetTextLineHeight()))) { + if (ImGui::Button(fmt::format(" {} {}", ICON_VS_EYE, value).c_str(), ImVec2(width, ImGui::GetTextLineHeight()))) { const auto *previousPattern = m_currVisualizedPattern; m_currVisualizedPattern = &pattern; auto lastVisualizerError = m_visualizerDrawer.getLastVisualizerError(); @@ -963,7 +963,7 @@ namespace hex::ui { ImGui::TableNextColumn(); ImGui::TableNextColumn(); - ImGui::Selectable(hex::format("... ({})", "hex.ui.pattern_drawer.double_click"_lang).c_str(), false, ImGuiSelectableFlags_SpanAllColumns); + ImGui::Selectable(fmt::format("... ({})", "hex.ui.pattern_drawer.double_click"_lang).c_str(), false, ImGuiSelectableFlags_SpanAllColumns); if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) displayEnd += DisplayEndStep; break; @@ -986,7 +986,7 @@ namespace hex::ui { chunkOpen = highlightWhenSelected(startOffset, ((endOffset + endSize) - startOffset) - 1, [&]{ const auto open = ImGui::TreeNodeEx("##TreeNode", ImGuiTreeNodeFlags_DrawLinesToNodes | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_OpenOnArrow); ImGui::SameLine(); - ImGui::TextUnformatted(hex::format("{0}[{1} ... {2}]", m_treeStyle == TreeStyle::Flattened ? this->getDisplayName(pattern).c_str() : "", i, endIndex - 1).c_str()); + ImGui::TextUnformatted(fmt::format("{0}[{1} ... {2}]", m_treeStyle == TreeStyle::Flattened ? this->getDisplayName(pattern).c_str() : "", i, endIndex - 1).c_str()); return open; }); diff --git a/plugins/visualizers/source/content/pl_inline_visualizers.cpp b/plugins/visualizers/source/content/pl_inline_visualizers.cpp index 63470f879..8780a73e9 100644 --- a/plugins/visualizers/source/content/pl_inline_visualizers.cpp +++ b/plugins/visualizers/source/content/pl_inline_visualizers.cpp @@ -41,7 +41,7 @@ namespace hex::plugin::visualizers { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0.5F)); - if (ImGui::Button(hex::format(" {} {}", ICON_VS_PLAY, pattern.getFormattedValue()).c_str(), ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()))) { + if (ImGui::Button(fmt::format(" {} {}", ICON_VS_PLAY, pattern.getFormattedValue()).c_str(), ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()))) { auto *evaluator = pattern.getEvaluator(); const auto functionName = arguments[0].toString(false); const auto &function = evaluator->findFunction(functionName); diff --git a/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp b/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp index 1932b8c27..6b03b5780 100644 --- a/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp @@ -346,16 +346,16 @@ namespace hex::plugin::visualizers { bool validateVector(const std::vector &vector, u32 vertexCount, u32 divisor, const std::string &name, std::string &errorMessage) { if (!vector.empty()) { if (vector.size() % divisor != 0) { - errorMessage = hex::format("hex.visualizers.pl_visualizer.3d.error_message_count"_lang, name , std::to_string(divisor)); + errorMessage = fmt::format("hex.visualizers.pl_visualizer.3d.error_message_count"_lang, name , std::to_string(divisor)); return false; } } else { - errorMessage = hex::format("hex.visualizers.pl_visualizer.3d.error_message_not_empty"_lang, name); + errorMessage = fmt::format("hex.visualizers.pl_visualizer.3d.error_message_not_empty"_lang, name); return false; } auto vectorCount = vector.size()/divisor; if (vectorCount != vertexCount) { - errorMessage = hex::format("hex.visualizers.pl_visualizer.3d.error_message_expected"_lang, std::to_string(vertexCount), std::to_string(vectorCount)); + errorMessage = fmt::format("hex.visualizers.pl_visualizer.3d.error_message_expected"_lang, std::to_string(vertexCount), std::to_string(vectorCount)); return false; } return true; @@ -502,7 +502,7 @@ namespace hex::plugin::visualizers { drawList->AddText( screenPos + scaled({ 5, 5 }), ImGui::GetColorU32(ImGuiCol_Text), - hex::format("X: {:.5}\nY: {:.5}", mousePos.x, mousePos.y).c_str()); + fmt::format("X: {:.5}\nY: {:.5}", mousePos.x, mousePos.y).c_str()); } } @@ -669,7 +669,7 @@ namespace hex::plugin::visualizers { errorMessage += std::to_string(badIndex) + ", "; errorMessage.pop_back(); errorMessage.pop_back(); - errorMessage += hex::format("hex.visualizers.pl_visualizer.3d.error_message_for_vertex_count"_lang.get(), s_vertexCount); + errorMessage += fmt::format("hex.visualizers.pl_visualizer.3d.error_message_for_vertex_count"_lang, s_vertexCount); throw std::runtime_error(errorMessage); } } @@ -706,7 +706,7 @@ namespace hex::plugin::visualizers { errorMessage += std::to_string(badIndex) + ", "; errorMessage.pop_back(); errorMessage.pop_back(); - errorMessage += hex::format("hex.visualizers.pl_visualizer.3d.error_message_for_vertex_count"_lang.get(), s_vertexCount); + errorMessage += fmt::format("hex.visualizers.pl_visualizer.3d.error_message_for_vertex_count"_lang, s_vertexCount); throw std::runtime_error(errorMessage); } } diff --git a/plugins/visualizers/source/content/pl_visualizers/coordinates.cpp b/plugins/visualizers/source/content/pl_visualizers/coordinates.cpp index d1bc602b2..72dba299c 100644 --- a/plugins/visualizers/source/content/pl_visualizers/coordinates.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/coordinates.cpp @@ -63,7 +63,7 @@ namespace hex::plugin::visualizers { addressTask = TaskManager::createBackgroundTask("hex.visualizers.pl_visualizer.coordinates.querying", [lat = latitude, lon = longitude](auto &) { constexpr static auto ApiURL = "https://geocode.maps.co/reverse?lat={}&lon={}&format=jsonv2"; - HttpRequest request("GET", hex::format(ApiURL, lat, lon)); + HttpRequest request("GET", fmt::format(ApiURL, lat, lon)); auto response = request.execute().get(); if (!response.isSuccess()) @@ -76,13 +76,13 @@ namespace hex::plugin::visualizers { std::scoped_lock lock(addressMutex); if (jsonAddr.contains("village")) { - address = hex::format("{} {}, {} {}", + address = fmt::format("{} {}, {} {}", jsonAddr["village"].get(), jsonAddr["county"].get(), jsonAddr["state"].get(), jsonAddr["country"].get()); } else if (jsonAddr.contains("city")) { - address = hex::format("{}, {} {}, {} {}", + address = fmt::format("{}, {} {}, {} {}", jsonAddr["road"].get(), jsonAddr["quarter"].get(), jsonAddr["city"].get(), diff --git a/plugins/visualizers/source/content/pl_visualizers/sound.cpp b/plugins/visualizers/source/content/pl_visualizers/sound.cpp index e72d2e211..b73b368bb 100644 --- a/plugins/visualizers/source/content/pl_visualizers/sound.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/sound.cpp @@ -28,9 +28,9 @@ namespace hex::plugin::visualizers { static TaskHolder resetTask; if (sampleRate == 0) - throw std::logic_error(hex::format("Invalid sample rate: {}", sampleRate)); + throw std::logic_error(fmt::format("Invalid sample rate: {}", sampleRate)); else if (channels == 0) - throw std::logic_error(hex::format("Invalid channel count: {}", channels)); + throw std::logic_error(fmt::format("Invalid channel count: {}", channels)); u64 sampledIndex; if (shouldReset) { waveData.clear(); diff --git a/plugins/visualizers/source/content/pl_visualizers/table.cpp b/plugins/visualizers/source/content/pl_visualizers/table.cpp index eb3dea771..d199e8ca1 100644 --- a/plugins/visualizers/source/content/pl_visualizers/table.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/table.cpp @@ -39,7 +39,7 @@ namespace hex::plugin::visualizers { } if (width >= IMGUI_TABLE_MAX_COLUMNS) - throw std::logic_error(hex::format("Table visualizer cannot have more than {} columns.", IMGUI_TABLE_MAX_COLUMNS)); + throw std::logic_error(fmt::format("Table visualizer cannot have more than {} columns.", IMGUI_TABLE_MAX_COLUMNS)); if (ImGui::BeginTable("##visualizer_table", width, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) { for (u64 i = 0; i < height; i += 1) { diff --git a/plugins/visualizers/source/content/pl_visualizers/timestamp.cpp b/plugins/visualizers/source/content/pl_visualizers/timestamp.cpp index 3d6faa6c7..c0286eedd 100644 --- a/plugins/visualizers/source/content/pl_visualizers/timestamp.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/timestamp.cpp @@ -82,7 +82,7 @@ namespace hex::plugin::visualizers { // Draw clock sections and numbers for (u8 i = 0; i < 12; ++i) { - auto text = hex::format("{}", (((i + 2) % 12) + 1)); + auto text = fmt::format("{}", (((i + 2) % 12) + 1)); drawList->AddLine(center + sectionPos(i) * size / 2.2F, center + sectionPos(i) * size / 2, ImGui::GetColorU32(ImGuiCol_TextDisabled), 1_scaled); drawList->AddText(center + sectionPos(i) * size / 3.0F - ImGui::CalcTextSize(text.c_str()) / 2, ImGui::GetColorU32(ImGuiCol_Text), text.c_str()); } diff --git a/plugins/windows/source/content/settings_entries.cpp b/plugins/windows/source/content/settings_entries.cpp index 90eca6953..8f1e0d757 100644 --- a/plugins/windows/source/content/settings_entries.cpp +++ b/plugins/windows/source/content/settings_entries.cpp @@ -22,11 +22,11 @@ namespace hex::plugin::windows { // Add 'Icon' key to use first icon embedded in exe std::array imHexPath = { 0 }; GetModuleFileNameA(nullptr, imHexPath.data(), imHexPath.size()); - auto iconValue = hex::format(R"("{}",0)", imHexPath.data()); + auto iconValue = fmt::format(R"("{}",0)", imHexPath.data()); RegSetKeyValueA(imHexRootKey, nullptr, "Icon", REG_SZ, iconValue.c_str(), iconValue.size() + 1); // Add 'command' key to pass the right-clicked file path as first argument to ImHex - auto commandValue = hex::format(R"("{}" "%1")", imHexPath.data()); + auto commandValue = fmt::format(R"("{}" "%1")", imHexPath.data()); RegSetValueA(imHexRootKey, "command", REG_SZ, commandValue.c_str(), commandValue.size() + 1); RegCloseKey(imHexRootKey); } diff --git a/plugins/windows/source/views/view_tty_console.cpp b/plugins/windows/source/views/view_tty_console.cpp index c2d294292..093f4e3c6 100644 --- a/plugins/windows/source/views/view_tty_console.cpp +++ b/plugins/windows/source/views/view_tty_console.cpp @@ -247,7 +247,7 @@ namespace hex::plugin::windows { } else if (byte == '\r') { // Ignore carriage return } else { - m_receiveLines.back() += hex::format("<{:02X}>", static_cast(byte)); + m_receiveLines.back() += fmt::format("<{:02X}>", static_cast(byte)); } }; diff --git a/plugins/yara_rules/source/content/views/view_yara.cpp b/plugins/yara_rules/source/content/views/view_yara.cpp index 94c9446f1..44cfeef81 100644 --- a/plugins/yara_rules/source/content/views/view_yara.cpp +++ b/plugins/yara_rules/source/content/views/view_yara.cpp @@ -208,9 +208,9 @@ namespace hex::plugin::yara { ImGui::TableNextColumn(); ImGui::TextUnformatted(match.variable.c_str()); ImGui::TableNextColumn(); - ImGui::TextUnformatted(hex::format("0x{0:08X}", match.region.getStartAddress()).c_str()); + ImGui::TextUnformatted(fmt::format("0x{0:08X}", match.region.getStartAddress()).c_str()); ImGui::TableNextColumn(); - ImGui::TextUnformatted(hex::format("0x{0:08X}", match.region.getSize()).c_str()); + ImGui::TextUnformatted(fmt::format("0x{0:08X}", match.region.getSize()).c_str()); } ImGui::TreePop(); } @@ -283,12 +283,12 @@ namespace hex::plugin::yara { for (YaraRule::Rule &rule : *m_matchedRules) { for (auto &match : rule.matches) { - auto tags = hex::format("{}", fmt::join(rule.tags, ", ")); + auto tags = fmt::format("{}", fmt::join(rule.tags, ", ")); m_highlights->insert( { match.region.getStartAddress(), match.region.getEndAddress() }, - hex::format("rule {0}{1} {{ {2} }}", + fmt::format("rule {0}{1} {{ {2} }}", rule.identifier, - tags.empty() ? "" : hex::format(" : {}", tags), + tags.empty() ? "" : fmt::format(" : {}", tags), match.variable ) );