1
0
mirror of synced 2025-01-29 19:17:28 +01:00

fix: Many format string warnings on MacOS and some Linux distros

This commit is contained in:
WerWolv 2021-12-31 01:10:06 +01:00
parent d3d9209b39
commit 077bc45b7d
25 changed files with 108 additions and 109 deletions

View File

@ -26,8 +26,6 @@ add_library(imgui OBJECT
source/TextEditor.cpp
source/imgui_imhex_extensions.cpp
source/imnodes.cpp
source/implot.cpp

View File

@ -244,7 +244,7 @@ namespace hex::plugin::builtin {
void drawNode() override {
ImGui::PushItemWidth(150);
if (this->m_value.has_value())
ImGui::Text("0x%llx", this->m_value.value());
ImGui::TextFormatted("0x{0:X}", this->m_value.value());
else
ImGui::TextUnformatted("???");
ImGui::PopItemWidth();
@ -270,7 +270,7 @@ namespace hex::plugin::builtin {
void drawNode() override {
ImGui::PushItemWidth(150);
if (this->m_value.has_value())
ImGui::Text("%f", this->m_value.value());
ImGui::TextFormatted("{0}", this->m_value.value());
else
ImGui::TextUnformatted("???");
ImGui::PopItemWidth();

View File

@ -68,18 +68,18 @@ namespace hex::plugin::builtin {
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableNextColumn();
ImGui::Text("%02d", i + 32 * tablePart);
ImGui::TextFormatted("{0:03d}", i + 32 * tablePart);
if (asciiTableShowOctal) {
ImGui::TableNextColumn();
ImGui::Text("0o%02o", i + 32 * tablePart);
ImGui::TextFormatted("0o{0:03o}", i + 32 * tablePart);
}
ImGui::TableNextColumn();
ImGui::Text("0x%02x", i + 32 * tablePart);
ImGui::TextFormatted("0x{0:02X}", i + 32 * tablePart);
ImGui::TableNextColumn();
ImGui::Text("%s", hex::makePrintable(i + 32 * tablePart).c_str());
ImGui::TextFormatted("{0}", hex::makePrintable(i + 32 * tablePart));
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, ((rowCount % 2) == 0) ? 0xFF101010 : 0xFF303030);
@ -295,16 +295,16 @@ namespace hex::plugin::builtin {
switch (mathDisplayType) {
case MathDisplayType::Standard:
ImGui::Text("%.3Lf", mathHistory[(mathHistory.size() - 1) - i]);
ImGui::TextFormatted("{0:.3Lf}", mathHistory[(mathHistory.size() - 1) - i]);
break;
case MathDisplayType::Scientific:
ImGui::Text("%.6Le", mathHistory[(mathHistory.size() - 1) - i]);
ImGui::TextFormatted("{0:.6Le}", mathHistory[(mathHistory.size() - 1) - i]);
break;
case MathDisplayType::Engineering:
ImGui::Text("%s", hex::toEngineeringString(mathHistory[(mathHistory.size() - 1) - i]).c_str());
ImGui::TextFormatted("{0}", hex::toEngineeringString(mathHistory[(mathHistory.size() - 1) - i]).c_str());
break;
case MathDisplayType::Programmer:
ImGui::Text("0x%llX (%llu)",
ImGui::TextFormatted("0x{0:X} ({1})",
u64(mathHistory[(mathHistory.size() - 1) - i]),
u64(mathHistory[(mathHistory.size() - 1) - i]));
break;
@ -335,16 +335,16 @@ namespace hex::plugin::builtin {
ImGui::TableNextColumn();
switch (mathDisplayType) {
case MathDisplayType::Standard:
ImGui::Text("%.3Lf", value);
ImGui::TextFormatted("{0:.3Lf}", value);
break;
case MathDisplayType::Scientific:
ImGui::Text("%.6Le", value);
ImGui::TextFormatted("{0:.6Le}", value);
break;
case MathDisplayType::Engineering:
ImGui::Text("%s", hex::toEngineeringString(value).c_str());
ImGui::TextFormatted("{}", hex::toEngineeringString(value));
break;
case MathDisplayType::Programmer:
ImGui::Text("0x%llX (%llu)", u64(value), u64(value));
ImGui::TextFormatted("0x{0:X} ({1})", u64(value), u64(value));
break;
}
}

View File

@ -7,7 +7,7 @@
#include <codicons_font.h>
#include <imgui.h>
#include <imgui_internal.h>
#include <imgui_imhex_extensions.h>
#include <hex/ui/imgui_imhex_extensions.h>
#include <atomic>
@ -28,7 +28,7 @@ namespace hex::plugin::builtin {
framerate = 1.0F / ImGui::GetIO().DeltaTime;
}
ImGui::TextUnformatted(hex::format("FPS {0:2}.{1:02}", u32(framerate), u32(framerate * 100) % 100).c_str());
ImGui::TextFormatted("FPS {0:2}.{1:02}", u32(framerate), u32(framerate * 100) % 100);
});

View File

@ -81,7 +81,7 @@ namespace hex::plugin::builtin {
if (ImGui::CollapsingHeader((std::string(name.data()) + "###bookmark").c_str())) {
ImGui::TextUnformatted("hex.builtin.view.bookmarks.title.info"_lang);
ImGui::Separator();
ImGui::TextUnformatted(hex::format("hex.builtin.view.bookmarks.address"_lang, region.address, region.address + region.size - 1, region.size).c_str());
ImGui::TextFormatted("hex.builtin.view.bookmarks.address"_lang, region.address, region.address + region.size - 1, region.size);
if (ImGui::BeginChild("hexData", ImVec2(0, ImGui::GetTextLineHeight() * 8), true)) {
size_t offset = region.address % 0x10;
@ -105,7 +105,7 @@ namespace hex::plugin::builtin {
if (byte < offset)
ImGui::TextUnformatted(" ");
else
ImGui::Text("%02X", bytes[byte]);
ImGui::TextFormatted("{0:02X}", bytes[byte]);
ImGui::SameLine();
}
ImGui::NewLine();
@ -119,7 +119,7 @@ namespace hex::plugin::builtin {
ImHexApi::Provider::get()->read(region.address + i, bytes.data(), byteCount);
for (size_t byte = 0; byte < byteCount; byte++) {
ImGui::Text("%02X", bytes[byte]);
ImGui::TextFormatted("{0:02X}", bytes[byte]);
ImGui::SameLine();
}
ImGui::NewLine();

View File

@ -136,13 +136,13 @@ namespace hex::plugin::builtin {
auto &constant = this->m_constants[this->m_filterIndices[i]];
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%s", constant.category.c_str());
ImGui::TextUnformatted(constant.category.c_str());
ImGui::TableNextColumn();
ImGui::Text("%s", constant.name.c_str());
ImGui::TextUnformatted(constant.name.c_str());
ImGui::TableNextColumn();
ImGui::Text("%s", constant.description.c_str());
ImGui::TextUnformatted(constant.description.c_str());
ImGui::TableNextColumn();
ImGui::Text("%s", constant.value.c_str());
ImGui::TextUnformatted(constant.value.c_str());
}
}
clipper.End();

View File

@ -114,7 +114,7 @@ namespace hex::plugin::builtin {
auto startY = ImGui::GetCursorPosY();
ImGui::TextUnformatted(hex::format(this->m_upperCaseHex ? "{:0{}X}:" : "{:0{}x}:", row * this->m_columnCount, addressDigitCount).c_str());
ImGui::TextFormatted(this->m_upperCaseHex ? "{:0{}X}:" : "{:0{}x}:", row * this->m_columnCount, addressDigitCount);
ImGui::SetCursorPosY(startY);
ImGui::TableNextColumn();
@ -200,7 +200,7 @@ namespace hex::plugin::builtin {
auto glyphWidth = ImGui::CalcTextSize("0").x + 1;
for (u8 i = 0; i < 2; i++) {
for (u8 col = 0; col < this->m_columnCount; col++) {
ImGui::TextUnformatted(hex::format(this->m_upperCaseHex ? "{:02X}" : "{:02x}", col).c_str());
ImGui::TextFormatted(this->m_upperCaseHex ? "{:02X}" : "{:02x}", col);
ImGui::SameLine(0.0F, col % 8 == 7 ? glyphWidth * 1.5F : glyphWidth * 0.75F);
}
ImGui::TableNextColumn();

View File

@ -6,8 +6,6 @@
#include <cstring>
#include <thread>
#include <imgui_imhex_extensions.h>
using namespace std::literals::string_literals;
namespace hex::plugin::builtin {
@ -295,13 +293,13 @@ namespace hex::plugin::builtin {
EventManager::post<RequestSelectionChange>(Region { this->m_disassembly[i].offset, this->m_disassembly[i].size });
}
ImGui::SameLine();
ImGui::Text("0x%llx", this->m_disassembly[i].address);
ImGui::TextFormatted("0x{0:X}", this->m_disassembly[i].address);
ImGui::TableNextColumn();
ImGui::Text("0x%llx", this->m_disassembly[i].offset);
ImGui::TextFormatted("0x{0:X}", this->m_disassembly[i].offset);
ImGui::TableNextColumn();
ImGui::TextUnformatted(this->m_disassembly[i].bytes.c_str());
ImGui::TableNextColumn();
ImGui::TextColored(ImColor(0xFFD69C56), "%s", this->m_disassembly[i].mnemonic.c_str());
ImGui::TextFormattedColored(ImColor(0xFFD69C56), "{}", this->m_disassembly[i].mnemonic);
ImGui::SameLine();
ImGui::TextUnformatted(this->m_disassembly[i].operators.c_str());
}

View File

@ -1,8 +1,6 @@
#include "content/views/view_help.hpp"
#include <hex/helpers/paths.hpp>
#include <imgui_imhex_extensions.h>
#include <hex/helpers/fmt.hpp>
#include <hex/helpers/utils.hpp>
@ -21,7 +19,7 @@ namespace hex::plugin::builtin {
}
void ViewHelp::drawAboutMainPage() {
ImGui::Text("ImHex Hex Editor v%s by WerWolv - " ICON_FA_CODE_BRANCH, IMHEX_VERSION);
ImGui::TextFormatted("ImHex Hex Editor v{} by WerWolv - " ICON_FA_CODE_BRANCH, IMHEX_VERSION);
#if defined(GIT_BRANCH) && defined(GIT_COMMIT_HASH)
ImGui::SameLine();

View File

@ -176,7 +176,7 @@ namespace hex::plugin::builtin {
if (provider->getPageCount() > 1) {
ImGui::SameLine();
ImGui::TextUnformatted(hex::format("hex.builtin.view.hexeditor.page"_lang, provider->getCurrentPage() + 1, provider->getPageCount()).c_str());
ImGui::TextFormatted("hex.builtin.view.hexeditor.page"_lang, provider->getCurrentPage() + 1, provider->getPageCount());
ImGui::SameLine();

View File

@ -15,7 +15,6 @@
#include <hex/helpers/magic.hpp>
#include <imgui_imhex_extensions.h>
#include <implot.h>
namespace hex::plugin::builtin {

View File

@ -58,15 +58,15 @@ namespace hex::plugin::builtin {
this->m_selectedPatch = address;
}
ImGui::SameLine();
ImGui::Text("0x%08lX", address);
ImGui::TextFormatted("0x{0:08X}", address);
ImGui::TableNextColumn();
u8 previousValue = 0x00;
provider->readRaw(address, &previousValue, sizeof(u8));
ImGui::Text("0x%02X", previousValue);
ImGui::TextFormatted("0x{0:02X}", previousValue);
ImGui::TableNextColumn();
ImGui::Text("0x%02X", patch);
ImGui::TextFormatted("0x{0:02X}", patch);
index += 1;
}

View File

@ -11,8 +11,6 @@
#include <hex/helpers/magic.hpp>
#include <hex/helpers/literals.hpp>
#include <imgui_imhex_extensions.h>
#include <nlohmann/json.hpp>
namespace hex::plugin::builtin {
@ -291,11 +289,10 @@ namespace hex::plugin::builtin {
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
ImGui::TextUnformatted(hex::format("{} / {}",
this->m_evaluatorRuntime->getCreatedPatternCount(),
this->m_evaluatorRuntime->getMaximumPatternCount()
).c_str()
);
ImGui::TextFormatted("{} / {}",
this->m_evaluatorRuntime->getCreatedPatternCount(),
this->m_evaluatorRuntime->getMaximumPatternCount()
);
}
@ -540,7 +537,7 @@ namespace hex::plugin::builtin {
}
ImGui::NewLine();
ImGui::Text("%s", static_cast<const char *>("hex.builtin.view.pattern_editor.accept_pattern.question"_lang));
ImGui::TextUnformatted("hex.builtin.view.pattern_editor.accept_pattern.question"_lang);
confirmButtons("hex.common.yes"_lang, "hex.common.no"_lang, [this]{
this->loadPatternFile(this->m_possiblePatternFiles[this->m_selectedPatternFile].string());

View File

@ -8,7 +8,7 @@
#include <regex>
#include <llvm/Demangle/Demangle.h>
#include <imgui_imhex_extensions.h>
#include <hex/ui/imgui_imhex_extensions.h>
using namespace std::literals::string_literals;
@ -149,7 +149,7 @@ namespace hex::plugin::builtin {
}
else if (this->m_foundStrings.size() > 0) {
ImGui::SameLine();
ImGui::TextUnformatted(hex::format("hex.builtin.view.strings.results"_lang, this->m_filterIndices.size()).c_str());
ImGui::TextFormatted("hex.builtin.view.strings.results"_lang, this->m_filterIndices.size());
}
@ -211,12 +211,12 @@ namespace hex::plugin::builtin {
createStringContextMenu(foundString);
ImGui::PopID();
ImGui::SameLine();
ImGui::Text("0x%08lx : 0x%08lx", foundString.offset, foundString.offset + foundString.size);
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", foundString.offset, foundString.offset + foundString.size);
ImGui::TableNextColumn();
ImGui::Text("0x%04lx", foundString.size);
ImGui::TextFormatted("0x{0:04X}", foundString.size);
ImGui::TableNextColumn();
ImGui::Text("%s", string.c_str());
ImGui::TextUnformatted(string.c_str());
}
}
clipper.End();

View File

@ -9,7 +9,6 @@
#include <filesystem>
#include <thread>
#include <imgui_imhex_extensions.h>
#include <hex/helpers/paths.hpp>
namespace hex::plugin::builtin {
@ -98,9 +97,9 @@ namespace hex::plugin::builtin {
if (!wholeDataMatch) {
ImGui::TableNextColumn();
ImGui::Text("0x%llX : 0x%llX", address, address + size - 1);
ImGui::TextFormatted("0x{0:X} : 0x{1:X}", address, address + size - 1);
ImGui::TableNextColumn();
ImGui::Text("0x%lX", size);
ImGui::TextFormatted("0x{0:X}", size);
} else {
ImGui::TableNextColumn();
ImGui::TextColored(ImVec4(0.92F, 0.25F, 0.2F, 1.0F), "%s", static_cast<const char*>("hex.builtin.view.yara.whole_data"_lang));

View File

@ -9,7 +9,7 @@ public:
void drawContent() override {
if (ImGui::Begin("Example")) {
ImGui::Text("Custom plugin window");
ImGui::TextUnformatted("Custom plugin window");
}
ImGui::End();
}

View File

@ -134,6 +134,8 @@ set(LIBIMHEX_SOURCES
source/providers/provider.cpp
source/ui/imgui_imhex_extensions.cpp
source/views/view.cpp
)

View File

@ -268,27 +268,27 @@ namespace hex::pl {
}
this->drawCommentTooltip();
ImGui::SameLine();
ImGui::Text("%s", this->getDisplayName().c_str());
ImGui::TextUnformatted(this->getDisplayName().c_str());
ImGui::TableNextColumn();
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
ImGui::TableNextColumn();
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - 1);
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - 1);
ImGui::TableNextColumn();
ImGui::Text("0x%04llX", this->getSize());
ImGui::TextFormatted("0x{0:04X}", this->getSize());
ImGui::TableNextColumn();
ImGui::TextColored(ImColor(0xFF9BC64D), "%s", this->getFormattedName().c_str());
ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{}", this->getFormattedName());
ImGui::TableNextColumn();
if (!this->m_formatterFunction.has_value())
ImGui::Text("%s", value.c_str());
ImGui::TextUnformatted(value.c_str());
else {
auto result = this->m_formatterFunction->func(this->getEvaluator(), { literal });
if (result.has_value()) {
if (auto displayValue = std::get_if<std::string>(&result.value()); displayValue != nullptr)
ImGui::Text("%s", displayValue->c_str());
ImGui::TextUnformatted(displayValue->c_str());
} else {
ImGui::Text("???");
ImGui::TextUnformatted("???");
}
}
}
@ -372,13 +372,13 @@ namespace hex::pl {
ImGui::TableNextColumn();
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
ImGui::TableNextColumn();
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - 1);
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - 1);
ImGui::TableNextColumn();
ImGui::Text("0x%04llX", this->getSize());
ImGui::TextFormatted("0x{0:04X}", this->getSize());
ImGui::TableNextColumn();
ImGui::TextColored(ImColor(0xFF9BC64D), "%s", this->getFormattedName().c_str());
ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{}", this->getFormattedName());
ImGui::TableNextColumn();
ImGui::Text("*(0x%llX)", data);
ImGui::TextFormatted("*(0x{0})", data);
if (open) {
this->m_pointedAt->createEntry(provider);
@ -769,21 +769,21 @@ namespace hex::pl {
ImGui::TableNextColumn();
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
ImGui::TableNextColumn();
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - 1);
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - 1);
ImGui::TableNextColumn();
ImGui::Text("0x%04llX", this->getSize());
ImGui::TextFormatted("0x{0:04X}", this->getSize());
ImGui::TableNextColumn();
ImGui::TextColored(ImColor(0xFF9BC64D), "%s", this->m_entries[0]->getTypeName().c_str());
ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{0}", this->m_entries[0]->getTypeName());
ImGui::SameLine(0, 0);
ImGui::TextUnformatted("[");
ImGui::SameLine(0, 0);
ImGui::TextColored(ImColor(0xFF00FF00), "%llu", this->m_entries.size());
ImGui::TextFormattedColored(ImColor(0xFF00FF00), "{0}", this->m_entries.size());
ImGui::SameLine(0, 0);
ImGui::TextUnformatted("]");
ImGui::TableNextColumn();
ImGui::Text("%s", "{ ... }");
ImGui::TextUnformatted("{ ... }");
}
if (open) {
@ -889,21 +889,21 @@ namespace hex::pl {
ImGui::TableNextColumn();
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
ImGui::TableNextColumn();
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - 1);
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - 1);
ImGui::TableNextColumn();
ImGui::Text("0x%04llX", this->getSize());
ImGui::TextFormatted("0x{0:04X}", this->getSize());
ImGui::TableNextColumn();
ImGui::TextColored(ImColor(0xFF9BC64D), "%s", this->m_template->getTypeName().c_str());
ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{0}", this->m_template->getTypeName().c_str());
ImGui::SameLine(0, 0);
ImGui::TextUnformatted("[");
ImGui::SameLine(0, 0);
ImGui::TextColored(ImColor(0xFF00FF00), "%llu", this->m_entryCount);
ImGui::TextFormattedColored(ImColor(0xFF00FF00), "{0}", this->m_entryCount);
ImGui::SameLine(0, 0);
ImGui::TextUnformatted("]");
ImGui::TableNextColumn();
ImGui::Text("%s", "{ ... }");
ImGui::TextUnformatted("{ ... }");
}
if (open) {
@ -1035,13 +1035,13 @@ namespace hex::pl {
this->drawCommentTooltip();
ImGui::TableNextColumn();
ImGui::TableNextColumn();
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - (this->getSize() == 0 ? 0 : 1));
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - (this->getSize() == 0 ? 0 : 1));
ImGui::TableNextColumn();
ImGui::Text("0x%04llX", this->getSize());
ImGui::TextFormatted("0x{0:04X}", this->getSize());
ImGui::TableNextColumn();
ImGui::TextColored(ImColor(0xFFD69C56), "struct"); ImGui::SameLine(); ImGui::Text("%s", this->getTypeName().c_str());
ImGui::TextColored(ImColor(0xFFD69C56), "struct"); ImGui::SameLine(); ImGui::TextUnformatted(this->getTypeName().c_str());
ImGui::TableNextColumn();
ImGui::Text("%s", "{ ... }");
ImGui::TextUnformatted("{ ... }");
}
if (open) {
@ -1174,14 +1174,14 @@ namespace hex::pl {
this->drawCommentTooltip();
ImGui::TableNextColumn();
ImGui::TableNextColumn();
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), std::max(this->getOffset() + this->getSize() - (this->getSize() == 0 ? 0 : 1), u64(0)));
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), std::max(this->getOffset() + this->getSize() - (this->getSize() == 0 ? 0 : 1), u64(0)));
ImGui::TableNextColumn();
ImGui::Text("0x%04llX", this->getSize());
ImGui::TextFormatted("0x{0:04X}", this->getSize());
ImGui::TableNextColumn();
ImGui::TextColored(ImColor(0xFFD69C56), "union"); ImGui::SameLine(); ImGui::Text("%s", PatternData::getTypeName().c_str());
ImGui::TextColored(ImColor(0xFFD69C56), "union"); ImGui::SameLine(); ImGui::TextUnformatted(PatternData::getTypeName().c_str());
ImGui::TableNextColumn();
ImGui::Text("%s", "{ ... }");
ImGui::TextUnformatted("{ ... }");
}
if (open) {
@ -1319,17 +1319,17 @@ namespace hex::pl {
EventManager::post<RequestSelectionChange>(Region { this->getOffset(), this->getSize() });
}
ImGui::SameLine();
ImGui::Text("%s", this->getDisplayName().c_str());
ImGui::TextUnformatted(this->getDisplayName().c_str());
ImGui::TableNextColumn();
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
ImGui::TableNextColumn();
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - 1);
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - 1);
ImGui::TableNextColumn();
ImGui::Text("0x%04llX", this->getSize());
ImGui::TextFormatted("0x{0:04X}", this->getSize());
ImGui::TableNextColumn();
ImGui::TextColored(ImColor(0xFFD69C56), "enum"); ImGui::SameLine(); ImGui::Text("%s", PatternData::getTypeName().c_str());
ImGui::TextColored(ImColor(0xFFD69C56), "enum"); ImGui::SameLine(); ImGui::TextUnformatted(PatternData::getTypeName().c_str());
ImGui::TableNextColumn();
ImGui::Text("%s", hex::format("{} (0x{:0{}X})", valueString.c_str(), value, this->getSize() * 2).c_str());
ImGui::TextFormatted("{} (0x{:0{}X})", valueString.c_str(), value, this->getSize() * 2);
}
[[nodiscard]] std::string getFormattedName() const override {
@ -1385,19 +1385,19 @@ namespace hex::pl {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%s", this->getDisplayName().c_str());
ImGui::TextUnformatted(this->getDisplayName().c_str());
ImGui::TableNextColumn();
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
ImGui::TableNextColumn();
if (this->m_bitSize == 1)
ImGui::Text("0x%08llX bit %u", this->getOffset() + this->m_bitOffset / 8, (this->m_bitOffset + (this->m_bitSize - 1)) % 8);
ImGui::TextFormatted("0x{0:08X} bit {1}", this->getOffset() + this->m_bitOffset / 8, (this->m_bitOffset + (this->m_bitSize - 1)) % 8);
else
ImGui::Text("0x%08llX bits %u - %u", this->getOffset() + this->m_bitOffset / 8, this->m_bitOffset % 8, this->m_bitOffset % 8 + (this->m_bitSize - 1) % 8);
ImGui::TextFormatted("0x{0:08X} bits {1} - {2}", this->getOffset() + this->m_bitOffset / 8, this->m_bitOffset % 8, this->m_bitOffset % 8 + (this->m_bitSize - 1) % 8);
ImGui::TableNextColumn();
if (this->m_bitSize == 1)
ImGui::Text("%u bit", this->m_bitSize);
ImGui::TextFormatted("{0} bit", this->m_bitSize);
else
ImGui::Text("%u bits", this->m_bitSize);
ImGui::TextFormatted("{0} bits", this->m_bitSize);
ImGui::TableNextColumn();
ImGui::TextColored(ImColor(0xFF9BC64D), "bits");
ImGui::TableNextColumn();
@ -1405,7 +1405,7 @@ namespace hex::pl {
u8 numBytes = (this->m_bitSize / 8) + 1;
u64 extractedValue = hex::extract(this->m_bitOffset + (this->m_bitSize - 1), this->m_bitOffset, value);
ImGui::Text("%llu (0x%llX)", extractedValue, extractedValue);
ImGui::TextFormatted("{0} (0x{1:X})", extractedValue, extractedValue);
}
}
@ -1470,11 +1470,11 @@ namespace hex::pl {
this->drawCommentTooltip();
ImGui::TableNextColumn();
ImGui::TableNextColumn();
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - 1);
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - 1);
ImGui::TableNextColumn();
ImGui::Text("0x%04llX", this->getSize());
ImGui::TextFormatted("0x{0:04X}", this->getSize());
ImGui::TableNextColumn();
ImGui::TextColored(ImColor(0xFFD69C56), "bitfield"); ImGui::SameLine(); ImGui::Text("%s", PatternData::getTypeName().c_str());
ImGui::TextColored(ImColor(0xFFD69C56), "bitfield"); ImGui::SameLine(); ImGui::TextUnformatted(PatternData::getTypeName().c_str());
ImGui::TableNextColumn();
std::string valueString = "{ ";

View File

@ -4,6 +4,7 @@
#include <imgui.h>
#include <hex/helpers/fmt.hpp>
enum ImGuiCustomCol {
ImGuiCustomCol_DescButton,
@ -88,4 +89,12 @@ namespace ImGui {
void StyleCustomColorsClassic();
void SmallProgressBar(float fraction, float yOffset = 0.0F);
void TextFormatted(const std::string &fmt, auto ... args) {
ImGui::TextUnformatted(hex::format(fmt, std::forward<decltype(args)>(args)...).c_str());
}
void TextFormattedColored(ImColor color, const std::string &fmt, auto ... args) {
ImGui::TextColored(color, "%s", hex::format(fmt, std::forward<decltype(args)>(args)...).c_str());
}
}

View File

@ -5,7 +5,7 @@
#include <imgui.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui_internal.h>
#include <imgui_imhex_extensions.h>
#include <hex/ui/imgui_imhex_extensions.h>
#include <fontawesome_font.h>
#include <codicons_font.h>

View File

@ -1,4 +1,4 @@
#include <imgui_imhex_extensions.h>
#include <hex/ui/imgui_imhex_extensions.h>
#include <imgui.h>
#include <imgui_freetype.h>

View File

@ -7,7 +7,7 @@
#include <psapi.h>
#include <imgui.h>
#include <imgui_imhex_extensions.h>
#include <hex/ui/imgui_imhex_extensions.h>
#include <fontawesome_font.h>
namespace hex::plugin::windows {
@ -71,7 +71,7 @@ namespace hex::plugin::windows {
cpuUsage *= 100;
}
ImGui::TextUnformatted(hex::format(ICON_FA_TACHOMETER_ALT " {0:2}.{1:02}", u32(cpuUsage), u32(cpuUsage * 100) % 100).c_str());
ImGui::TextFormatted(ICON_FA_TACHOMETER_ALT " {0:2}.{1:02}", u32(cpuUsage), u32(cpuUsage * 100) % 100);
});
ContentRegistry::Interface::addFooterItem([] {
@ -87,7 +87,7 @@ namespace hex::plugin::windows {
auto totalMem = memInfo.ullTotalPhys;
auto usedMem = pmc.PrivateUsage;
ImGui::TextUnformatted(hex::format(ICON_FA_MICROCHIP " {0} / {1}", hex::toByteString(usedMem), hex::toByteString(totalMem)).c_str());
ImGui::TextFormatted(ICON_FA_MICROCHIP " {0} / {1}", hex::toByteString(usedMem), hex::toByteString(totalMem));
});
}

View File

@ -1,6 +1,5 @@
#include "views/view_tty_console.hpp"
#include <imgui_imhex_extensions.h>
#include <imgui_internal.h>
#include <hex/helpers/utils.hpp>

View File

@ -10,7 +10,7 @@
#include <imgui.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui_internal.h>
#include <imgui_imhex_extensions.h>
#include <hex/ui/imgui_imhex_extensions.h>
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
#include <fontawesome_font.h>

View File

@ -21,7 +21,7 @@
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
#include <imgui_freetype.h>
#include <imgui_imhex_extensions.h>
#include <hex/ui/imgui_imhex_extensions.h>
#include <implot.h>
#include <implot_internal.h>
#include <imnodes.h>
@ -516,7 +516,7 @@ namespace hex {
view->drawContent();
}
{
if (view->getWindowOpenState()) {
bool hasWindow = ImGui::FindWindowByName(View::toWindowName(view->getUnlocalizedName()).c_str()) != nullptr;
bool focused = false;