From 2803948cb6e9b35f2d19b7f2bceacb928ae2a35b Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 24 Nov 2025 14:44:33 +0100 Subject: [PATCH 1/3] Miscellaneous warning fixes. - warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning) - IMGUI_DEFINE_MATH_OPERATORS is not needed by the lib. --- TextEditor.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/TextEditor.cpp b/TextEditor.cpp index 02966f0b..1fb78064 100644 --- a/TextEditor.cpp +++ b/TextEditor.cpp @@ -6,8 +6,7 @@ #include "TextEditor.h" -#define IMGUI_DEFINE_MATH_OPERATORS -#include "imgui.h" // for imGui::GetCurrentWindow() +#include "imgui.h" // TODO // - multiline comments vs single-line: latter is blocking start of a ML @@ -419,7 +418,7 @@ TextEditor::Coordinates TextEditor::FindWordEnd(const Coordinates & aFrom) const if (cindex >= (int)line.size()) return at; - bool prevspace = (bool)isspace(line[cindex].mChar); + bool prevspace = isspace(line[cindex].mChar) != 0; auto cstart = (PaletteIndex)line[cindex].mColorIndex; while (cindex < (int)line.size()) { @@ -453,7 +452,7 @@ TextEditor::Coordinates TextEditor::FindNextWord(const Coordinates & aFrom) cons if (cindex < (int)mLines[at.mLine].size()) { auto& line = mLines[at.mLine]; - isword = isalnum(line[cindex].mChar); + isword = isalnum(line[cindex].mChar) != 0; skip = isword; } @@ -468,7 +467,7 @@ TextEditor::Coordinates TextEditor::FindNextWord(const Coordinates & aFrom) cons auto& line = mLines[at.mLine]; if (cindex < (int)line.size()) { - isword = isalnum(line[cindex].mChar); + isword = isalnum(line[cindex].mChar) != 0; if (isword && !skip) return Coordinates(at.mLine, GetCharacterColumn(at.mLine, cindex)); From 4335e748cec77c6f416031f3b10d19490e1d5cdd Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 24 Nov 2025 14:42:52 +0100 Subject: [PATCH 2/3] Update to work on latest Dear ImGui: update obsolete calls to PushAllowKeyboardFocus()/PopAllowKeyboardFocus(). Require imgui 1.89.4 (2023-03). --- TextEditor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TextEditor.cpp b/TextEditor.cpp index 1fb78064..c44fc05d 100644 --- a/TextEditor.cpp +++ b/TextEditor.cpp @@ -1131,7 +1131,7 @@ void TextEditor::Render(const char* aTitle, const ImVec2& aSize, bool aBorder) if (mHandleKeyboardInputs) { HandleKeyboardInputs(); - ImGui::PushAllowKeyboardFocus(true); + ImGui::PushItemFlag(ImGuiItemFlags_NoTabStop, false); } if (mHandleMouseInputs) @@ -1141,7 +1141,7 @@ void TextEditor::Render(const char* aTitle, const ImVec2& aSize, bool aBorder) Render(); if (mHandleKeyboardInputs) - ImGui::PopAllowKeyboardFocus(); + ImGui::PopItemFlag(); if (!mIgnoreImGuiChild) ImGui::EndChild(); From 7454c1f421be04f05f1c58eb2d3db5efaace2e19 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 24 Nov 2025 14:41:26 +0100 Subject: [PATCH 3/3] Update to work on latest Dear ImGui: removed obsolete calls to GetKeyIndex(). Require imgui 1.87 (2022-02). --- TextEditor.cpp | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/TextEditor.cpp b/TextEditor.cpp index c44fc05d..28145d71 100644 --- a/TextEditor.cpp +++ b/TextEditor.cpp @@ -710,55 +710,55 @@ void TextEditor::HandleKeyboardInputs() io.WantCaptureKeyboard = true; io.WantTextInput = true; - if (!IsReadOnly() && ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Z))) + if (!IsReadOnly() && ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Z)) Undo(); - else if (!IsReadOnly() && !ctrl && !shift && alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Backspace))) + else if (!IsReadOnly() && !ctrl && !shift && alt && ImGui::IsKeyPressed(ImGuiKey_Backspace)) Undo(); - else if (!IsReadOnly() && ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Y))) + else if (!IsReadOnly() && ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Y)) Redo(); - else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow))) + else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGuiKey_UpArrow)) MoveUp(1, shift); - else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow))) + else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGuiKey_DownArrow)) MoveDown(1, shift); - else if (!alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_LeftArrow))) + else if (!alt && ImGui::IsKeyPressed(ImGuiKey_LeftArrow)) MoveLeft(1, shift, ctrl); - else if (!alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_RightArrow))) + else if (!alt && ImGui::IsKeyPressed(ImGuiKey_RightArrow)) MoveRight(1, shift, ctrl); - else if (!alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageUp))) + else if (!alt && ImGui::IsKeyPressed(ImGuiKey_PageUp)) MoveUp(GetPageSize() - 4, shift); - else if (!alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageDown))) + else if (!alt && ImGui::IsKeyPressed(ImGuiKey_PageDown)) MoveDown(GetPageSize() - 4, shift); - else if (!alt && ctrl && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Home))) + else if (!alt && ctrl && ImGui::IsKeyPressed(ImGuiKey_Home)) MoveTop(shift); - else if (ctrl && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_End))) + else if (ctrl && !alt && ImGui::IsKeyPressed(ImGuiKey_End)) MoveBottom(shift); - else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Home))) + else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGuiKey_Home)) MoveHome(shift); - else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_End))) + else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGuiKey_End)) MoveEnd(shift); - else if (!IsReadOnly() && !ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Delete))) + else if (!IsReadOnly() && !ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Delete)) Delete(); - else if (!IsReadOnly() && !ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Backspace))) + else if (!IsReadOnly() && !ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Backspace)) Backspace(); - else if (!ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Insert))) + else if (!ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Insert)) mOverwrite ^= true; - else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Insert))) + else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Insert)) Copy(); - else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C))) + else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_C)) Copy(); - else if (!IsReadOnly() && !ctrl && shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Insert))) + else if (!IsReadOnly() && !ctrl && shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Insert)) Paste(); - else if (!IsReadOnly() && ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_V))) + else if (!IsReadOnly() && ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_V)) Paste(); - else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_X))) + else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_X)) Cut(); - else if (!ctrl && shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Delete))) + else if (!ctrl && shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Delete)) Cut(); - else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_A))) + else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_A)) SelectAll(); - else if (!IsReadOnly() && !ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Enter))) + else if (!IsReadOnly() && !ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Enter)) EnterCharacter('\n', false); - else if (!IsReadOnly() && !ctrl && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Tab))) + else if (!IsReadOnly() && !ctrl && !alt && ImGui::IsKeyPressed(ImGuiKey_Tab)) EnterCharacter('\t', shift); if (!IsReadOnly() && !io.InputQueueCharacters.empty())