Internals: Added ImTextFindPreviousUtf8Codepoint() helper + comments.
diff --git a/imgui.cpp b/imgui.cpp
index 1a9267b..b00d9b5 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -2265,6 +2265,18 @@
}
return bytes_count;
}
+
+const char* ImTextFindPreviousUtf8Codepoint(const char* in_text_start, const char* in_text_curr)
+{
+ while (in_text_curr > in_text_start)
+ {
+ in_text_curr--;
+ if ((*in_text_curr & 0xC0) != 0x80)
+ return in_text_curr;
+ }
+ return in_text_start;
+}
+
IM_MSVC_RUNTIME_CHECKS_RESTORE
//-----------------------------------------------------------------------------
diff --git a/imgui.h b/imgui.h
index 8cc1b43..2ab9530 100644
--- a/imgui.h
+++ b/imgui.h
@@ -2039,7 +2039,7 @@
// (default to use native imm32 api on Windows)
void (*SetPlatformImeDataFn)(ImGuiViewport* viewport, ImGuiPlatformImeData* data);
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
- void* ImeWindowHandle; // = NULL // [Obsolete] Set ImGuiViewport::PlatformHandleRaw instead. Set this to your HWND to get automatic IME cursor positioning.
+ void* ImeWindowHandle; // = NULL // [Obsoleted in 1.87] Set ImGuiViewport::PlatformHandleRaw instead. Set this to your HWND to get automatic IME cursor positioning.
#else
void* _UnusedPadding; // Unused field to keep data structure the same size.
#endif
diff --git a/imgui_internal.h b/imgui_internal.h
index 65201ca..70d1cec 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -348,18 +348,18 @@
static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
// Helpers: String
-IMGUI_API int ImStricmp(const char* str1, const char* str2);
-IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count);
-IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count);
-IMGUI_API char* ImStrdup(const char* str);
-IMGUI_API char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* str);
-IMGUI_API const char* ImStrchrRange(const char* str_begin, const char* str_end, char c);
-IMGUI_API int ImStrlenW(const ImWchar* str);
+IMGUI_API int ImStricmp(const char* str1, const char* str2); // Case insensitive compare.
+IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count); // Case insensitive compare to a certain count.
+IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count); // Copy to a certain count and always zero terminate (strncpy doesn't).
+IMGUI_API char* ImStrdup(const char* str); // Duplicate a string.
+IMGUI_API char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* str); // Copy in provided buffer, recreate buffer if needed.
+IMGUI_API const char* ImStrchrRange(const char* str_begin, const char* str_end, char c); // Find first occurrence of 'c' in string range.
IMGUI_API const char* ImStreolRange(const char* str, const char* str_end); // End end-of-line
-IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
-IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
-IMGUI_API void ImStrTrimBlanks(char* str);
-IMGUI_API const char* ImStrSkipBlank(const char* str);
+IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end); // Find a substring in a string range.
+IMGUI_API void ImStrTrimBlanks(char* str); // Remove leading and trailing blanks from a buffer.
+IMGUI_API const char* ImStrSkipBlank(const char* str); // Find first non-blank character.
+IMGUI_API int ImStrlenW(const ImWchar* str); // Computer string length (ImWchar string)
+IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line (ImWchar string)
IM_MSVC_RUNTIME_CHECKS_OFF
static inline char ImToUpper(char c) { return (c >= 'a' && c <= 'z') ? c &= ~32 : c; }
static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
@@ -386,6 +386,7 @@
IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count)
IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8
IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8
+IMGUI_API const char* ImTextFindPreviousUtf8Codepoint(const char* in_text_start, const char* in_text_curr); // return previous UTF-8 code-point.
// Helpers: File System
#ifdef IMGUI_DISABLE_FILE_FUNCTIONS