mirror of https://github.com/WerWolv/ImHex.git
fix: SHIFT + Tab not removing tabs in pattern editor
This commit is contained in:
parent
2c0553f8fd
commit
a561cee54b
|
@ -1184,10 +1184,26 @@ void TextEditor::EnterCharacter(ImWchar aChar, bool aShift) {
|
||||||
} else if (aChar == '\t') {
|
} else if (aChar == '\t') {
|
||||||
auto &line = mLines[coord.mLine];
|
auto &line = mLines[coord.mLine];
|
||||||
auto cindex = GetCharacterIndex(coord);
|
auto cindex = GetCharacterIndex(coord);
|
||||||
|
|
||||||
|
if (!aShift) {
|
||||||
auto spacesToInsert = mTabSize - (cindex % mTabSize);
|
auto spacesToInsert = mTabSize - (cindex % mTabSize);
|
||||||
for (int j = 0; j < spacesToInsert; j++)
|
for (int j = 0; j < spacesToInsert; j++)
|
||||||
line.insert(line.begin() + cindex, Glyph(' ', PaletteIndex::Background));
|
line.insert(line.begin() + cindex, Glyph(' ', PaletteIndex::Background));
|
||||||
SetCursorPosition(Coordinates(coord.mLine, GetCharacterColumn(coord.mLine, cindex + spacesToInsert)));
|
SetCursorPosition(Coordinates(coord.mLine, GetCharacterColumn(coord.mLine, cindex + spacesToInsert)));
|
||||||
|
} else {
|
||||||
|
auto spacesToRemove = (cindex % mTabSize);
|
||||||
|
if (spacesToRemove == 0) spacesToRemove = 4;
|
||||||
|
|
||||||
|
for (int j = 0; j < spacesToRemove; j++) {
|
||||||
|
if ((line.begin() + cindex - 1)->mChar == ' ') {
|
||||||
|
line.erase(line.begin() + cindex - 1);
|
||||||
|
cindex -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetCursorPosition(Coordinates(coord.mLine, GetCharacterColumn(coord.mLine, std::max(0, cindex))));
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
char buf[7];
|
char buf[7];
|
||||||
int e = ImTextCharToUtf8(buf, 7, aChar);
|
int e = ImTextCharToUtf8(buf, 7, aChar);
|
||||||
|
|
Loading…
Reference in New Issue