mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 22:00:28 +01:00
[escher/text_input] Fix reload and scroll after deleteSelectedText
This commit is contained in:
@@ -84,6 +84,9 @@ void TextInput::ContentView::reloadRectFromPosition(const char * position, bool
|
||||
}
|
||||
|
||||
void TextInput::ContentView::reloadRectFromAndToPositions(const char * start, const char * end) {
|
||||
if (start == end) {
|
||||
return;
|
||||
}
|
||||
KDRect startFrame = glyphFrameAtPosition(text(), start);
|
||||
KDRect endFrame = glyphFrameAtPosition(text(), end);
|
||||
bool onSameLine = startFrame.y() == endFrame.y();
|
||||
@@ -132,6 +135,17 @@ void TextInput::scrollToCursor() {
|
||||
scrollToContentRect(contentView()->cursorRect(), true);
|
||||
}
|
||||
|
||||
void TextInput::deleteSelectedText() {
|
||||
assert(!contentView()->selectionIsEmpty());
|
||||
const char * previousSelectionStart = contentView()->selectionStart();
|
||||
const char * previousSelectionEnd = contentView()->selectionEnd();
|
||||
size_t removedLength = contentView()->deleteSelectedText();
|
||||
if (previousSelectionEnd == contentView()->cursorLocation()) {
|
||||
setCursorLocation(contentView()->cursorLocation() - removedLength);
|
||||
}
|
||||
contentView()->reloadRectFromPosition(previousSelectionStart, true);
|
||||
}
|
||||
|
||||
bool TextInput::setCursorLocation(const char * location) {
|
||||
assert(location != nullptr);
|
||||
const char * adjustedLocation = maxCharPointer(location, text());
|
||||
|
||||
Reference in New Issue
Block a user