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 OHOS_INPUTMETHOD_INPUTMETHOD_PROXY_CAPI_H
16#define OHOS_INPUTMETHOD_INPUTMETHOD_PROXY_CAPI_H
17/**
18 * @addtogroup InputMethod
19 * @{
20 *
21 * @brief InputMethod provides functions to use input methods and develop input methods.
22 *
23 * @since 12
24 */
25
26/**
27 * @file inputmethod_inputmethod_proxy_capi.h
28 *
29 * @brief Provides functions to use input methods.
30 *
31 * @library libohinputmethod.so
32 * @kit IMEKit
33 * @syscap SystemCapability.MiscServices.InputMethodFramework
34 * @since 12
35 * @version 1.0
36 */
37#include <stddef.h>
38
39#include "inputmethod_types_capi.h"
40#include "inputmethod_cursor_info_capi.h"
41#include "inputmethod_private_command_capi.h"
42#ifdef __cplusplus
43extern "C"{
44#endif /* __cplusplus */
45/**
46 * @brief Define the InputMethod_InputMethodProxy structure type.
47 *
48 * Provides methods for controlling input method.
49 *
50 * @since 12
51 */
52typedef struct InputMethod_InputMethodProxy InputMethod_InputMethodProxy;
53
54/**
55 * @brief Show keyboard.
56 *
57 * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance.
58 *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
59 * @return Returns a specific error code.
60 *     {@link IME_ERR_OK} - success.
61 *     {@link IME_ERR_IMCLIENT} - input method client error.
62 *     {@link IME_ERR_IMMS} - input method manager service error.
63 *     {@link IME_ERR_DETACHED} - input method client is detached.
64 *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
65 * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
66 * @since 12
67 */
68InputMethod_ErrorCode OH_InputMethodProxy_ShowKeyboard(InputMethod_InputMethodProxy *inputMethodProxy);
69
70/**
71 * @brief Hide keyboard.
72 *
73 * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance.
74 *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
75 * @return Returns a specific error code.
76 *     {@link IME_ERR_OK} - success.
77 *     {@link IME_ERR_IMCLIENT} - input method client error.
78 *     {@link IME_ERR_IMMS} - input method manager service error.
79 *     {@link IME_ERR_DETACHED} - input method client is detached.
80 *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
81 * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
82 * @since 12
83 */
84InputMethod_ErrorCode OH_InputMethodProxy_HideKeyboard(InputMethod_InputMethodProxy *inputMethodProxy);
85
86/**
87 * @brief Notify selection change.
88 *
89 * Notify selection change when text or cursor position or selected text changed.
90 *
91 * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance.
92 *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
93 * @param text The whole input text.
94 * @param length The length of text. Max length is 8K.
95 * @param start The start position of selected text.
96 * @param end The end position of selected text.
97 * @return Returns a specific error code.
98 *     {@link IME_ERR_OK} - success.
99 *     {@link IME_ERR_PARAMCHECK} - parameter check failed.
100 *     {@link IME_ERR_IMCLIENT} - input method client error.
101 *     {@link IME_ERR_IMMS} - input method manager service error.
102 *     {@link IME_ERR_DETACHED} - input method client is detached.
103 *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
104 * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
105 * @since 12
106 */
107InputMethod_ErrorCode OH_InputMethodProxy_NotifySelectionChange(
108    InputMethod_InputMethodProxy *inputMethodProxy, char16_t text[], size_t length, int start, int end);
109
110/**
111 * @brief Notify text editor configuration change.
112 *
113 * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance.
114 *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
115 * @param enterKey The enter key type.
116 * @param textType The text input type.
117 * @return Returns a specific error code.
118 *     {@link IME_ERR_OK} - success.
119 *     {@link IME_ERR_PARAMCHECK} - parameter check failed.
120 *     {@link IME_ERR_IMCLIENT} - input method client error.
121 *     {@link IME_ERR_IMMS} - input method manager service error.
122 *     {@link IME_ERR_DETACHED} - input method client is detached.
123 *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
124 * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
125 * @since 12
126 */
127InputMethod_ErrorCode OH_InputMethodProxy_NotifyConfigurationChange(InputMethod_InputMethodProxy *inputMethodProxy,
128    InputMethod_EnterKeyType enterKey, InputMethod_TextInputType textType);
129
130/**
131 * @brief Notify cursor update.
132 *
133 * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance.
134 *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
135 * @param cursorInfo Represents a pointer to an {@link InputMethod_CursorInfo} instance.
136 *     The cursor information.
137 * @return Returns a specific error code.
138 *     {@link IME_ERR_OK} - success.
139 *     {@link IME_ERR_PARAMCHECK} - parameter check failed.
140 *     {@link IME_ERR_IMCLIENT} - input method client error.
141 *     {@link IME_ERR_IMMS} - input method manager service error.
142 *     {@link IME_ERR_DETACHED} - input method client is detached.
143 *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
144 * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
145 * @since 12
146 */
147InputMethod_ErrorCode OH_InputMethodProxy_NotifyCursorUpdate(
148    InputMethod_InputMethodProxy *inputMethodProxy, InputMethod_CursorInfo *cursorInfo);
149
150/**
151 * @brief Send private command.
152 *
153 * @param inputMethodProxy Represents a pointer to an {@link OH_InputMethod_InputMethodProxy} instance.
154 *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
155 * @param privateCommand The private commands, which is defined in {@link InputMethod_PrivateCommand}. Max size 32KB.
156 * @param size The size of privateCommand. Max is 5.
157 * @return Returns a specific error code.
158 *     {@link IME_ERR_OK} - success.
159 *     {@link IME_ERR_PARAMCHECK} - parameter check failed.
160 *     {@link IME_ERR_IMCLIENT} - input method client error.
161 *     {@link IME_ERR_IMMS} - input method manager service error.
162 *     {@link IME_ERR_DETACHED} - input method client is detached.
163 *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
164 * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
165 * @since 12
166 */
167InputMethod_ErrorCode OH_InputMethodProxy_SendPrivateCommand(
168    InputMethod_InputMethodProxy *inputMethodProxy, InputMethod_PrivateCommand *privateCommand[], size_t size);
169#ifdef __cplusplus
170}
171#endif /* __cplusplus */
172/** @} */
173#endif // INPUTMETHOD_INPUTMETHOD_PROXY_CAP_H