ui: Make text editor automatically close (, [, {, " and '
This commit is contained in:
parent
58e3031510
commit
93474d7f43
22
external/ImGui/source/TextEditor.cpp
vendored
22
external/ImGui/source/TextEditor.cpp
vendored
@ -767,8 +767,26 @@ void TextEditor::HandleKeyboardInputs()
|
|||||||
for (int i = 0; i < io.InputQueueCharacters.Size; i++)
|
for (int i = 0; i < io.InputQueueCharacters.Size; i++)
|
||||||
{
|
{
|
||||||
auto c = io.InputQueueCharacters[i];
|
auto c = io.InputQueueCharacters[i];
|
||||||
if (c != 0 && (c == '\n' || c >= 32))
|
if (c != 0 && (c == '\n' || c >= 32)) {
|
||||||
EnterCharacter(c, shift);
|
constexpr std::array<std::pair<char, char>, 5> doubleChars = {{ { '(', ')' }, { '[', ']' }, { '{', '}' }, { '"', '"' }, {'\'', '\'' } }};
|
||||||
|
|
||||||
|
bool handled = false;
|
||||||
|
for (auto [doubleCharOpen, doubleCharClose] : doubleChars) {
|
||||||
|
if (c == doubleCharOpen) {
|
||||||
|
EnterCharacter(doubleCharOpen, shift);
|
||||||
|
auto cursorPos = GetCursorPosition();
|
||||||
|
EnterCharacter(doubleCharClose, shift);
|
||||||
|
SetCursorPosition(cursorPos);
|
||||||
|
|
||||||
|
handled = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!handled)
|
||||||
|
EnterCharacter(c, shift);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
io.InputQueueCharacters.resize(0);
|
io.InputQueueCharacters.resize(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user