Moved Text Controller & Markup Processor to sub-folders
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / controller / text-controller-text-updater.h
1 #ifndef DALI_TOOLKIT_TEXT_UPDATER_H
2 #define DALI_TOOLKIT_TEXT_UPDATER_H
3
4 /*
5  * Copyright (c) 2022 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 // EXTERNAL INCLUDES
22 #include <string>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/text/controller/text-controller.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Text
32 {
33 /**
34  * @brief Methods that update the text
35  */
36 struct Controller::TextUpdater
37 {
38   /// @copydoc Text::Contoller::SetText
39   /// @param[in] controller The controller
40   static void SetText(Controller& controller, const std::string& text);
41
42   /**
43    * @brief Called by editable UI controls when key events are received.
44    *
45    * @param[in] controller The controller
46    * @param[in] text The text to insert.
47    * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
48    */
49   static void InsertText(Controller& controller, const std::string& text, Controller::InsertType type);
50
51   /// @copydoc Text::EditableControlInterface::PasteText()
52   /// @param[in] controller The controller
53   static void PasteText(Controller& controller, const std::string& stringToPaste);
54
55   /**
56    * @brief Remove a given number of characters
57    *
58    * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
59    * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
60    * style when pre-edit text is removed.
61    *
62    * @param[in] controller The controller
63    * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
64    * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
65    * @param[in] type Whether to update the input style.
66    * @return True if the remove was successful.
67    */
68   static bool RemoveText(Controller& controller, int cursorOffset, int numberOfCharacters, UpdateInputStyleType type);
69
70   /**
71    * @brief Checks if text is selected and if so removes it.
72    * @param[in] controller The controller
73    * @return true if text was removed
74    */
75   static bool RemoveSelectedText(Controller& controller);
76
77   /**
78    * @brief Used to remove the text included the placeholder text.
79    * @param[in] controller The controller
80    */
81   static void ResetText(Controller& controller);
82
83   /**
84    * @brief Update anchor position from given number of inserted characters.
85    *
86    * @param[in] controller The controller
87    * @param[in] numberOfCharacters The number of inserted characters.
88    * @param[in] previousCursorIndex A cursor position before event occurs.
89    */
90   static void InsertTextAnchor(Controller& controller, int numberOfCharacters, CharacterIndex previousCursorIndex);
91
92   /**
93    * @brief Update anchor position from given number of removed characters.
94    *
95    * @param[in] controller The controller
96    * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
97    * @param[in] numberOfCharacters The number of removed characters.
98    * @param[in] previousCursorIndex A cursor position before event occurs.
99    */
100   static void RemoveTextAnchor(Controller& controller, int cursorOffset, int numberOfCharacters, CharacterIndex previousCursorIndex);
101 };
102
103 } // namespace Text
104
105 } // namespace Toolkit
106
107 } // namespace Dali
108
109 #endif // DALI_TOOLKIT_TEXT_UPDATER_H