Skip to content

Commit

Permalink
imgui: disable utf-8 support for color text editor
Browse files Browse the repository at this point in the history
depending on character sequence, it might break level entities syntax highlight when colored text is involved
  • Loading branch information
alexey-lysiuk committed Jan 11, 2025
1 parent 8724966 commit ac40d7c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Quake/ImGuiColorTextEdit/TextEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,21 @@ bool TextEditor::Render(const char* aTitle, bool aParentIsFocused, const ImVec2&
// ------------------------------------ //
// ---------- Generic utils ----------- //

#ifdef IMGUI_EDITOR_QSEXP

static constexpr int UTF8CharLength(char)
{
return 1;
}

static constexpr int ImTextCharToUtf8(char* buf, int, unsigned int c)
{
buf[0] = c;
return 1;
}

#else // !IMGUI_EDITOR_QSEXP

// https://en.wikipedia.org/wiki/UTF-8
// We assume that the char is a standalone character (<128) or a leading byte of an UTF-8 code sequence (non-10xxxxxx code)
static int UTF8CharLength(char c)
Expand Down Expand Up @@ -514,6 +529,8 @@ static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c)
}
}

#endif // IMGUI_EDITOR_QSEXP

static inline bool CharIsWordChar(char ch)
{
int sizeInBytes = UTF8CharLength(ch);
Expand Down

0 comments on commit ac40d7c

Please sign in to comment.