mirror of https://github.com/buggins/dlangui.git
selection highlight for EditLine
This commit is contained in:
parent
117d4ce33e
commit
72ddb2efb7
|
@ -1286,6 +1286,7 @@ class EditLine : EditWidgetBase {
|
||||||
|
|
||||||
override protected bool handleAction(Action a) {
|
override protected bool handleAction(Action a) {
|
||||||
switch (a.id) {
|
switch (a.id) {
|
||||||
|
/*
|
||||||
case EditorActions.DelPrevChar:
|
case EditorActions.DelPrevChar:
|
||||||
if (_caretPos.pos > 0) {
|
if (_caretPos.pos > 0) {
|
||||||
TextRange range = TextRange(_caretPos, _caretPos);
|
TextRange range = TextRange(_caretPos, _caretPos);
|
||||||
|
@ -1302,6 +1303,7 @@ class EditLine : EditWidgetBase {
|
||||||
_content.performOperation(op);
|
_content.performOperation(op);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
*/
|
||||||
case EditorActions.Up:
|
case EditorActions.Up:
|
||||||
break;
|
break;
|
||||||
case EditorActions.Down:
|
case EditorActions.Down:
|
||||||
|
@ -1345,6 +1347,24 @@ class EditLine : EditWidgetBase {
|
||||||
applyPadding(_clientRc);
|
applyPadding(_clientRc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// override to custom highlight of line background
|
||||||
|
protected void drawLineBackground(DrawBuf buf, Rect lineRect, Rect visibleRect) {
|
||||||
|
if (!_selectionRange.empty) {
|
||||||
|
// line inside selection
|
||||||
|
Rect startrc = textPosToClient(_selectionRange.start);
|
||||||
|
Rect endrc = textPosToClient(_selectionRange.end);
|
||||||
|
int startx = startrc.left + _clientRc.left;
|
||||||
|
int endx = endrc.left + _clientRc.left;
|
||||||
|
Rect rc = lineRect;
|
||||||
|
rc.left = startx;
|
||||||
|
rc.right = endx;
|
||||||
|
if (!rc.empty) {
|
||||||
|
// draw selection rect for line
|
||||||
|
buf.fillRect(rc, 0xB060A0FF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// draw content
|
/// draw content
|
||||||
override void onDraw(DrawBuf buf) {
|
override void onDraw(DrawBuf buf) {
|
||||||
if (visibility != Visibility.Visible)
|
if (visibility != Visibility.Visible)
|
||||||
|
@ -1358,6 +1378,13 @@ class EditLine : EditWidgetBase {
|
||||||
dstring txt = text;
|
dstring txt = text;
|
||||||
Point sz = font.textSize(txt);
|
Point sz = font.textSize(txt);
|
||||||
//applyAlign(rc, sz);
|
//applyAlign(rc, sz);
|
||||||
|
Rect lineRect = _clientRc;
|
||||||
|
lineRect.left = _clientRc.left - _scrollPos.x;
|
||||||
|
lineRect.right = lineRect.left + calcLineWidth(txt);
|
||||||
|
Rect visibleRect = lineRect;
|
||||||
|
visibleRect.left = _clientRc.left;
|
||||||
|
visibleRect.right = _clientRc.right;
|
||||||
|
drawLineBackground(buf, lineRect, visibleRect);
|
||||||
font.drawText(buf, rc.left - _scrollPos.x, rc.top + sz.y / 10, txt, textColor, tabSize);
|
font.drawText(buf, rc.left - _scrollPos.x, rc.top + sz.y / 10, txt, textColor, tabSize);
|
||||||
if (focused) {
|
if (focused) {
|
||||||
// draw caret
|
// draw caret
|
||||||
|
|
Loading…
Reference in New Issue