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 { 33 } 34 void SendKeyboardStatus(const KeyboardStatus &status) override; 35 void SendFunctionKey(const FunctionKey &functionKey) override; SetKeyboardStatus(bool status)36 void SetKeyboardStatus(bool status) override 37 { 38 } 39 void MoveCursor(const Direction direction) override; HandleSetSelection(int32_t start,int32_t end)40 void HandleSetSelection(int32_t start, int32_t end) override 41 { 42 } 43 void HandleExtendAction(int32_t action) override; HandleSelect(int32_t keyCode,int32_t cursorMoveSkip)44 void HandleSelect(int32_t keyCode, int32_t cursorMoveSkip) override 45 { 46 } 47 std::u16string GetLeftTextOfCursor(int32_t number) override; 48 std::u16string GetRightTextOfCursor(int32_t number) override; 49 int32_t GetTextIndexAtCursor() override; 50 int32_t ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override; 51 bool IsFromTs() override; 52 int32_t SetPreviewText(const std::u16string &text, const Range &range) override; 53 void FinishTextPreview() override; 54 55 private: 56 static std::mutex listenerMutex_; 57 static sptr<JsGetInputMethodTextChangedListener> inputMethodListener_; 58 }; 59 } // namespace MiscServices 60 } // namespace OHOS 61 #endif // INTERFACE_KITS_JS_GET_INPUT_METHOD_TEXTCHANGE_LISTENER_H