TextView - Right to Left implementation.
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-view / text-processor.h
1 #ifndef __DALI_TOOLKIT_TEXT_PROCESSOR_H__
2 #define __DALI_TOOLKIT_TEXT_PROCESSOR_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/markup-processor/markup-processor.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal
31 {
32
33 namespace TextProcessor
34 {
35 // Forward declarations.
36 struct BidirectionalParagraphInfo;
37
38 /**
39  * Splits the given text in paragraphs.
40  *
41  * @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
42  * not necessarily the case for text in TextView)
43  *
44  * @param [in] styledTextArray The given text.
45  * @param [out] paragraphs The text split in paragraphs.
46  * @param [out] styles The styles of each character of each paragraph.
47  */
48 void SplitInParagraphs( const MarkupProcessor::StyledTextArray& styledTextArray,
49                         std::vector<Text>& paragraphs,
50                         std::vector< Vector<TextStyle*> >& styles );
51
52 /**
53  * Finds the position of all word separators (currently white spaces and new paragraph characters '\n') in the given text.
54  *
55  * @param [in] paragraph The given paragraph.
56  * @param [out] positions Positions within the paragraph of all word sepatators.
57  */
58 void SplitInWords( const Text& paragraph,
59                    Vector<std::size_t>& positions );
60
61 /**
62  * Finds the nearest word in a string to a specified
63  * offset (in Characters).
64  *
65  * @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
66  * not necessarily the case for text in TextView)
67  *
68  * @param[in] text The text to search through.
69  * @param[in] offset The current offset position to begin search from.
70  * @param[out] start The start position of nearest word
71  * @param[out] end The end position of nearest word
72  */
73 void FindNearestWord( const MarkupProcessor::StyledTextArray& text, size_t offset, size_t& start, size_t& end);
74
75 } // namespace TextProcessor
76
77 } // namespace Internal
78
79 } // namespace DaliToolkit
80
81 } // namespace Dali
82
83 #endif // __DALI_TOOLKIT_TEXT_PROCESSOR_H__