Changed accumulation to work for both points and widths

This commit is contained in:
James Johnson 2018-01-11 11:56:00 -05:00
parent ce39c13e31
commit 83a2f2ef5c
2 changed files with 12 additions and 6 deletions

View File

@ -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;
}
}

View File

@ -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);