1 #ifndef DALI_TOOLKIT_TEXT_UPDATER_H
2 #define DALI_TOOLKIT_TEXT_UPDATER_H
5 * Copyright (c) 2022 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.
25 #include <dali-toolkit/internal/text/controller/text-controller.h>
34 * @brief Methods that update the text
36 struct Controller::TextUpdater
38 /// @copydoc Text::Contoller::SetText
39 /// @param[in] controller The controller
40 static void SetText(Controller& controller, const std::string& text);
43 * @brief Called by editable UI controls when key events are received.
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.
49 static void InsertText(Controller& controller, const std::string& text, Controller::InsertType type);
51 /// @copydoc Text::EditableControlInterface::PasteText()
52 /// @param[in] controller The controller
53 static void PasteText(Controller& controller, const std::string& stringToPaste);
56 * @brief Remove a given number of characters
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.
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.
68 static bool RemoveText(Controller& controller, int cursorOffset, int numberOfCharacters, UpdateInputStyleType type);
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
75 static bool RemoveSelectedText(Controller& controller);
78 * @brief Used to remove the text included the placeholder text.
79 * @param[in] controller The controller
81 static void ResetText(Controller& controller);
84 * @brief Update anchor position from given number of inserted characters.
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.
90 static void InsertTextAnchor(Controller& controller, int numberOfCharacters, CharacterIndex previousCursorIndex);
93 * @brief Update anchor position from given number of removed characters.
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.
100 static void RemoveTextAnchor(Controller& controller, int cursorOffset, int numberOfCharacters, CharacterIndex previousCursorIndex);
105 } // namespace Toolkit
109 #endif // DALI_TOOLKIT_TEXT_UPDATER_H