Log/Capture: Added LogTextV, a va_list variant of LogText. (#3828)
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 432976a..7853699 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -59,6 +59,7 @@
- Examples: Reworked setup of clear color to be compatible with transparent values.
- CI: Use a dedicated "scheduled" workflow to trigger scheduled builds. Forks may disable this workflow if
scheduled builds builds are not required. [@rokups]
+- Log/Capture: Added LogTextV, a va_list variant of LogText. [@PathogenDavid]
-----------------------------------------------------------------------
diff --git a/imgui.cpp b/imgui.cpp
index dfba47e..80b0044 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -9911,14 +9911,8 @@
//-----------------------------------------------------------------------------
// Pass text data straight to log (without being displayed)
-void ImGui::LogText(const char* fmt, ...)
+static inline void LogTextV(ImGuiContext& g, const char* fmt, va_list args)
{
- ImGuiContext& g = *GImGui;
- if (!g.LogEnabled)
- return;
-
- va_list args;
- va_start(args, fmt);
if (g.LogFile)
{
g.LogBuffer.Buf.resize(0);
@@ -9929,9 +9923,29 @@
{
g.LogBuffer.appendfv(fmt, args);
}
+}
+
+void ImGui::LogText(const char* fmt, ...)
+{
+ ImGuiContext& g = *GImGui;
+ if (!g.LogEnabled)
+ return;
+
+ va_list args;
+ va_start(args, fmt);
+ LogTextV(g, fmt, args);
va_end(args);
}
+void ImGui::LogTextV(const char* fmt, va_list args)
+{
+ ImGuiContext& g = *GImGui;
+ if (!g.LogEnabled)
+ return;
+
+ LogTextV(g, fmt, args);
+}
+
// Internal version that takes a position to decide on newline placement and pad items according to their depth.
// We split text into individual lines to add current tree level padding
// FIXME: This code is a little complicated perhaps, considering simplifying the whole system.
diff --git a/imgui.h b/imgui.h
index db42472..be95aac 100644
--- a/imgui.h
+++ b/imgui.h
@@ -748,6 +748,7 @@
IMGUI_API void LogFinish(); // stop logging (close file, etc.)
IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard
IMGUI_API void LogText(const char* fmt, ...) IM_FMTARGS(1); // pass text data straight to log (without being displayed)
+ IMGUI_API void LogTextV(const char* fmt, va_list args) IM_FMTLIST(1);
// Drag and Drop
// - If you stop calling BeginDragDropSource() the payload is preserved however it won't have a preview tooltip (we currently display a fallback "..." tooltip as replacement)