1 #ifndef __DALI_TOOLKIT_TEXT_PROCESSOR_H__
2 #define __DALI_TOOLKIT_TEXT_PROCESSOR_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://floralicense.org/license/
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
21 #include <dali-toolkit/public-api/markup-processor/markup-processor.h>
32 namespace TextProcessor
36 * Splits the given text in lines.
38 * @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
39 * not necessarily the case for text in TextView)
41 * @param [in] text The given text.
42 * @param [out] lines The text split in lines.
44 void SplitInLines( const MarkupProcessor::StyledTextArray& text,
45 std::vector<MarkupProcessor::StyledTextArray>& lines );
48 * Splits the given line in words.
50 * @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
51 * not necessarily the case for text in TextView)
53 * @param [in] line The given line.
54 * @param [out] words The line split in words.
56 void SplitInWords( const MarkupProcessor::StyledTextArray& line,
57 std::vector<MarkupProcessor::StyledTextArray>& words );
60 * Whether the text begins with right-to-left (bidirectional) character.
61 * @param [in] text The given text.
62 * @return \e true if the text begins right-to-left character.
64 bool BeginsRightToLeftCharacter( const Text& text );
67 * @copydoc BeginsRightToLeftCharacter( const Text& text )
69 bool BeginsRightToLeftCharacter( const MarkupProcessor::StyledTextArray& text );
72 * Whether the text contains any right-to-left (bidirectional) character.
73 * @param [in] text The given text.
74 * @return \e true if the text contains right-to-left character.
76 bool ContainsRightToLeftCharacter( const Text& text );
79 * @copydoc ContainsRightToLeftCharacter( const Text& text )
81 bool ContainsRightToLeftCharacter( const MarkupProcessor::StyledTextArray& text );
84 * Convert the text as specified by the Unicode Bidirectional Algorithm.
85 * The text is converted only if it is bidirectional.
86 * @param[in] line The line of text to be converted.
87 * @param[out] convertedText The text converted. Text is grouped in chunks which only have one direction.
88 * @param[out] logicalToVisualMap The character position map from the logical input text to the visual output text.
89 * @param[out] visualToLogicalMap The character position map from the visual output text to the logical input text.
91 void ConvertBidirectionalText( const MarkupProcessor::StyledTextArray& line,
92 std::vector<MarkupProcessor::StyledTextArray>& convertedText,
93 std::vector<int>& logicalToVisualMap,
94 std::vector<int>& visualToLogicalMap );
97 * Finds the nearest word in a string to a specified
98 * offset (in Characters).
100 * @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
101 * not necessarily the case for text in TextView)
103 * @param[in] text The text to search through.
104 * @param[in] offset The current offset position to begin search from.
105 * @param[out] start The start position of nearest word
106 * @param[out] end The end position of nearest word
108 void FindNearestWord( const MarkupProcessor::StyledTextArray& text, size_t offset, size_t& start, size_t& end);
110 } // namespace TextProcessor
112 } // namespace Internal
114 } // namespace DaliToolkit
118 #endif // __DALI_TOOLKIT_TEXT_PROCESSOR_H__