+CharacterIndex Controller::Impl::GetPrimaryCursorPosition() const
+{
+ if( nullptr == mEventData )
+ {
+ return 0;
+ }
+ return mEventData->mPrimaryCursorPosition;
+}
+
+bool Controller::Impl::SetPrimaryCursorPosition( CharacterIndex index )
+{
+ if( nullptr == mEventData )
+ {
+ // Nothing to do if there is no text.
+ return false;
+ }
+
+ if( mEventData->mPrimaryCursorPosition == index )
+ {
+ // Nothing for same cursor position.
+ return false;
+ }
+
+ uint32_t length = static_cast<uint32_t>(mModel->mLogicalModel->mText.Count());
+ mEventData->mPrimaryCursorPosition = std::min(index, length);
+ ChangeState( EventData::EDITING );
+ mEventData->mLeftSelectionPosition = mEventData->mRightSelectionPosition = mEventData->mPrimaryCursorPosition;
+ mEventData->mUpdateCursorPosition = true;
+ ScrollTextToMatchCursor();
+ return true;
+}
+