1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef INTERFACE_KITS_JS_GET_INPUT_METHOD_TEXTCHANGE_LISTENER_H
16 #define INTERFACE_KITS_JS_GET_INPUT_METHOD_TEXTCHANGE_LISTENER_H
17 
18 #include "input_method_controller.h"
19 namespace OHOS {
20 namespace MiscServices {
21 class JsGetInputMethodController;
22 class JsGetInputMethodTextChangedListener : public OnTextChangedListener {
23 public:
24     JsGetInputMethodTextChangedListener() = default;
25     ~JsGetInputMethodTextChangedListener() = default;
26     static sptr<JsGetInputMethodTextChangedListener> GetInstance();
27 
28     void InsertText(const std::u16string &text) override;
29     void DeleteForward(int32_t length) override;
30     void DeleteBackward(int32_t length) override;
SendKeyEventFromInputMethod(const KeyEvent & event)31     void SendKeyEventFromInputMethod(const KeyEvent &event) override {}
32     void SendKeyboardStatus(const KeyboardStatus &status) override;
33     void SendFunctionKey(const FunctionKey &functionKey) override;
SetKeyboardStatus(bool status)34     void SetKeyboardStatus(bool status) override {}
35     void MoveCursor(const Direction direction) override;
HandleSetSelection(int32_t start,int32_t end)36     void HandleSetSelection(int32_t start, int32_t end) override {}
37     void HandleExtendAction(int32_t action) override;
HandleSelect(int32_t keyCode,int32_t cursorMoveSkip)38     void HandleSelect(int32_t keyCode, int32_t cursorMoveSkip) override {}
39     std::u16string GetLeftTextOfCursor(int32_t number) override;
40     std::u16string GetRightTextOfCursor(int32_t number) override;
41     int32_t GetTextIndexAtCursor() override;
42     int32_t ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
43     bool IsFromTs() override;
44 
45 private:
46     static std::mutex listenerMutex_;
47     static sptr<JsGetInputMethodTextChangedListener> inputMethodListener_;
48 };
49 } // namespace MiscServices
50 } // namespace OHOS
51 #endif // INTERFACE_KITS_JS_GET_INPUT_METHOD_TEXTCHANGE_LISTENER_H