void GetCursorPosition( GetCursorPositionParameters& parameters,
CursorInfo& cursorInfo )
{
+ const LineRun* const modelLines = parameters.visualModel->mLines.Begin();
+ if( NULL == modelLines )
+ {
+ // Nothing to do.
+ return;
+ }
+
// Whether the logical cursor position is at the end of the whole text.
const bool isLastPosition = parameters.logicalModel->mText.Count() == parameters.logical;
// Whether the cursor is in the last position and the last position is a new paragraph character.
const bool isLastNewParagraph = parameters.isMultiline && isLastPosition && TextAbstraction::IsNewParagraph( *( parameters.logicalModel->mText.Begin() + characterOfLine ) );
- const LineRun* const modelLines = parameters.visualModel->mLines.Begin();
-
const LineIndex lineIndex = parameters.visualModel->GetLineOfCharacter( characterOfLine );
const LineRun& line = *( modelLines + lineIndex );
cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
// Set the primary cursor's position.
- cursorInfo.primaryPosition.x = 0.f;
+ cursorInfo.primaryPosition.x = ( LTR == line.direction ) ? newLine.alignmentOffset : parameters.visualModel->mControlSize.width - newLine.alignmentOffset;
cursorInfo.primaryPosition.y = cursorInfo.lineOffset;
-
- // Transform the cursor info from line's coords to text's coords.
- cursorInfo.primaryPosition.x += ( LTR == line.direction ) ? 0.f : parameters.visualModel->mControlSize.width;
}
else
{
// Set the primary cursor's height.
cursorInfo.primaryCursorHeight = cursorInfo.isSecondaryCursor ? 0.5f * glyphMetrics.fontHeight : glyphMetrics.fontHeight;
-
cursorInfo.glyphOffset = line.ascender - glyphMetrics.ascender;
// Set the primary cursor's position.
cursorInfo.primaryPosition.x = -glyphMetrics.xBearing + primaryPosition.x + glyphAdvance;