mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher/text_input] Fix selection algorithm
There was a glitch when :
** are the selected glyphs and | is the cursor
12345678
234567|8 then Shift+up
**
This commit is contained in:
@@ -549,9 +549,9 @@ void TextArea::ContentView::moveCursorGeo(int deltaX, int deltaY) {
|
||||
}
|
||||
|
||||
void TextArea::selectUpDown(bool up) {
|
||||
const char * currentCursorLocation = contentView()->cursorLocation();
|
||||
const char * previousCursorLocation = contentView()->cursorLocation();
|
||||
contentView()->moveCursorGeo(0, up ? -1 : 1);
|
||||
const char * newCursorLocation = contentView()->cursorLocation();
|
||||
contentView()->addSelection(up ? newCursorLocation : currentCursorLocation, up ? currentCursorLocation : newCursorLocation);
|
||||
contentView()->addSelection(up ? newCursorLocation : previousCursorLocation, up ? previousCursorLocation : newCursorLocation);
|
||||
scrollToCursor();
|
||||
}
|
||||
|
||||
@@ -26,11 +26,6 @@ KDRect TextInput::ContentView::cursorRect() {
|
||||
}
|
||||
|
||||
void TextInput::ContentView::addSelection(const char * left, const char * right) {
|
||||
if ((left == m_selectionStart && right <= m_selectionEnd)
|
||||
|| (right == m_selectionEnd && left >= m_selectionStart))
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool emptySelection = selectionIsEmpty();
|
||||
if (emptySelection) {
|
||||
m_selectionStart = left;
|
||||
@@ -40,10 +35,20 @@ void TextInput::ContentView::addSelection(const char * left, const char * right)
|
||||
} else if (right == m_selectionStart) {
|
||||
m_selectionStart = left;
|
||||
} else if (right == m_selectionEnd) {
|
||||
m_selectionEnd = left;
|
||||
if (left >= m_selectionStart) {
|
||||
m_selectionEnd = left;
|
||||
} else {
|
||||
m_selectionEnd = m_selectionStart;
|
||||
m_selectionStart = left;
|
||||
}
|
||||
} else {
|
||||
assert(left == m_selectionStart);
|
||||
m_selectionStart = right;
|
||||
if (right <= m_selectionEnd) {
|
||||
m_selectionStart = right;
|
||||
} else {
|
||||
m_selectionStart = m_selectionEnd;
|
||||
m_selectionEnd = right;
|
||||
}
|
||||
}
|
||||
reloadRectFromAndToPositions(left, right);
|
||||
if (m_selectionStart == m_selectionEnd) {
|
||||
|
||||
Reference in New Issue
Block a user