1 /* 2 * Copyright (c) 2024 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 NATIVE_INPUTMETHOD_TYPES_H 16 #define NATIVE_INPUTMETHOD_TYPES_H 17 #include <string> 18 #include <variant> 19 20 #include "inputmethod_controller_capi.h" 21 struct InputMethod_PrivateCommand { 22 std::string key; 23 std::variant<std::string, bool, int32_t> value; 24 }; 25 26 struct InputMethod_CursorInfo { 27 double left = -1.0; 28 double top = -1.0; 29 double width = -1.0; 30 double height = -1.0; 31 }; 32 33 struct InputMethod_TextAvoidInfo { 34 double positionY; 35 double height; 36 }; 37 struct InputMethod_TextConfig { 38 InputMethod_TextInputType inputType; 39 InputMethod_EnterKeyType enterKeyType; 40 bool previewTextSupported; 41 InputMethod_CursorInfo cursorInfo; 42 InputMethod_TextAvoidInfo avoidInfo; 43 int32_t selectionStart; 44 int32_t selectionEnd; 45 int32_t windowId; 46 }; 47 48 struct InputMethod_MessageHandlerProxy { 49 OH_MessageHandlerProxy_OnTerminatedFunc onTerminatedFunc; 50 OH_MessageHandlerProxy_OnMessageFunc onMessageFunc; 51 }; 52 53 struct InputMethod_TextEditorProxy { 54 OH_TextEditorProxy_GetTextConfigFunc getTextConfigFunc; 55 OH_TextEditorProxy_InsertTextFunc insertTextFunc; 56 OH_TextEditorProxy_DeleteForwardFunc deleteForwardFunc; 57 OH_TextEditorProxy_DeleteBackwardFunc deleteBackwardFunc; 58 OH_TextEditorProxy_SendKeyboardStatusFunc sendKeyboardStatusFunc; 59 OH_TextEditorProxy_SendEnterKeyFunc sendEnterKeyFunc; 60 OH_TextEditorProxy_MoveCursorFunc moveCursorFunc; 61 OH_TextEditorProxy_HandleSetSelectionFunc handleSetSelectionFunc; 62 OH_TextEditorProxy_HandleExtendActionFunc handleExtendActionFunc; 63 OH_TextEditorProxy_GetLeftTextOfCursorFunc getLeftTextOfCursorFunc; 64 OH_TextEditorProxy_GetRightTextOfCursorFunc getRightTextOfCursorFunc; 65 OH_TextEditorProxy_GetTextIndexAtCursorFunc getTextIndexAtCursorFunc; 66 OH_TextEditorProxy_ReceivePrivateCommandFunc receivePrivateCommandFunc; 67 OH_TextEditorProxy_SetPreviewTextFunc setPreviewTextFunc; 68 OH_TextEditorProxy_FinishTextPreviewFunc finishTextPreviewFunc; 69 }; 70 71 struct InputMethod_AttachOptions { 72 bool showKeyboard; 73 InputMethod_RequestKeyboardReason requestKeyboardReason = 74 InputMethod_RequestKeyboardReason::IME_REQUEST_REASON_NONE; 75 }; 76 constexpr int32_t MAX_TEXT_LENGTH = 8 * 1024; 77 #endif // NATIVE_INPUTMETHOD_TYPES_H 78