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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali-toolkit/public-api/markup-processor/markup-processor.h>
33 namespace TextProcessor
37 * Splits the given text in lines.
39 * @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
40 * not necessarily the case for text in TextView)
42 * @param [in] text The given text.
43 * @param [out] lines The text split in lines.
45 void SplitInLines( const MarkupProcessor::StyledTextArray& text,
46 std::vector<MarkupProcessor::StyledTextArray>& lines );
49 * Splits the given line in words.
51 * @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
52 * not necessarily the case for text in TextView)
54 * @param [in] line The given line.
55 * @param [out] words The line split in words.
57 void SplitInWords( const MarkupProcessor::StyledTextArray& line,
58 std::vector<MarkupProcessor::StyledTextArray>& words );
61 * Whether the text begins with right-to-left (bidirectional) character.
62 * @param [in] text The given text.
63 * @return \e true if the text begins right-to-left character.
65 bool BeginsRightToLeftCharacter( const Text& text );
68 * @copydoc BeginsRightToLeftCharacter( const Text& text )
70 bool BeginsRightToLeftCharacter( const MarkupProcessor::StyledTextArray& text );
73 * Whether the text contains any right-to-left (bidirectional) character.
74 * @param [in] text The given text.
75 * @return \e true if the text contains right-to-left character.
77 bool ContainsRightToLeftCharacter( const Text& text );
80 * @copydoc ContainsRightToLeftCharacter( const Text& text )
82 bool ContainsRightToLeftCharacter( const MarkupProcessor::StyledTextArray& text );
85 * Convert the text as specified by the Unicode Bidirectional Algorithm.
86 * The text is converted only if it is bidirectional.
87 * @param[in] line The line of text to be converted.
88 * @param[out] convertedText The text converted. Text is grouped in chunks which only have one direction.
89 * @param[out] logicalToVisualMap The character position map from the logical input text to the visual output text.
90 * @param[out] visualToLogicalMap The character position map from the visual output text to the logical input text.
92 void ConvertBidirectionalText( const MarkupProcessor::StyledTextArray& line,
93 std::vector<MarkupProcessor::StyledTextArray>& convertedText,
94 std::vector<int>& logicalToVisualMap,
95 std::vector<int>& visualToLogicalMap );
98 * Finds the nearest word in a string to a specified
99 * offset (in Characters).
101 * @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
102 * not necessarily the case for text in TextView)
104 * @param[in] text The text to search through.
105 * @param[in] offset The current offset position to begin search from.
106 * @param[out] start The start position of nearest word
107 * @param[out] end The end position of nearest word
109 void FindNearestWord( const MarkupProcessor::StyledTextArray& text, size_t offset, size_t& start, size_t& end);
111 } // namespace TextProcessor
113 } // namespace Internal
115 } // namespace DaliToolkit
119 #endif // __DALI_TOOLKIT_TEXT_PROCESSOR_H__