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_TextEditorProxy {
49     OH_TextEditorProxy_GetTextConfigFunc getTextConfigFunc;
50     OH_TextEditorProxy_InsertTextFunc insertTextFunc;
51     OH_TextEditorProxy_DeleteForwardFunc deleteForwardFunc;
52     OH_TextEditorProxy_DeleteBackwardFunc deleteBackwardFunc;
53     OH_TextEditorProxy_SendKeyboardStatusFunc sendKeyboardStatusFunc;
54     OH_TextEditorProxy_SendEnterKeyFunc sendEnterKeyFunc;
55     OH_TextEditorProxy_MoveCursorFunc moveCursorFunc;
56     OH_TextEditorProxy_HandleSetSelectionFunc handleSetSelectionFunc;
57     OH_TextEditorProxy_HandleExtendActionFunc handleExtendActionFunc;
58     OH_TextEditorProxy_GetLeftTextOfCursorFunc getLeftTextOfCursorFunc;
59     OH_TextEditorProxy_GetRightTextOfCursorFunc getRightTextOfCursorFunc;
60     OH_TextEditorProxy_GetTextIndexAtCursorFunc getTextIndexAtCursorFunc;
61     OH_TextEditorProxy_ReceivePrivateCommandFunc receivePrivateCommandFunc;
62     OH_TextEditorProxy_SetPreviewTextFunc setPreviewTextFunc;
63     OH_TextEditorProxy_FinishTextPreviewFunc finishTextPreviewFunc;
64 };
65 
66 struct InputMethod_AttachOptions {
67     bool showKeyboard;
68 };
69 constexpr int32_t MAX_TEXT_LENGTH = 8 * 1024;
70 #endif // NATIVE_INPUTMETHOD_TYPES_H
71