mirror of https://github.com/buggins/dlangui.git
Changed accumulation to work for both points and widths
This commit is contained in:
parent
ce39c13e31
commit
83a2f2ef5c
|
@ -455,18 +455,24 @@ struct LineSpan {
|
|||
/// the wrapped text
|
||||
dstring[] wrappedContent;
|
||||
|
||||
int widthAccumulation(int wrapLine)
|
||||
enum WrapPointInfo : bool {
|
||||
Position,
|
||||
Width,
|
||||
}
|
||||
|
||||
int accumulation(int wrapLine, bool wrapPointInfo)
|
||||
{
|
||||
int widthTotal;
|
||||
int total;
|
||||
for (int i; i < wrapLine; i++)
|
||||
{
|
||||
if (i < this.wrapPoints.length - 1)
|
||||
{
|
||||
int curWidth = this.wrapPoints[i].wrapWidth;
|
||||
widthTotal += curWidth;
|
||||
int curVal;
|
||||
curVal = wrapPointInfo ? this.wrapPoints[i].wrapWidth : this.wrapPoints[i].wrapPos;
|
||||
total += curVal;
|
||||
}
|
||||
}
|
||||
return widthTotal;
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1289,7 +1289,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
|||
if (wrapLine > 0)
|
||||
{
|
||||
LineSpan curSpan = getSpan(_caretPos.line);
|
||||
xOffset = curSpan.widthAccumulation(wrapLine);
|
||||
xOffset = curSpan.accumulation(wrapLine, LineSpan.WrapPointInfo.Width);
|
||||
}
|
||||
auto yOffset = -1 * _lineHeight * (wrapsUpTo(_caretPos.line) + wrapLine);
|
||||
caretRc.offset(_clientRect.left - xOffset, _clientRect.top - yOffset);
|
||||
|
|
Loading…
Reference in New Issue