mirror of https://github.com/buggins/dlangui.git
Basic implementation for highlighting text selection in word wrap
This commit is contained in:
parent
422517aff4
commit
71931c8e43
|
@ -3336,7 +3336,23 @@ class EditBox : EditWidgetBase {
|
||||||
Rect rc = lineRect;
|
Rect rc = lineRect;
|
||||||
rc.left = startx;
|
rc.left = startx;
|
||||||
rc.right = endx;
|
rc.right = endx;
|
||||||
if (!rc.empty) {
|
if (!rc.empty && _wordWrap)
|
||||||
|
{
|
||||||
|
auto limitNumber = (int num, int limit) => num > limit ? limit : num;
|
||||||
|
LineSpan curSpan = getSpan(lineIndex);
|
||||||
|
int yOffset = _lineHeight * (wrapsUpTo(lineIndex));
|
||||||
|
rc.offset(0, yOffset);
|
||||||
|
Rect[] wrappedSelection;
|
||||||
|
wrappedSelection.length = curSpan.len;
|
||||||
|
foreach (int i, wrapLineRect; wrappedSelection)
|
||||||
|
{
|
||||||
|
wrapLineRect = rc;
|
||||||
|
wrapLineRect.offset(-1 * curSpan.accumulation(i, LineSpan.WrapPointInfo.Width), i * _lineHeight);
|
||||||
|
wrapLineRect.right = limitNumber(wrapLineRect.right,(rc.left + curSpan.wrapPoints[i].wrapWidth));
|
||||||
|
buf.fillRect(wrapLineRect, focused ? _selectionColorFocused : _selectionColorNormal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!rc.empty) {
|
||||||
// draw selection rect for line
|
// draw selection rect for line
|
||||||
buf.fillRect(rc, focused ? _selectionColorFocused : _selectionColorNormal);
|
buf.fillRect(rc, focused ? _selectionColorFocused : _selectionColorNormal);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue