1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-11 00:04:24 +00:00

Debug Tools: ID Stack Tool: added option to hex-encode non-ASCII characters in output path. (#8904, #4631)

This commit is contained in:
ocornut 2025-08-26 15:58:59 +02:00
parent 783f1e62cc
commit 9e864012ae
3 changed files with 19 additions and 7 deletions

View file

@ -50,6 +50,8 @@ Other Changes:
pointer, which could to issue when deleting the cloned list. (#8894, #1860) pointer, which could to issue when deleting the cloned list. (#8894, #1860)
- Debug Tools: ID Stack Tool: fixed using fixed-size buffers preventing long identifiers - Debug Tools: ID Stack Tool: fixed using fixed-size buffers preventing long identifiers
from being displayed in the tool. (#8905, #4631) from being displayed in the tool. (#8905, #4631)
- Debug Tools: ID Stack Tool: added option to hex-encode non-ASCII characters in
output path. (#8904, #4631)
- Examples: Android: Android+OpenGL3: update Gradle project (#8888, #8878) [@scribam] - Examples: Android: Android+OpenGL3: update Gradle project (#8888, #8878) [@scribam]
- Backends: SDL_GPU: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and - Backends: SDL_GPU: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and
PresentMode to configure how secondary viewports are created. Currently only used PresentMode to configure how secondary viewports are created. Currently only used

View file

@ -17760,11 +17760,17 @@ void ImGui::ShowIDStackToolWindow(bool* p_open)
char level_desc[256]; char level_desc[256];
StackToolFormatLevelInfo(tool, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc)); StackToolFormatLevelInfo(tool, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc));
tool->ResultTempBuf.append(stack_n == 0 ? "//" : "/"); tool->ResultTempBuf.append(stack_n == 0 ? "//" : "/");
for (int n = 0; level_desc[n]; n++) for (const char* p = level_desc; *p != 0; )
{ {
if (level_desc[n] == '/') unsigned int c;
const char* p_next = p + ImTextCharFromUtf8(&c, p, NULL);
if (c == '/')
tool->ResultTempBuf.append("\\"); tool->ResultTempBuf.append("\\");
tool->ResultTempBuf.append(level_desc + n, level_desc + n + 1); if (c < 256 || !tool->OptHexEncodeNonAsciiChars)
tool->ResultTempBuf.append(p, p_next);
else for (; p < p_next; p++)
tool->ResultTempBuf.appendf("\\x%02x", (unsigned char)*p);
p = p_next;
} }
} }
Text("0x%08X", tool->QueryId); Text("0x%08X", tool->QueryId);
@ -17773,11 +17779,14 @@ void ImGui::ShowIDStackToolWindow(bool* p_open)
// CTRL+C to copy path // CTRL+C to copy path
const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime; const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime;
PushStyleVarY(ImGuiStyleVar_FramePadding, 0.0f);
Checkbox("Hex-encode non-ASCII", &tool->OptHexEncodeNonAsciiChars);
SameLine(); SameLine();
PushStyleVarY(ImGuiStyleVar_FramePadding, 0.0f); Checkbox("Ctrl+C: copy path", &tool->CopyToClipboardOnCtrlC); PopStyleVar(); Checkbox("Ctrl+C: copy path", &tool->OptCopyToClipboardOnCtrlC);
PopStyleVar();
SameLine(); SameLine();
TextColored((time_since_copy >= 0.0f && time_since_copy < 0.75f && ImFmod(time_since_copy, 0.25f) < 0.25f * 0.5f) ? ImVec4(1.f, 1.f, 0.3f, 1.f) : ImVec4(), "*COPIED*"); TextColored((time_since_copy >= 0.0f && time_since_copy < 0.75f && ImFmod(time_since_copy, 0.25f) < 0.25f * 0.5f) ? ImVec4(1.f, 1.f, 0.3f, 1.f) : ImVec4(), "*COPIED*");
if (tool->CopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused)) if (tool->OptCopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused))
{ {
tool->CopyToClipboardLastTime = (float)g.Time; tool->CopyToClipboardLastTime = (float)g.Time;
SetClipboardText(tool->ResultTempBuf.c_str()); SetClipboardText(tool->ResultTempBuf.c_str());

View file

@ -2108,12 +2108,13 @@ struct ImGuiIDStackTool
int StackLevel; // -1: query stack and resize Results, >= 0: individual stack level int StackLevel; // -1: query stack and resize Results, >= 0: individual stack level
ImGuiID QueryId; // ID to query details for ImGuiID QueryId; // ID to query details for
ImVector<ImGuiStackLevelInfo> Results; ImVector<ImGuiStackLevelInfo> Results;
bool CopyToClipboardOnCtrlC; bool OptHexEncodeNonAsciiChars;
bool OptCopyToClipboardOnCtrlC;
float CopyToClipboardLastTime; float CopyToClipboardLastTime;
ImGuiTextBuffer ResultPathsBuf; ImGuiTextBuffer ResultPathsBuf;
ImGuiTextBuffer ResultTempBuf; ImGuiTextBuffer ResultTempBuf;
ImGuiIDStackTool() { memset(this, 0, sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; } ImGuiIDStackTool() { memset(this, 0, sizeof(*this)); OptHexEncodeNonAsciiChars = true; CopyToClipboardLastTime = -FLT_MAX; }
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------