From 8a62263409f5d222ac0d0ccf7bf0e7e0261224a8 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Sat, 5 Nov 2016 20:32:17 +1100 Subject: Add options to choose between the locations of a position when there are multiple locations for one position. The main current use is to find the location at the end of a line or display line when the commonly used location is at the start of the next line. --- src/PositionCache.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/PositionCache.cxx') diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 997a4bfae..45731601a 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -217,7 +217,7 @@ int LineLayout::FindPositionFromX(XYPOSITION x, Range range, bool charPosition) return range.end; } -Point LineLayout::PointFromPosition(int posInLine, int lineHeight) const { +Point LineLayout::PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const { Point pt; // In case of very long line put x at arbitrary large position if (posInLine > maxLineLength) { @@ -232,6 +232,12 @@ Point LineLayout::PointFromPosition(int posInLine, int lineHeight) const { pt.x = positions[posInLine] - positions[rangeSubLine.start]; if (rangeSubLine.start != 0) // Wrapped lines may be indented pt.x += wrapIndent; + if (pe & peSubLineEnd) // Return end of first subline not start of next + break; + } else if ((pe & peLineEnd) && (subLine == (lines-1))) { + pt.x = positions[numCharsInLine] - positions[rangeSubLine.start]; + if (rangeSubLine.start != 0) // Wrapped lines may be indented + pt.x += wrapIndent; } } else { break; -- cgit v1.2.3