Skip to content

Commit 904b663

Browse files
committed
Clarify support for "%s" shortcuts in functions taking format strings. (#9404, #3466, #6846)
1 parent 3e7b79a commit 904b663

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

imgui.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,8 @@ namespace ImGui
613613
IMGUI_API ImGuiID GetID(int int_id);
614614

615615
// Widgets: Text
616-
IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text.
616+
// - Note that all functions taking format strings in the API may be passed ("%s", text) or ("%.*s", text_len, text): which will automatically bypass the formatter.
617+
IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Practically equivalent to 'Text("%s", text)' but doesn't require null terminated string if 'text_end' is specified.
617618
IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // formatted text
618619
IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1);
619620
IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();

imgui_widgets.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags)
266266
}
267267
}
268268

269+
// Note that all functions taking format strings in the API may be passed ("%s", text) or ("%.*s", text_len, text),
270+
// which will automatically bypass the formatter.
269271
void ImGui::TextUnformatted(const char* text, const char* text_end)
270272
{
271273
TextEx(text, text_end, ImGuiTextFlags_NoWidthForLargeClippedText);

0 commit comments

Comments
 (0)