mirror of https://github.com/buggins/dlangui.git
editors refactoring
This commit is contained in:
parent
28774a9ba6
commit
a5aaa1a9cc
|
@ -435,7 +435,20 @@ class EditWidgetBase : WidgetGroup, EditableContentListener {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract override bool onContentChange(EditableContent content, EditOperation operation, ref TextRange rangeBefore, ref TextRange rangeAfter);
|
protected void updateMaxLineWidth() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override bool onContentChange(EditableContent content, EditOperation operation, ref TextRange rangeBefore, ref TextRange rangeAfter) {
|
||||||
|
updateMaxLineWidth();
|
||||||
|
measureVisibleText();
|
||||||
|
_caretPos = rangeAfter.end;
|
||||||
|
_selectionRange.start = _caretPos;
|
||||||
|
_selectionRange.end = _caretPos;
|
||||||
|
ensureCaretVisible();
|
||||||
|
invalidate();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// get widget text
|
/// get widget text
|
||||||
override @property dstring text() { return _content.text; }
|
override @property dstring text() { return _content.text; }
|
||||||
|
@ -621,13 +634,6 @@ class EditLine : EditWidgetBase {
|
||||||
text = initialContent;
|
text = initialContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
override bool onContentChange(EditableContent content, EditOperation operation, ref TextRange rangeBefore, ref TextRange rangeAfter) {
|
|
||||||
measureVisibleText();
|
|
||||||
_caretPos = rangeAfter.end;
|
|
||||||
invalidate();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected dstring _measuredText;
|
protected dstring _measuredText;
|
||||||
protected int[] _measuredTextWidths;
|
protected int[] _measuredTextWidths;
|
||||||
protected Point _measuredTextSize;
|
protected Point _measuredTextSize;
|
||||||
|
@ -834,7 +840,7 @@ class EditBox : EditWidgetBase, OnScrollHandler {
|
||||||
protected int[][] _visibleLinesMeasurement; // char positions for visible lines
|
protected int[][] _visibleLinesMeasurement; // char positions for visible lines
|
||||||
protected int[] _visibleLinesWidths; // width (in pixels) of visible lines
|
protected int[] _visibleLinesWidths; // width (in pixels) of visible lines
|
||||||
|
|
||||||
protected void updateMaxLineWidth() {
|
override protected void updateMaxLineWidth() {
|
||||||
// find max line width. TODO: optimize!!!
|
// find max line width. TODO: optimize!!!
|
||||||
int maxw;
|
int maxw;
|
||||||
int[] buf;
|
int[] buf;
|
||||||
|
@ -937,17 +943,6 @@ class EditBox : EditWidgetBase, OnScrollHandler {
|
||||||
updateScrollbars();
|
updateScrollbars();
|
||||||
}
|
}
|
||||||
|
|
||||||
override bool onContentChange(EditableContent content, EditOperation operation, ref TextRange rangeBefore, ref TextRange rangeAfter) {
|
|
||||||
updateMaxLineWidth();
|
|
||||||
measureVisibleText();
|
|
||||||
_caretPos = rangeAfter.end;
|
|
||||||
_selectionRange.start = _caretPos;
|
|
||||||
_selectionRange.end = _caretPos;
|
|
||||||
ensureCaretVisible();
|
|
||||||
invalidate();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
override protected Rect textPosToClient(TextPosition p) {
|
override protected Rect textPosToClient(TextPosition p) {
|
||||||
Rect res;
|
Rect res;
|
||||||
int lineIndex = p.line - _firstVisibleLine;
|
int lineIndex = p.line - _firstVisibleLine;
|
||||||
|
|
Loading…
Reference in New Issue