X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=base%2Fdali-toolkit%2Finternal%2Fcontrols%2Ftext-view%2Ftext-processor.cpp;h=1f32dd9df7f1ba68deed1d4a7921c33addc0e886;hp=8e212a8dd2d71923903d7387e2d688ec95ec1a95;hb=e8918378f56190a664319b2bd918f3223e70a577;hpb=0f217b9896d284c667e1251ee617e4ddadd4c9e3 diff --git a/base/dali-toolkit/internal/controls/text-view/text-processor.cpp b/base/dali-toolkit/internal/controls/text-view/text-processor.cpp index 8e212a8..1f32dd9 100644 --- a/base/dali-toolkit/internal/controls/text-view/text-processor.cpp +++ b/base/dali-toolkit/internal/controls/text-view/text-processor.cpp @@ -33,10 +33,10 @@ namespace Internal namespace TextProcessor { -void SplitInLines( const MarkupProcessor::StyledTextArray& text, - std::vector& lines ) +void SplitInParagraphs( const MarkupProcessor::StyledTextArray& text, + std::vector& paragraphs ) { - MarkupProcessor::StyledTextArray line; + MarkupProcessor::StyledTextArray paragraph; for( MarkupProcessor::StyledTextArray::const_iterator it = text.begin(), endIt = text.end(); it != endIt; ++it ) { const MarkupProcessor::StyledText& styledText( *it ); @@ -49,30 +49,30 @@ void SplitInLines( const MarkupProcessor::StyledTextArray& text, { Text newText( character ); MarkupProcessor::StyledText newStyledText( newText, styledText.mStyle ); - line.push_back( newStyledText ); + paragraph.push_back( newStyledText ); - lines.push_back( line ); - line.clear(); + paragraphs.push_back( paragraph ); + paragraph.clear(); } else { Text newText( character ); MarkupProcessor::StyledText newStyledText( newText, styledText.mStyle ); - line.push_back( newStyledText ); + paragraph.push_back( newStyledText ); } } } - // This line could be empty if the last character of the previous line is a 'new line' character + // This paragraph could be empty if the last character of the previous paragraph is a 'new paragraph' character // and is the last of the text. - lines.push_back( line ); + paragraphs.push_back( paragraph ); } -void SplitInWords( const MarkupProcessor::StyledTextArray& line, +void SplitInWords( const MarkupProcessor::StyledTextArray& paragraph, std::vector& words ) { MarkupProcessor::StyledTextArray word; - for( MarkupProcessor::StyledTextArray::const_iterator it = line.begin(), endIt = line.end(); it != endIt; ++it ) + for( MarkupProcessor::StyledTextArray::const_iterator it = paragraph.begin(), endIt = paragraph.end(); it != endIt; ++it ) { const MarkupProcessor::StyledText& styledText( *it ); const Dali::Character character = styledText.mText[0u]; @@ -263,6 +263,14 @@ void ConvertBidirectionalText( const MarkupProcessor::StyledTextArray& line, } } +/** + * Wheather the character of the text pointed by the given offset is a white space. + * + * @param[in] text The text. + * @param[in] offset Offset pointing the character. + * + * @return \e true if the character pointed by the offset is a white space. + */ bool IsWhiteSpace( const MarkupProcessor::StyledTextArray& text, size_t offset ) { DALI_ASSERT_DEBUG( offset < text.size() ); @@ -319,6 +327,15 @@ void FindNearestWord( const MarkupProcessor::StyledTextArray& text, size_t offse j++; } + // If both markers at same position and is whitespace then word is a whitespace word + if ( i == j ) + { + while(j < size && IsWhiteSpace(text, j)) + { + j++; + } + } + start = i; end = j; }