mirror of https://github.com/buggins/dlangui.git
clear selection on home/end key if needed - close #421
This commit is contained in:
parent
cb8193f663
commit
9138d35a10
|
|
@ -1247,6 +1247,12 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
return _content.lineRange(_caretPos.line);
|
return _content.lineRange(_caretPos.line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// clears selection (don't change text, just unselect)
|
||||||
|
void clearSelection() {
|
||||||
|
_selectionRange = TextRange(_caretPos, _caretPos);
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
protected bool removeRangeText(TextRange range) {
|
protected bool removeRangeText(TextRange range) {
|
||||||
if (range.empty)
|
if (range.empty)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1390,6 +1396,9 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
_caretPos.pos = space.firstNonSpaceIndex;
|
_caretPos.pos = space.firstNonSpaceIndex;
|
||||||
ensureCaretVisible();
|
ensureCaretVisible();
|
||||||
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
||||||
|
if (a.id == EditorActions.LineBegin && _caretPos == oldCaretPos) {
|
||||||
|
clearSelection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case DocumentEnd:
|
case DocumentEnd:
|
||||||
|
|
@ -1407,6 +1416,8 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
_caretPos.pos = cast(int)currentLine.length;
|
_caretPos.pos = cast(int)currentLine.length;
|
||||||
ensureCaretVisible();
|
ensureCaretVisible();
|
||||||
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
||||||
|
} else if (a.id == EditorActions.LineEnd) {
|
||||||
|
clearSelection();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case DelPrevWord:
|
case DelPrevWord:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue