+struct FindWordData
+{
+ FindWordData(const Dali::Toolkit::Text::Character* const textBuffer,
+ Dali::Toolkit::Text::Length totalNumberOfCharacters,
+ Dali::Toolkit::Text::CharacterIndex hitCharacter,
+ bool isWhiteSpace,
+ bool isNewParagraph)
+ : textBuffer(textBuffer),
+ totalNumberOfCharacters(totalNumberOfCharacters),
+ hitCharacter(hitCharacter),
+ foundIndex(0),
+ isWhiteSpace(isWhiteSpace),
+ isNewParagraph(isNewParagraph)
+ {
+ }
+
+ ~FindWordData()
+ {
+ }
+
+ const Dali::Toolkit::Text::Character* const textBuffer;
+ Dali::Toolkit::Text::Length totalNumberOfCharacters;
+ Dali::Toolkit::Text::CharacterIndex hitCharacter;
+ Dali::Toolkit::Text::CharacterIndex foundIndex;
+ bool isWhiteSpace : 1u;
+ bool isNewParagraph : 1u;
+};
+
+bool IsWhiteSpaceOrNewParagraph(Dali::Toolkit::Text::Character character,
+ bool isHitWhiteSpace,
+ bool isHitWhiteSpaceOrNewParagraph)
+{
+ bool isWhiteSpaceOrNewParagraph = false;
+ if(isHitWhiteSpaceOrNewParagraph)
+ {
+ if(isHitWhiteSpace)
+ {
+ // Whether the current character is a white space. Note a new paragraph character is a white space as well but here is not wanted.
+ isWhiteSpaceOrNewParagraph = Dali::TextAbstraction::IsWhiteSpace(character) && !Dali::TextAbstraction::IsNewParagraph(character);
+ }
+ else
+ {
+ // Whether the current character is a new paragraph character.
+ isWhiteSpaceOrNewParagraph = Dali::TextAbstraction::IsNewParagraph(character);
+ }
+ }
+ else
+ {
+ // Whether the current character is a white space or a new paragraph character (note the new paragraph character is a white space as well).
+ isWhiteSpaceOrNewParagraph = Dali::TextAbstraction::IsWhiteSpace(character);
+ }
+
+ return isWhiteSpaceOrNewParagraph;
+}
+
+void FindStartOfWord(FindWordData& data)
+{
+ const bool isHitWhiteSpaceOrNewParagraph = data.isWhiteSpace || data.isNewParagraph;
+
+ for(data.foundIndex = data.hitCharacter; data.foundIndex > 0; --data.foundIndex)
+ {
+ const Dali::Toolkit::Text::Character character = *(data.textBuffer + data.foundIndex - 1u);
+
+ const bool isWhiteSpaceOrNewParagraph = IsWhiteSpaceOrNewParagraph(character,
+ data.isWhiteSpace,
+ isHitWhiteSpaceOrNewParagraph);
+
+ if(isHitWhiteSpaceOrNewParagraph != isWhiteSpaceOrNewParagraph)
+ {
+ break;
+ }
+ }
+}
+
+void FindEndOfWord(FindWordData& data)
+{
+ const bool isHitWhiteSpaceOrNewParagraph = data.isWhiteSpace || data.isNewParagraph;
+
+ for(data.foundIndex = data.hitCharacter + 1u; data.foundIndex < data.totalNumberOfCharacters; ++data.foundIndex)
+ {
+ const Dali::Toolkit::Text::Character character = *(data.textBuffer + data.foundIndex);
+
+ const bool isWhiteSpaceOrNewParagraph = IsWhiteSpaceOrNewParagraph(character,
+ data.isWhiteSpace,
+ isHitWhiteSpaceOrNewParagraph);
+
+ if(isHitWhiteSpaceOrNewParagraph != isWhiteSpaceOrNewParagraph)
+ {
+ break;
+ }
+ }
+}
+