From 4d78c5c9aba58447eec046a77dd0551b4d1922a7 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 13 Mar 2015 13:15:01 +0000 Subject: [PATCH] Comments and reduced ImGuiTextEditState.InitialText[] to 3 KB (assuming average use case of UTF-8 uses 3 bytes charracters) --- imgui.cpp | 2 +- imgui.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index c97b499d..5f7bd5fa 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -958,7 +958,7 @@ struct ImGuiTextEditState { ImGuiID Id; // widget id owning the text state ImWchar Text[1024]; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer. - char InitialText[1024*4+1]; // backup of end-user buffer at the time of focus (in UTF-8, unaltered) + char InitialText[1024*3+1]; // backup of end-user buffer at the time of focus (in UTF-8, unaltered) size_t CurLenA, CurLenW; // we need to maintain our buffer length in both UTF-8 and wchar format. size_t BufSizeA; // end-user buffer size, <= 1024 (or increase above) float Width; // widget width diff --git a/imgui.h b/imgui.h index 869fde9b..0ad58bf1 100644 --- a/imgui.h +++ b/imgui.h @@ -693,7 +693,6 @@ struct ImGuiTextBuffer ImVector Buf; ImGuiTextBuffer() { Buf.push_back(0); } - ~ImGuiTextBuffer() { } const char* begin() const { return &Buf.front(); } const char* end() const { return &Buf.back(); } // Buf is zero-terminated, so end() will point on the zero-terminator size_t size() const { return Buf.size()-1; } @@ -902,7 +901,7 @@ struct ImFontAtlas IMGUI_API void SetTexID(void* id) { TexID = id; } // Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list) - // (Those functions could be static, aren't so simple use case doesn't have to refer to the ImFontAtlas:: type ever if in their code) + // (Those functions could be static but aren't so most users don't have to refer to the ImFontAtlas:: name ever if in their code; just using io.Fonts->) IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs IMGUI_API const ImWchar* GetGlyphRangesChinese(); // Japanese + full set of about 21000 CJK Unified Ideographs