mirror of
https://github.com/ocornut/imgui.git
synced 2025-10-15 14:35:59 +00:00
InputText: fixed an infinite loop error happening if a custom input text callback modifies/clear BufTextLen before calling InsertChars(). (#8994, #3237)
+ misc comments.
This commit is contained in:
@@ -64,6 +64,11 @@ Other Changes:
|
||||
The grip is not visible before hovering to reduce clutter.
|
||||
- InputText: fixed single-line InputText() not applying fine character clipping
|
||||
properly (regression in 1.92.3). (#8967) [@Cyphall]
|
||||
- InputText: fixed an infinite loop error happening if a custom input text
|
||||
callback modifies/clear BufTextLen before calling InsertChars().
|
||||
(regression from 1.92.3). Note that this never really worked correctly, but
|
||||
previously it would only temporary wreck cursor position, and since 1.92.3 it
|
||||
would go in an infinite loop. (#8994, #3237)
|
||||
- Style: added ImGuiCol_UnsavedMarker, color of the unsaved document marker when
|
||||
using ImGuiWindowFlags_UnsavedDocument/ImGuiTabItemFlags_UnsavedDocument. (#8983)
|
||||
- IO: added ImGuiPlatformIO::ClearPlatformHandlers(), ClearRendererHandlers()
|
||||
|
@@ -4804,7 +4804,7 @@ static void DemoWindowLayout()
|
||||
ImGui::SameLine();
|
||||
scroll_to_off |= ImGui::Button("Scroll Offset");
|
||||
|
||||
bool scroll_to_pos = ImGui::DragFloat("##pos", &scroll_to_pos_px, 1.00f, -10, FLT_MAX, "X/Y = %.0f px");;
|
||||
bool scroll_to_pos = ImGui::DragFloat("##pos", &scroll_to_pos_px, 1.00f, -10, FLT_MAX, "X/Y = %.0f px");
|
||||
ImGui::SameLine();
|
||||
scroll_to_pos |= ImGui::Button("Scroll To Pos");
|
||||
ImGui::PopItemWidth();
|
||||
|
@@ -2484,7 +2484,7 @@ struct ImGuiContext
|
||||
ImGuiWindow* LogWindow;
|
||||
ImFileHandle LogFile; // If != NULL log to stdout/ file
|
||||
ImGuiTextBuffer LogBuffer; // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
|
||||
const char* LogNextPrefix;
|
||||
const char* LogNextPrefix; // See comment in LogSetNextTextDecoration(): doesn't copy underlying data, use carefully!
|
||||
const char* LogNextSuffix;
|
||||
float LogLinePosY;
|
||||
bool LogLineFirstItem;
|
||||
|
@@ -3941,6 +3941,7 @@ static ImVec2 InputTextCalcTextSize(ImGuiContext* ctx, const char* text_begin, c
|
||||
{
|
||||
ImGuiContext& g = *ctx;
|
||||
ImGuiInputTextState* obj = &g.InputTextState;
|
||||
IM_ASSERT(text_end_display >= text_begin && text_end_display <= text_end);
|
||||
return ImFontCalcTextSizeEx(g.Font, g.FontSize, FLT_MAX, obj->WrapWidth, text_begin, text_end_display, text_end, out_remaining, out_offset, flags);
|
||||
}
|
||||
|
||||
@@ -4321,11 +4322,12 @@ void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, cons
|
||||
memcpy(Buf + pos, new_text, (size_t)new_text_len * sizeof(char));
|
||||
Buf[BufTextLen + new_text_len] = '\0';
|
||||
|
||||
if (CursorPos >= pos)
|
||||
CursorPos += new_text_len;
|
||||
SelectionStart = SelectionEnd = CursorPos;
|
||||
BufDirty = true;
|
||||
BufTextLen += new_text_len;
|
||||
if (CursorPos >= pos)
|
||||
CursorPos += new_text_len;
|
||||
CursorPos = ImClamp(CursorPos, 0, BufTextLen);
|
||||
SelectionStart = SelectionEnd = CursorPos;
|
||||
}
|
||||
|
||||
void ImGui::PushPasswordFont()
|
||||
|
Reference in New Issue
Block a user