diff --git a/Cargo.lock b/Cargo.lock index 2723171..3bb6be1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,6 +35,13 @@ dependencies = [ "document-features", ] +[[package]] +name = "ohos-ime-sys" +version = "0.1.0" +dependencies = [ + "document-features", +] + [[package]] name = "ohos-sys" version = "0.3.1" @@ -43,4 +50,5 @@ dependencies = [ "hitrace-sys", "ohos-deviceinfo-sys", "ohos-drawing-sys", + "ohos-ime-sys", ] diff --git a/Cargo.toml b/Cargo.toml index 591e35b..cf788dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ document-features = { version = "0.2", optional = true } ohos-drawing-sys = { path = "components/drawing", version = "0.1", optional = true} ohos-deviceinfo-sys = { version = "0.1", optional = true, path = "components/deviceinfo"} hitrace-sys = { version = "0.1.2", optional = true, path = "components/hitrace"} +ohos-ime-sys = { version = "0.1", optional = true, path = "components/inputmethod"} [features] default = ["api-10"] @@ -29,6 +30,8 @@ drawing = ["dep:ohos-drawing-sys"] hilog = [] ## Enables bindings to `hitrace` hitrace = ["dep:hitrace-sys"] +## Enables bindings to `inputmethod` from the IME-Kit. Empty if API-level < 12. +inputmethod = ["dep:ohos-ime-sys"] ## Enables bindings to `napi` napi = [] ## Enables bindings to `native_buffer` @@ -46,6 +49,8 @@ all-components = [ "deviceinfo", "drawing", "hilog", + "hitrace", + "inputmethod", "napi", "native_buffer", "native_image", @@ -71,7 +76,8 @@ api-11 = ["api-10", api-12 = ["api-11", "ohos-deviceinfo-sys?/api-12", "ohos-drawing-sys?/api-12", - "hitrace-sys?/api-12" + "hitrace-sys?/api-12", + "ohos-ime-sys?/api-12" ] ## Document available features when building the documentation document-features = ["dep:document-features"] diff --git a/components/inputmethod/Cargo.toml b/components/inputmethod/Cargo.toml new file mode 100644 index 0000000..ed6b4c3 --- /dev/null +++ b/components/inputmethod/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "ohos-ime-sys" +version = "0.1.0" +edition = "2021" +description = "Bindings to the `inputmethod` API of OpenHarmony" +license = "Apache-2.0" +repository = "https://github.com/openharmony-rs/ohos-sys" +keywords = ["OpenHarmony", "HarmonyOS", "ffi", "ime", "inputmethod"] +exclude = ["src/**/*_nopublish.rs"] +readme = "README.md" + +[dependencies] +document-features = { version = "0.2", optional = true } + +[features] +default = [] + +#! ### OpenHarmony API level +#! The `inputmethod` API was added in API-level 12. +#! Defaults to no bindings at all, to maintain feature composability in `ohos-sys`. +#! Optionally enable one of the `api-*` features to get access to bindings for newer +#! OpenHarmony versions. + +## **EXPERIMENTAL**: Enables bindings for OpenHarmony API-level 12 (beta-1). +## Will stabilize once the final version has been released. +api-12 = [] +## Document available features when building the documentation +document-features = ["dep:document-features"] + +[package.metadata.docs.rs] +features = ["document-features"] +targets = ["aarch64-unknown-linux-ohos", "armv7-unknown-linux-ohos", "x86_64-unknown-linux-ohos"] +all-features = true diff --git a/components/inputmethod/README.md b/components/inputmethod/README.md new file mode 100644 index 0000000..44929f5 --- /dev/null +++ b/components/inputmethod/README.md @@ -0,0 +1,11 @@ +# OpenHarmony Inputmethod bindings + +Raw rust-bindings for the native `inputmethod` from the IME-Kit on OpenHarmony. hiTraceMeter provides APIs for system performance tracing. +Available since OpenHarmony 5.0 (API-level 12). +Please view the [HarmonyOS reference] for usage details (Link to the OpenHarmony documentation not available yet). + +[HarmonyOS reference]: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/_input_method-V5 + +## License + +Licensed under the Apache-2.0 license, matching the license of OpenHarmony. \ No newline at end of file diff --git a/components/inputmethod/src/attach_options.rs b/components/inputmethod/src/attach_options.rs new file mode 100644 index 0000000..1e65301 --- /dev/null +++ b/components/inputmethod/src/attach_options.rs @@ -0,0 +1,2 @@ +mod attach_options_api12; +pub use attach_options_api12::*; diff --git a/components/inputmethod/src/attach_options/attach_options_api12.rs b/components/inputmethod/src/attach_options/attach_options_api12.rs new file mode 100644 index 0000000..d4b098f --- /dev/null +++ b/components/inputmethod/src/attach_options/attach_options_api12.rs @@ -0,0 +1,40 @@ +/* automatically generated by rust-bindgen 0.69.4 */ + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +use crate::types::*; + +#[repr(C)] +pub struct InputMethod_AttachOptions { + _unused: [u8; 0], +} +extern "C" { + /** @brief Create a new {@link InputMethod_AttachOptions} instance. + + @param showKeyboard Represents whether to show the keyboard. + @return If the creation succeeds, a pointer to the newly created {@link InputMethod_AttachOptions} + instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. + @since 12*/ + pub fn OH_AttachOptions_Create(showKeyboard: bool) -> *mut InputMethod_AttachOptions; + /** @brief Delete a {@link InputMethod_AttachOptions} instance. + + @param options Represents a pointer to an {@link InputMethod_AttachOptions} instance which will be destroyed. + @since 12*/ + pub fn OH_AttachOptions_Destroy(options: *mut InputMethod_AttachOptions); + /** @brief Get showKeyboard value from {@link InputMethod_AttachOptions}. + + @param options Represents a pointer to an {@link InputMethod_AttachOptions} instance which will be get value from. + @param showKeyboard Represents showKeyboard value. + true - need to show keyboard. + false - no need to show keyboard. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_AttachOptions_IsShowKeyboard( + options: *mut InputMethod_AttachOptions, + showKeyboard: *mut bool, + ) -> InputMethod_ErrorCode; +} diff --git a/components/inputmethod/src/controller.rs b/components/inputmethod/src/controller.rs new file mode 100644 index 0000000..d4e2aae --- /dev/null +++ b/components/inputmethod/src/controller.rs @@ -0,0 +1,2 @@ +mod controller_api12; +pub use controller_api12::*; diff --git a/components/inputmethod/src/controller/controller_api12.rs b/components/inputmethod/src/controller/controller_api12.rs new file mode 100644 index 0000000..a09a6ad --- /dev/null +++ b/components/inputmethod/src/controller/controller_api12.rs @@ -0,0 +1,48 @@ +/* automatically generated by rust-bindgen 0.69.4 */ + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +use crate::attach_options::InputMethod_AttachOptions; +use crate::inputmethod_proxy::InputMethod_InputMethodProxy; +use crate::text_editor_proxy::InputMethod_TextEditorProxy; +use crate::types::*; + +extern "C" { + /** @brief Attach application to the input method service. + + @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance. + The caller needs to manage the lifecycle of textEditorProxy. + If the call succeeds, caller cannot release textEditorProxy until the next attach or detach call. + @param options Represents a pointer to an {@link InputMethod_AttachOptions} instance. + The options when attaching input method. + @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + Lifecycle is mantianed until the next attach or detach call. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_PARAMCHECK} - parameter check failed. + {@link IME_ERR_IMCLIENT} - input method client error. + {@link IME_ERR_IMMS} - input method manager service error. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_InputMethodController_Attach( + textEditorProxy: *mut InputMethod_TextEditorProxy, + options: *mut InputMethod_AttachOptions, + inputMethodProxy: *mut *mut InputMethod_InputMethodProxy, + ) -> InputMethod_ErrorCode; + /** @brief Detach application from the input method service. + + @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_IMCLIENT} - input method client error. + {@link IME_ERR_IMMS} - input method manager service error. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_InputMethodController_Detach( + inputMethodProxy: *mut InputMethod_InputMethodProxy, + ) -> InputMethod_ErrorCode; +} diff --git a/components/inputmethod/src/cursor_info.rs b/components/inputmethod/src/cursor_info.rs new file mode 100644 index 0000000..993cea3 --- /dev/null +++ b/components/inputmethod/src/cursor_info.rs @@ -0,0 +1,2 @@ +mod cursor_info_api12; +pub use cursor_info_api12::*; diff --git a/components/inputmethod/src/cursor_info/cursor_info_api12.rs b/components/inputmethod/src/cursor_info/cursor_info_api12.rs new file mode 100644 index 0000000..c6c30ff --- /dev/null +++ b/components/inputmethod/src/cursor_info/cursor_info_api12.rs @@ -0,0 +1,71 @@ +/* automatically generated by rust-bindgen 0.69.4 */ + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +use crate::types::*; + +#[repr(C)] +pub struct InputMethod_CursorInfo { + _unused: [u8; 0], +} +extern "C" { + /** @brief Create a new {@link InputMethod_CursorInfo} instance. + + @param left The left point of the cursor and must be absolute coordinate of the physical screen. + @param top The top point of the cursor and must be absolute coordinate of the physical screen. + @param width The width of the cursor. + @param height The height of the cursor. + @return If the creation succeeds, a pointer to the newly created {@link InputMethod_CursorInfo} + instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. + @since 12*/ + pub fn OH_CursorInfo_Create( + left: f64, + top: f64, + width: f64, + height: f64, + ) -> *mut InputMethod_CursorInfo; + /** @brief Destroy a {@link InputMethod_CursorInfo} instance. + + @param cursorInfo Represents a pointer to an {@link InputMethod_CursorInfo} instance which will be destroyed. + @since 12*/ + pub fn OH_CursorInfo_Destroy(cursorInfo: *mut InputMethod_CursorInfo); + /** @brief Set cursor info. + + @param cursorInfo Represents a pointer to an {@link InputMethod_CursorInfo} instance. + @param left The left point of the cursor and must be absolute coordinate of the physical screen. + @param top The top point of the cursor and must be absolute coordinate of the physical screen. + @param width The width of the cursor. + @param height The height of the cursor. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_CursorInfo_SetRect( + cursorInfo: *mut InputMethod_CursorInfo, + left: f64, + top: f64, + width: f64, + height: f64, + ) -> InputMethod_ErrorCode; + /** @brief Get cursor info. + + @param cursorInfo Represents a pointer to an {@link InputMethod_CursorInfo} instance. + @param left The left point of the cursor and must be absolute coordinate of the physical screen. + @param top The top point of the cursor and must be absolute coordinate of the physical screen. + @param width The width of the cursor. + @param height The height of the cursor. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_CursorInfo_GetRect( + cursorInfo: *mut InputMethod_CursorInfo, + left: *mut f64, + top: *mut f64, + width: *mut f64, + height: *mut f64, + ) -> InputMethod_ErrorCode; +} diff --git a/components/inputmethod/src/inputmethod_proxy.rs b/components/inputmethod/src/inputmethod_proxy.rs new file mode 100644 index 0000000..c8bb18d --- /dev/null +++ b/components/inputmethod/src/inputmethod_proxy.rs @@ -0,0 +1,2 @@ +mod inputmethod_proxy_api12; +pub use inputmethod_proxy_api12::*; diff --git a/components/inputmethod/src/inputmethod_proxy/inputmethod_proxy_api12.rs b/components/inputmethod/src/inputmethod_proxy/inputmethod_proxy_api12.rs new file mode 100644 index 0000000..3d8cd86 --- /dev/null +++ b/components/inputmethod/src/inputmethod_proxy/inputmethod_proxy_api12.rs @@ -0,0 +1,130 @@ +/* automatically generated by rust-bindgen 0.69.4 */ + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +use crate::cursor_info::InputMethod_CursorInfo; +use crate::private_command::InputMethod_PrivateCommand; +use crate::types::*; + +#[repr(C)] +pub struct InputMethod_InputMethodProxy { + _unused: [u8; 0], +} +extern "C" { + /** @brief Show keyboard. + + @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_IMCLIENT} - input method client error. + {@link IME_ERR_IMMS} - input method manager service error. + {@link IME_ERR_DETACHED} - input method client is detached. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_InputMethodProxy_ShowKeyboard( + inputMethodProxy: *mut InputMethod_InputMethodProxy, + ) -> InputMethod_ErrorCode; + /** @brief Hide keyboard. + + @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_IMCLIENT} - input method client error. + {@link IME_ERR_IMMS} - input method manager service error. + {@link IME_ERR_DETACHED} - input method client is detached. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_InputMethodProxy_HideKeyboard( + inputMethodProxy: *mut InputMethod_InputMethodProxy, + ) -> InputMethod_ErrorCode; + /** @brief Notify selection change. + + Notify selection change when text or cursor position or selected text changed. + + @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + @param text The whole input text. + @param length The length of text. Max length is 8K. + @param start The start position of selected text. + @param end The end position of selected text. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_PARAMCHECK} - parameter check failed. + {@link IME_ERR_IMCLIENT} - input method client error. + {@link IME_ERR_IMMS} - input method manager service error. + {@link IME_ERR_DETACHED} - input method client is detached. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_InputMethodProxy_NotifySelectionChange( + inputMethodProxy: *mut InputMethod_InputMethodProxy, + text: *mut u16, + length: usize, + start: ::core::ffi::c_int, + end: ::core::ffi::c_int, + ) -> InputMethod_ErrorCode; + /** @brief Notify text editor configuration change. + + @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + @param enterKey The enter key type. + @param textType The text input type. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_PARAMCHECK} - parameter check failed. + {@link IME_ERR_IMCLIENT} - input method client error. + {@link IME_ERR_IMMS} - input method manager service error. + {@link IME_ERR_DETACHED} - input method client is detached. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_InputMethodProxy_NotifyConfigurationChange( + inputMethodProxy: *mut InputMethod_InputMethodProxy, + enterKey: InputMethod_EnterKeyType, + textType: InputMethod_TextInputType, + ) -> InputMethod_ErrorCode; + /** @brief Notify cursor update. + + @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + @param cursorInfo Represents a pointer to an {@link InputMethod_CursorInfo} instance. + The cursor information. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_PARAMCHECK} - parameter check failed. + {@link IME_ERR_IMCLIENT} - input method client error. + {@link IME_ERR_IMMS} - input method manager service error. + {@link IME_ERR_DETACHED} - input method client is detached. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_InputMethodProxy_NotifyCursorUpdate( + inputMethodProxy: *mut InputMethod_InputMethodProxy, + cursorInfo: *mut InputMethod_CursorInfo, + ) -> InputMethod_ErrorCode; + /** @brief Send private command. + + @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + @param privateCommand The private commands, which is defined in {@link InputMethod_PrivateCommand}. Max size 32KB. + @param size The size of privateCommand. Max is 5. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_PARAMCHECK} - parameter check failed. + {@link IME_ERR_IMCLIENT} - input method client error. + {@link IME_ERR_IMMS} - input method manager service error. + {@link IME_ERR_DETACHED} - input method client is detached. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_InputMethodProxy_SendPrivateCommand( + inputMethodProxy: *mut InputMethod_InputMethodProxy, + privateCommand: *mut *mut InputMethod_PrivateCommand, + size: usize, + ) -> InputMethod_ErrorCode; +} diff --git a/components/inputmethod/src/lib.rs b/components/inputmethod/src/lib.rs new file mode 100644 index 0000000..bf190de --- /dev/null +++ b/components/inputmethod/src/lib.rs @@ -0,0 +1,27 @@ +//! Bindings to the native inputmethod API +//! +//! This can be used to interact with the inputmethod on OpenHarmony from native code. +//! Available with API-level 12 and newer +//! +//! Official documentation: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/_input_method-V5 +//! +//! ## Feature flags +#![cfg_attr( + feature = "document-features", + cfg_attr(doc, doc = ::document_features::document_features!()) +)] +#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg(feature = "api-12")] + +#[link(name = "ohinputmethod")] +extern "C" {} + +pub mod attach_options; +pub mod controller; +pub mod cursor_info; +pub mod inputmethod_proxy; +pub mod private_command; +pub mod text_avoid_info; +pub mod text_config; +pub mod text_editor_proxy; +pub mod types; diff --git a/components/inputmethod/src/private_command.rs b/components/inputmethod/src/private_command.rs new file mode 100644 index 0000000..ff4252e --- /dev/null +++ b/components/inputmethod/src/private_command.rs @@ -0,0 +1,2 @@ +mod private_command_api12; +pub use private_command_api12::*; diff --git a/components/inputmethod/src/private_command/private_command_api12.rs b/components/inputmethod/src/private_command/private_command_api12.rs new file mode 100644 index 0000000..b751fde --- /dev/null +++ b/components/inputmethod/src/private_command/private_command_api12.rs @@ -0,0 +1,158 @@ +/* automatically generated by rust-bindgen 0.69.4 */ + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +use crate::types::*; + +#[repr(C)] +pub struct InputMethod_PrivateCommand { + _unused: [u8; 0], +} +extern "C" { + /** @brief Create a new {@link InputMethod_PrivateCommand} instance. + + @param key The key of the private command. + @param keyLength The length of the key. + @return If the creation succeeds, a pointer to the newly created {@link InputMethod_PrivateCommand} + instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. + @since 12*/ + pub fn OH_PrivateCommand_Create( + key: *mut ::core::ffi::c_char, + keyLength: usize, + ) -> *mut InputMethod_PrivateCommand; + /** @brief Destroy a {@link InputMethod_PrivateCommand} instance. + + @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be destroyed. + @since 12*/ + pub fn OH_PrivateCommand_Destroy(command: *mut InputMethod_PrivateCommand); + /** @brief Set key value into {@link InputMethod_PrivateCommand}. + + @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be set value. + @param key Represents key value. + @param keyLength Represents key length. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_PrivateCommand_SetKey( + command: *mut InputMethod_PrivateCommand, + key: *mut ::core::ffi::c_char, + keyLength: usize, + ) -> InputMethod_ErrorCode; + /** @brief Set bool data value into {@link InputMethod_PrivateCommand}. + + @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be set value. + @param value Represents bool data value. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_PrivateCommand_SetBoolValue( + command: *mut InputMethod_PrivateCommand, + value: bool, + ) -> InputMethod_ErrorCode; + /** @brief Set integer data value into {@link InputMethod_PrivateCommand}. + + @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be set value. + @param value Represents integer data value. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_PrivateCommand_SetIntValue( + command: *mut InputMethod_PrivateCommand, + value: i32, + ) -> InputMethod_ErrorCode; + /** @brief Set string data value into {@link InputMethod_PrivateCommand}. + + @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be set value. + @param value Represents string data value. + @param valueLength Represents the length of string data value. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_PrivateCommand_SetStrValue( + command: *mut InputMethod_PrivateCommand, + value: *mut ::core::ffi::c_char, + valueLength: usize, + ) -> InputMethod_ErrorCode; + /** @brief Get key value from {@link InputMethod_PrivateCommand}. + + @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. + @param key Represents key value. + @param keyLength Represents key length. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_PrivateCommand_GetKey( + command: *mut InputMethod_PrivateCommand, + key: *mut *const ::core::ffi::c_char, + keyLength: *mut usize, + ) -> InputMethod_ErrorCode; + /** @brief Get value type from {@link InputMethod_PrivateCommand}. + + @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. + @param type Represents a pointer to a {@link InputMethod_CommandValueType} instance. Indicates the data type of the + value. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_PrivateCommand_GetValueType( + command: *mut InputMethod_PrivateCommand, + type_: *mut InputMethod_CommandValueType, + ) -> InputMethod_ErrorCode; + /** @brief Get bool data value from {@link InputMethod_PrivateCommand}. + + @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. + @param value Represents bool data value. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + {@link IME_ERR_QUERY_FAILED} - query failed, no bool value in command. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_PrivateCommand_GetBoolValue( + command: *mut InputMethod_PrivateCommand, + value: *mut bool, + ) -> InputMethod_ErrorCode; + /** @brief Get integer data value from {@link InputMethod_PrivateCommand}. + + @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. + @param value Represents integer data value. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + {@link IME_ERR_QUERY_FAILED} - query failed, no integer value in command. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_PrivateCommand_GetIntValue( + command: *mut InputMethod_PrivateCommand, + value: *mut i32, + ) -> InputMethod_ErrorCode; + /** @brief Get string data value from {@link InputMethod_PrivateCommand}. + + @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. + @param value Represents string data value. + @param valueLength Represents the length of string data value. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + {@link IME_ERR_QUERY_FAILED} - query failed, no string value in command. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_PrivateCommand_GetStrValue( + command: *mut InputMethod_PrivateCommand, + value: *mut *const ::core::ffi::c_char, + valueLength: *mut usize, + ) -> InputMethod_ErrorCode; +} diff --git a/components/inputmethod/src/text_avoid_info.rs b/components/inputmethod/src/text_avoid_info.rs new file mode 100644 index 0000000..7024b4b --- /dev/null +++ b/components/inputmethod/src/text_avoid_info.rs @@ -0,0 +1,2 @@ +mod text_avoid_info_api12; +pub use text_avoid_info_api12::*; diff --git a/components/inputmethod/src/text_avoid_info/text_avoid_info_api12.rs b/components/inputmethod/src/text_avoid_info/text_avoid_info_api12.rs new file mode 100644 index 0000000..f079810 --- /dev/null +++ b/components/inputmethod/src/text_avoid_info/text_avoid_info_api12.rs @@ -0,0 +1,78 @@ +/* automatically generated by rust-bindgen 0.69.4 */ + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +use crate::types::*; + +#[repr(C)] +pub struct InputMethod_TextAvoidInfo { + _unused: [u8; 0], +} +extern "C" { + /** @brief Create a new {@link InputMethod_TextAvoidInfo} instance. + + @param positionY The y-coordinate of the avoid area. + @param height The height of the avoid area. + @return If the creation succeeds, a pointer to the newly created {@link InputMethod_TextAvoidInfo} + instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. + @since 12*/ + pub fn OH_TextAvoidInfo_Create(positionY: f64, height: f64) -> *mut InputMethod_TextAvoidInfo; + /** @brief Destroy a {@link InputMethod_TextAvoidInfo} instance. + + @param options Represents a pointer to an {@link InputMethod_TextAvoidInfo} instance which will be destroyed. + @since 12*/ + pub fn OH_TextAvoidInfo_Destroy(info: *mut InputMethod_TextAvoidInfo); + /** @brief Set positionY value into {@link InputMethod_TextAvoidInfo}. + + @param info Represents a pointer to an {@link InputMethod_TextAvoidInfo} instance which will be set value. + @param positionY Represents positionY value. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextAvoidInfo_SetPositionY( + info: *mut InputMethod_TextAvoidInfo, + positionY: f64, + ) -> InputMethod_ErrorCode; + /** @brief Set height value into {@link InputMethod_TextAvoidInfo}. + + @param info Represents a pointer to an {@link InputMethod_TextAvoidInfo} instance which will be set value. + @param height Represents height value. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextAvoidInfo_SetHeight( + info: *mut InputMethod_TextAvoidInfo, + height: f64, + ) -> InputMethod_ErrorCode; + /** @brief Get positionY value from {@link InputMethod_TextAvoidInfo}. + + @param info Represents a pointer to an {@link InputMethod_TextAvoidInfo} instance which will be get value from. + @param positionY Represents positionY value. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextAvoidInfo_GetPositionY( + info: *mut InputMethod_TextAvoidInfo, + positionY: *mut f64, + ) -> InputMethod_ErrorCode; + /** @brief Get height value into {@link InputMethod_TextAvoidInfo}. + + @param info Represents a pointer to an {@link InputMethod_TextAvoidInfo} instance which will be get value from. + @param height Represents height value. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextAvoidInfo_GetHeight( + info: *mut InputMethod_TextAvoidInfo, + height: *mut f64, + ) -> InputMethod_ErrorCode; +} diff --git a/components/inputmethod/src/text_config.rs b/components/inputmethod/src/text_config.rs new file mode 100644 index 0000000..83baa02 --- /dev/null +++ b/components/inputmethod/src/text_config.rs @@ -0,0 +1,2 @@ +mod text_config_api12; +pub use text_config_api12::*; diff --git a/components/inputmethod/src/text_config/text_config_api12.rs b/components/inputmethod/src/text_config/text_config_api12.rs new file mode 100644 index 0000000..019b99b --- /dev/null +++ b/components/inputmethod/src/text_config/text_config_api12.rs @@ -0,0 +1,188 @@ +/* automatically generated by rust-bindgen 0.69.4 */ + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +use crate::cursor_info::InputMethod_CursorInfo; +use crate::text_avoid_info::InputMethod_TextAvoidInfo; +use crate::types::*; + +#[repr(C)] +pub struct InputMethod_TextConfig { + _unused: [u8; 0], +} +extern "C" { + /** @brief Create a new {@link InputMethod_TextConfig} instance. + + @return If the creation succeeds, a pointer to the newly created {@link InputMethod_TextConfig} + instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. + @since 12*/ + pub fn OH_TextConfig_Create() -> *mut InputMethod_TextConfig; + /** @brief Destroy a {@link InputMethod_TextConfig} instance. + + @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be destroyed. + @since 12*/ + pub fn OH_TextConfig_Destroy(config: *mut InputMethod_TextConfig); + /** @brief Set input type into TextConfig. + + @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be set. + @param inputType The text input type of text Editor, which is defined in {@link InputMethod_TextInputType}. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextConfig_SetInputType( + config: *mut InputMethod_TextConfig, + inputType: InputMethod_TextInputType, + ) -> InputMethod_ErrorCode; + /** @brief Set enter key type into TextConfig. + + @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be set. + @param enterKeyType The enter key type of text Editor, which is defined in {@link InputMethod_EnterKeyType}. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextConfig_SetEnterKeyType( + config: *mut InputMethod_TextConfig, + enterKeyType: InputMethod_EnterKeyType, + ) -> InputMethod_ErrorCode; + /** @brief Set preview text support into TextConfig. + + @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be set. + @param supported Indicates whether the preview text is supported. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextConfig_SetPreviewTextSupport( + config: *mut InputMethod_TextConfig, + supported: bool, + ) -> InputMethod_ErrorCode; + /** @brief Set selection into TextConfig. + + @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be set. + @param start The start position of selection. + @param end The end position of selection. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextConfig_SetSelection( + config: *mut InputMethod_TextConfig, + start: i32, + end: i32, + ) -> InputMethod_ErrorCode; + /** @brief Set window id into TextConfig. + + @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be set. + @param windowId The window ID of the application currently bound to the input method. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextConfig_SetWindowId( + config: *mut InputMethod_TextConfig, + windowId: i32, + ) -> InputMethod_ErrorCode; + /** @brief Get input type from TextConfig + + @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be get from. + @param inputType Represents a pointer to an {@link InputMethod_TextInputType} instance. + The text input type of text Editor + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextConfig_GetInputType( + config: *mut InputMethod_TextConfig, + inputType: *mut InputMethod_TextInputType, + ) -> InputMethod_ErrorCode; + /** @brief Get enter key type from TextConfig + + @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be get from. + @param enterKeyType Represents a pointer to an {@link InputMethod_EnterKeyType} instance. + Indicates the enter key type of text Editor + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextConfig_GetEnterKeyType( + config: *mut InputMethod_TextConfig, + enterKeyType: *mut InputMethod_EnterKeyType, + ) -> InputMethod_ErrorCode; + /** @brief Get is preview text supported from TextConfig. + + @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be get from. + @param supported Indicates whether the preview text is supported. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextConfig_IsPreviewTextSupported( + config: *mut InputMethod_TextConfig, + supported: *mut bool, + ) -> InputMethod_ErrorCode; + /** @brief Get cursor info from TextConfig. + + @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be get from. + @param cursorInfo Represents a pointer to an {@link InputMethod_CursorInfo} instance. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextConfig_GetCursorInfo( + config: *mut InputMethod_TextConfig, + cursorInfo: *mut *mut InputMethod_CursorInfo, + ) -> InputMethod_ErrorCode; + /** @brief Get text avoid information from text configuration. + + @param config Indicates the text configuration. + @param avoidInfo Indicates the text avoid information. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextConfig_GetTextAvoidInfo( + config: *mut InputMethod_TextConfig, + avoidInfo: *mut *mut InputMethod_TextAvoidInfo, + ) -> InputMethod_ErrorCode; + /** @brief Get selection from TextConfig. + + @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be get from. + @param start Represents selection start position. + @param end Represents selection end position. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextConfig_GetSelection( + config: *mut InputMethod_TextConfig, + start: *mut i32, + end: *mut i32, + ) -> InputMethod_ErrorCode; + /** @brief Get window id from TextConfig. + + @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be get from. + @param windowId The window ID of the application currently bound to the input method. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextConfig_GetWindowId( + config: *mut InputMethod_TextConfig, + windowId: *mut i32, + ) -> InputMethod_ErrorCode; +} diff --git a/components/inputmethod/src/text_editor_proxy.rs b/components/inputmethod/src/text_editor_proxy.rs new file mode 100644 index 0000000..563e71f --- /dev/null +++ b/components/inputmethod/src/text_editor_proxy.rs @@ -0,0 +1,2 @@ +mod text_editor_proxy_api12; +pub use text_editor_proxy_api12::*; diff --git a/components/inputmethod/src/text_editor_proxy/text_editor_proxy_api12.rs b/components/inputmethod/src/text_editor_proxy/text_editor_proxy_api12.rs new file mode 100644 index 0000000..315900c --- /dev/null +++ b/components/inputmethod/src/text_editor_proxy/text_editor_proxy_api12.rs @@ -0,0 +1,679 @@ +/* automatically generated by rust-bindgen 0.69.4 */ + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +use crate::private_command::InputMethod_PrivateCommand; +use crate::text_config::InputMethod_TextConfig; +use crate::types::*; + +#[repr(C)] +pub struct InputMethod_TextEditorProxy { + _unused: [u8; 0], +} +/** @brief Defines the function called when input method getting text config. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetGetTextConfigFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance. +@param config Represents a pointer to an {@link InputMethod_TextConfig} instance. +@since 12*/ +pub type OH_TextEditorProxy_GetTextConfigFunc = ::core::option::Option< + unsafe extern "C" fn( + textEditorProxy: *mut InputMethod_TextEditorProxy, + config: *mut InputMethod_TextConfig, + ), +>; +/** @brief Defines the function called when input method inserting text. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetInsertTextFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to the {@link InputMethod_TextEditorProxy} instance which will be set +in. +@param text Represents a pointer to the text to be inserted. +@param length Represents the length of the text to be inserted. +@since 12*/ +pub type OH_TextEditorProxy_InsertTextFunc = ::core::option::Option< + unsafe extern "C" fn( + textEditorProxy: *mut InputMethod_TextEditorProxy, + text: *const u16, + length: usize, + ), +>; +/** @brief Defines the function called when input method deleting text forward. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetDeleteForwardFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to the {@link InputMethod_TextEditorProxy} instance which will be set +in. +@param length Represents the length of the text to be deleted. +@since 12*/ +pub type OH_TextEditorProxy_DeleteForwardFunc = ::core::option::Option< + unsafe extern "C" fn(textEditorProxy: *mut InputMethod_TextEditorProxy, length: i32), +>; +/** @brief Defines the function called when input method deleting text backward. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetDeleteForwardFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to the {@link InputMethod_TextEditorProxy} instance which will be set +in. +@param length Represents the length of the text to be deleted. +@since 12*/ +pub type OH_TextEditorProxy_DeleteBackwardFunc = ::core::option::Option< + unsafe extern "C" fn(textEditorProxy: *mut InputMethod_TextEditorProxy, length: i32), +>; +/** @brief Called when input method notifying keyboard status. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetSendKeyboardStatusFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. +@param keyboardStatus Keyboard status, which is defined in {@link InputMethod_KeyboardStatus}. +@since 12*/ +pub type OH_TextEditorProxy_SendKeyboardStatusFunc = ::core::option::Option< + unsafe extern "C" fn( + textEditorProxy: *mut InputMethod_TextEditorProxy, + keyboardStatus: InputMethod_KeyboardStatus, + ), +>; +/** @brief Called when input method sending enter key. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetSendEnterKeyFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. +@param enterKeyType Enter key type, which is defined in {@link InputMethod_EnterKeyType}. +@since 12*/ +pub type OH_TextEditorProxy_SendEnterKeyFunc = ::core::option::Option< + unsafe extern "C" fn( + textEditorProxy: *mut InputMethod_TextEditorProxy, + enterKeyType: InputMethod_EnterKeyType, + ), +>; +/** @brief Called when input method requesting to move cursor. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetMoveCursorFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. +@param direction Represents the direction of the cursor movement, which is defined in {@link InputMethod_Direction}. +@since 12*/ +pub type OH_TextEditorProxy_MoveCursorFunc = ::core::option::Option< + unsafe extern "C" fn( + textEditorProxy: *mut InputMethod_TextEditorProxy, + direction: InputMethod_Direction, + ), +>; +/** @brief Called when input method requesting to set selection. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetHandleSetSelectionFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. +@param start Represents the start position of the selection. +@param end Represents the end position of the selection. +@since 12*/ +pub type OH_TextEditorProxy_HandleSetSelectionFunc = ::core::option::Option< + unsafe extern "C" fn(textEditorProxy: *mut InputMethod_TextEditorProxy, start: i32, end: i32), +>; +/** @brief Called when input method sending extend action. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetHandleExtendActionFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. +@param action Represents the extend action, which is defined in {@link InputMethod_ExtendAction}. +@since 12*/ +pub type OH_TextEditorProxy_HandleExtendActionFunc = ::core::option::Option< + unsafe extern "C" fn( + textEditorProxy: *mut InputMethod_TextEditorProxy, + action: InputMethod_ExtendAction, + ), +>; +/** @brief Called when input method requesting to get left text of cursor. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetGetLeftTextOfCursorFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. +@param number Represents the number of characters to be get. +@param text Represents the left text of cursor, you need to assing this parameter. +@param length Represents the length of the left text of cursor, you need to assing this parameter. +@since 12*/ +pub type OH_TextEditorProxy_GetLeftTextOfCursorFunc = ::core::option::Option< + unsafe extern "C" fn( + textEditorProxy: *mut InputMethod_TextEditorProxy, + number: i32, + text: *mut u16, + length: *mut usize, + ), +>; +/** @brief Called when input method requesting to get right text of cursor. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetGetRightTextOfCursorFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. +@param number Represents the number of characters to be get. +@param text Represents the right text of cursor, you need to assing this parameter. +@param length Represents the length of the right text of cursor. +@since 12*/ +pub type OH_TextEditorProxy_GetRightTextOfCursorFunc = ::core::option::Option< + unsafe extern "C" fn( + textEditorProxy: *mut InputMethod_TextEditorProxy, + number: i32, + text: *mut u16, + length: *mut usize, + ), +>; +/** @brief Called when input method requesting to get text index at cursor. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetGetTextIndexAtCursorFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. +@return Returns the index of text at cursor. +@since 12*/ +pub type OH_TextEditorProxy_GetTextIndexAtCursorFunc = ::core::option::Option< + unsafe extern "C" fn(textEditorProxy: *mut InputMethod_TextEditorProxy) -> i32, +>; +/** @brief Called when input method sending private command. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetReceivePrivateCommandFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. +@param privateCommand Private command from input method. +@param size Size of private command. +@return Returns the result of handling private command. +@since 12*/ +pub type OH_TextEditorProxy_ReceivePrivateCommandFunc = ::core::option::Option< + unsafe extern "C" fn( + textEditorProxy: *mut InputMethod_TextEditorProxy, + privateCommand: *mut *mut InputMethod_PrivateCommand, + size: usize, + ) -> i32, +>; +/** @brief Called when input method setting preview text. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetReceivePrivateCommandFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. +@param text Represents text to be previewd. +@param length Length of preview text. +@param start Start position of preview text. +@param end End position of preview text. +@return Returns the result of setting preview text. +@since 12*/ +pub type OH_TextEditorProxy_SetPreviewTextFunc = ::core::option::Option< + unsafe extern "C" fn( + textEditorProxy: *mut InputMethod_TextEditorProxy, + text: *const u16, + length: usize, + start: i32, + end: i32, + ) -> i32, +>; +/** @brief Called when input method finishing preview text. + +You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link +OH_TextEditorProxy_SetReceivePrivateCommandFunc}, and use {@link OH_InputMethodController_Attach} to complete the +registration.\n + +@param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. +@since 12*/ +pub type OH_TextEditorProxy_FinishTextPreviewFunc = + ::core::option::Option; +extern "C" { + /** @brief Create a new {@link InputMethod_TextEditorProxy} instance. + + @return If the creation succeeds, a pointer to the newly created {@link InputMethod_TextEditorProxy} + instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. + @since 12*/ + pub fn OH_TextEditorProxy_Create() -> *mut InputMethod_TextEditorProxy; + /** @brief Destroy a {@link InputMethod_TextEditorProxy} instance. + + @param proxy The {@link InputMethod_TextEditorProxy} instance to be destroyed. + @since 12*/ + pub fn OH_TextEditorProxy_Destroy(proxy: *mut InputMethod_TextEditorProxy); + /** @brief Set function {@link OH_TextEditorProxy_GetTextConfigFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param getTextConfigFunc Represents function {@link OH_TextEditorProxy_GetTextConfigFunc} which will be set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetGetTextConfigFunc( + proxy: *mut InputMethod_TextEditorProxy, + getTextConfigFunc: OH_TextEditorProxy_GetTextConfigFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_InsertTextFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param insertTextFunc Represents function {@link OH_TextEditorProxy_InsertTextFunc} which will be set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetInsertTextFunc( + proxy: *mut InputMethod_TextEditorProxy, + insertTextFunc: OH_TextEditorProxy_InsertTextFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_SetDeleteForwardFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param deleteForwardFunc Represents function {@link OH_TextEditorProxy_DeleteForwardFunc} which will be set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetDeleteForwardFunc( + proxy: *mut InputMethod_TextEditorProxy, + deleteForwardFunc: OH_TextEditorProxy_DeleteForwardFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_DeleteBackwardFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param deleteBackwardFunc Represents function {@link OH_TextEditorProxy_DeleteBackwardFunc} which will be set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetDeleteBackwardFunc( + proxy: *mut InputMethod_TextEditorProxy, + deleteBackwardFunc: OH_TextEditorProxy_DeleteBackwardFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_SendKeyboardStatusFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param sendKeyboardStatusFunc Represents function {@link OH_TextEditorProxy_SendKeyboardStatusFunc} which will be + set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetSendKeyboardStatusFunc( + proxy: *mut InputMethod_TextEditorProxy, + sendKeyboardStatusFunc: OH_TextEditorProxy_SendKeyboardStatusFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_SendEnterKeyFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param sendEnterKeyFunc Represents function {@link OH_TextEditorProxy_SendEnterKeyFunc} which will be set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetSendEnterKeyFunc( + proxy: *mut InputMethod_TextEditorProxy, + sendEnterKeyFunc: OH_TextEditorProxy_SendEnterKeyFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_MoveCursorFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param moveCursorFunc Represents function {@link OH_TextEditorProxy_MoveCursorFunc} which will be set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetMoveCursorFunc( + proxy: *mut InputMethod_TextEditorProxy, + moveCursorFunc: OH_TextEditorProxy_MoveCursorFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_HandleSetSelectionFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param handleSetSelectionFunc Represents function {@link OH_TextEditorProxy_HandleSetSelectionFunc} which will be + set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetHandleSetSelectionFunc( + proxy: *mut InputMethod_TextEditorProxy, + handleSetSelectionFunc: OH_TextEditorProxy_HandleSetSelectionFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_HandleExtendActionFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param handleExtendActionFunc Represents function {@link OH_TextEditorProxy_HandleExtendActionFunc} which will be + set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetHandleExtendActionFunc( + proxy: *mut InputMethod_TextEditorProxy, + handleExtendActionFunc: OH_TextEditorProxy_HandleExtendActionFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_GetLeftTextOfCursorFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param getLeftTextOfCursorFunc Represents function {@link OH_TextEditorProxy_GetLeftTextOfCursorFunc} which will + be set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetGetLeftTextOfCursorFunc( + proxy: *mut InputMethod_TextEditorProxy, + getLeftTextOfCursorFunc: OH_TextEditorProxy_GetLeftTextOfCursorFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_GetRightTextOfCursorFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param getRightTextOfCursorFunc Represents function {@link OH_TextEditorProxy_GetRightTextOfCursorFunc} which + will be set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetGetRightTextOfCursorFunc( + proxy: *mut InputMethod_TextEditorProxy, + getRightTextOfCursorFunc: OH_TextEditorProxy_GetRightTextOfCursorFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_GetTextIndexAtCursorFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param getTextIndexAtCursorFunc Represents function {@link OH_TextEditorProxy_GetTextIndexAtCursorFunc} which + will be set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetGetTextIndexAtCursorFunc( + proxy: *mut InputMethod_TextEditorProxy, + getTextIndexAtCursorFunc: OH_TextEditorProxy_GetTextIndexAtCursorFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_ReceivePrivateCommandFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param receivePrivateCommandFunc Represents function {@link OH_TextEditorProxy_ReceivePrivateCommandFunc} which + will be set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetReceivePrivateCommandFunc( + proxy: *mut InputMethod_TextEditorProxy, + receivePrivateCommandFunc: OH_TextEditorProxy_ReceivePrivateCommandFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_SetPreviewTextFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param setPreviewTextFunc Represents function {@link OH_TextEditorProxy_SetPreviewTextFunc} which will be set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetSetPreviewTextFunc( + proxy: *mut InputMethod_TextEditorProxy, + setPreviewTextFunc: OH_TextEditorProxy_SetPreviewTextFunc, + ) -> InputMethod_ErrorCode; + /** @brief Set function {@link OH_TextEditorProxy_FinishTextPreviewFunc} into {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + @param finishTextPreviewFunc Represents function {@link OH_TextEditorProxy_FinishTextPreviewFunc} which will be + set. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_SetFinishTextPreviewFunc( + proxy: *mut InputMethod_TextEditorProxy, + finishTextPreviewFunc: OH_TextEditorProxy_FinishTextPreviewFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_GetTextConfigFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param getTextConfigFunc Represents function {@link OH_TextEditorProxy_GetTextConfigFunc} which will be get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetGetTextConfigFunc( + proxy: *mut InputMethod_TextEditorProxy, + getTextConfigFunc: *mut OH_TextEditorProxy_GetTextConfigFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_InsertTextFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param insertTextFunc Represents function {@link OH_TextEditorProxy_InsertTextFunc} which will be get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetInsertTextFunc( + proxy: *mut InputMethod_TextEditorProxy, + insertTextFunc: *mut OH_TextEditorProxy_InsertTextFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_DeleteForwardFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param deleteForwardFunc Represents function {@link OH_TextEditorProxy_DeleteForwardFunc} which will be get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetDeleteForwardFunc( + proxy: *mut InputMethod_TextEditorProxy, + deleteForwardFunc: *mut OH_TextEditorProxy_DeleteForwardFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_DeleteBackwardFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param deleteBackwardFunc Represents function {@link OH_TextEditorProxy_DeleteBackwardFunc} which will be get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetDeleteBackwardFunc( + proxy: *mut InputMethod_TextEditorProxy, + deleteBackwardFunc: *mut OH_TextEditorProxy_DeleteBackwardFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_SendKeyboardStatusFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param sendKeyboardStatusFunc Represents function {@link OH_TextEditorProxy_SendKeyboardStatusFunc} which will be + get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetSendKeyboardStatusFunc( + proxy: *mut InputMethod_TextEditorProxy, + sendKeyboardStatusFunc: *mut OH_TextEditorProxy_SendKeyboardStatusFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_SendEnterKeyFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param sendEnterKeyFunc Represents function {@link OH_TextEditorProxy_SendEnterKeyFunc} which will be get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetSendEnterKeyFunc( + proxy: *mut InputMethod_TextEditorProxy, + sendEnterKeyFunc: *mut OH_TextEditorProxy_SendEnterKeyFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_MoveCursorFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param moveCursorFunc Represents function {@link OH_TextEditorProxy_MoveCursorFunc} which will be get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetMoveCursorFunc( + proxy: *mut InputMethod_TextEditorProxy, + moveCursorFunc: *mut OH_TextEditorProxy_MoveCursorFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_HandleSetSelectionFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param handleSetSelectionFunc Represents function {@link OH_TextEditorProxy_HandleSetSelectionFunc} which will be + get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetHandleSetSelectionFunc( + proxy: *mut InputMethod_TextEditorProxy, + handleSetSelectionFunc: *mut OH_TextEditorProxy_HandleSetSelectionFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_HandleExtendActionFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param handleExtendActionFunc Represents function {@link OH_TextEditorProxy_HandleExtendActionFunc} which will be + get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetHandleExtendActionFunc( + proxy: *mut InputMethod_TextEditorProxy, + handleExtendActionFunc: *mut OH_TextEditorProxy_HandleExtendActionFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_GetLeftTextOfCursorFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param getLeftTextOfCursorFunc Represents function {@link OH_TextEditorProxy_GetLeftTextOfCursorFunc} which will + be get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetGetLeftTextOfCursorFunc( + proxy: *mut InputMethod_TextEditorProxy, + getLeftTextOfCursorFunc: *mut OH_TextEditorProxy_GetLeftTextOfCursorFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_GetRightTextOfCursorFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param getRightTextOfCursorFunc Represents function {@link OH_TextEditorProxy_GetRightTextOfCursorFunc} which + will be get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetGetRightTextOfCursorFunc( + proxy: *mut InputMethod_TextEditorProxy, + getRightTextOfCursorFunc: *mut OH_TextEditorProxy_GetRightTextOfCursorFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_GetTextIndexAtCursorFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param getTextIndexAtCursorFunc Represents function {@link OH_TextEditorProxy_GetTextIndexAtCursorFunc} which + will be get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetGetTextIndexAtCursorFunc( + proxy: *mut InputMethod_TextEditorProxy, + getTextIndexAtCursorFunc: *mut OH_TextEditorProxy_GetTextIndexAtCursorFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_ReceivePrivateCommandFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param receivePrivateCommandFunc Represents function {@link OH_TextEditorProxy_ReceivePrivateCommandFunc} which + will be get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetReceivePrivateCommandFunc( + proxy: *mut InputMethod_TextEditorProxy, + receivePrivateCommandFunc: *mut OH_TextEditorProxy_ReceivePrivateCommandFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_SetPreviewTextFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param setPreviewTextFunc Represents function {@link OH_TextEditorProxy_SetPreviewTextFunc} which will be get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetSetPreviewTextFunc( + proxy: *mut InputMethod_TextEditorProxy, + setPreviewTextFunc: *mut OH_TextEditorProxy_SetPreviewTextFunc, + ) -> InputMethod_ErrorCode; + /** @brief Get function {@link OH_TextEditorProxy_FinishTextPreviewFunc} from {@link InputMethod_TextEditorProxy}. + + @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + from. + @param finishTextPreviewFunc Represents function {@link OH_TextEditorProxy_FinishTextPreviewFunc} which will be + get. + @return Returns a specific error code. + {@link IME_ERR_OK} - success. + {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + Specific error codes can be referenced {@link InputMethod_ErrorCode}. + @since 12*/ + pub fn OH_TextEditorProxy_GetFinishTextPreviewFunc( + proxy: *mut InputMethod_TextEditorProxy, + finishTextPreviewFunc: *mut OH_TextEditorProxy_FinishTextPreviewFunc, + ) -> InputMethod_ErrorCode; +} diff --git a/components/inputmethod/src/types.rs b/components/inputmethod/src/types.rs new file mode 100644 index 0000000..f2d3644 --- /dev/null +++ b/components/inputmethod/src/types.rs @@ -0,0 +1,2 @@ +mod types_api12; +pub use types_api12::*; diff --git a/components/inputmethod/src/types/types_api12.rs b/components/inputmethod/src/types/types_api12.rs new file mode 100644 index 0000000..d8dd0ff --- /dev/null +++ b/components/inputmethod/src/types/types_api12.rs @@ -0,0 +1,269 @@ +/* automatically generated by rust-bindgen 0.69.4 */ + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +impl InputMethod_KeyboardStatus { + /// The keyboard status is none. + pub const IME_KEYBOARD_STATUS_NONE: InputMethod_KeyboardStatus = InputMethod_KeyboardStatus(0); +} +impl InputMethod_KeyboardStatus { + /// The keyboard status is hide. + pub const IME_KEYBOARD_STATUS_HIDE: InputMethod_KeyboardStatus = InputMethod_KeyboardStatus(1); +} +impl InputMethod_KeyboardStatus { + /// The keyboard status is show. + pub const IME_KEYBOARD_STATUS_SHOW: InputMethod_KeyboardStatus = InputMethod_KeyboardStatus(2); +} +#[repr(transparent)] +/** @brief Keyboard status. + +@since 12*/ +#[derive(Clone, Hash, PartialEq, Eq)] +pub struct InputMethod_KeyboardStatus(pub ::core::ffi::c_uint); +impl InputMethod_EnterKeyType { + /// The enter key type is UNSPECIFIED. + pub const IME_ENTER_KEY_UNSPECIFIED: InputMethod_EnterKeyType = InputMethod_EnterKeyType(0); +} +impl InputMethod_EnterKeyType { + /// The enter key type is NONE. + pub const IME_ENTER_KEY_NONE: InputMethod_EnterKeyType = InputMethod_EnterKeyType(1); +} +impl InputMethod_EnterKeyType { + /// The enter key type is GO. + pub const IME_ENTER_KEY_GO: InputMethod_EnterKeyType = InputMethod_EnterKeyType(2); +} +impl InputMethod_EnterKeyType { + /// The enter key type is SEARCH. + pub const IME_ENTER_KEY_SEARCH: InputMethod_EnterKeyType = InputMethod_EnterKeyType(3); +} +impl InputMethod_EnterKeyType { + /// The enter key type is SEND. + pub const IME_ENTER_KEY_SEND: InputMethod_EnterKeyType = InputMethod_EnterKeyType(4); +} +impl InputMethod_EnterKeyType { + /// The enter key type is NEXT. + pub const IME_ENTER_KEY_NEXT: InputMethod_EnterKeyType = InputMethod_EnterKeyType(5); +} +impl InputMethod_EnterKeyType { + /// The enter key type is DONE. + pub const IME_ENTER_KEY_DONE: InputMethod_EnterKeyType = InputMethod_EnterKeyType(6); +} +impl InputMethod_EnterKeyType { + /// The enter key type is PREVIOUS. + pub const IME_ENTER_KEY_PREVIOUS: InputMethod_EnterKeyType = InputMethod_EnterKeyType(7); +} +impl InputMethod_EnterKeyType { + /// The enter key type is NEWLINE. + pub const IME_ENTER_KEY_NEWLINE: InputMethod_EnterKeyType = InputMethod_EnterKeyType(8); +} +#[repr(transparent)] +/** @brief Enter key type. + +@since 12*/ +#[derive(Clone, Hash, PartialEq, Eq)] +pub struct InputMethod_EnterKeyType(pub ::core::ffi::c_uint); +impl InputMethod_Direction { + /// The direction is NONE. + pub const IME_DIRECTION_NONE: InputMethod_Direction = InputMethod_Direction(0); +} +impl InputMethod_Direction { + /// The direction is UP. + pub const IME_DIRECTION_UP: InputMethod_Direction = InputMethod_Direction(1); +} +impl InputMethod_Direction { + /// The direction is DOWN. + pub const IME_DIRECTION_DOWN: InputMethod_Direction = InputMethod_Direction(2); +} +impl InputMethod_Direction { + /// The direction is LEFT. + pub const IME_DIRECTION_LEFT: InputMethod_Direction = InputMethod_Direction(3); +} +impl InputMethod_Direction { + /// The direction is RIGHT. + pub const IME_DIRECTION_RIGHT: InputMethod_Direction = InputMethod_Direction(4); +} +#[repr(transparent)] +/** @brief Direction. + +@since 12*/ +#[derive(Clone, Hash, PartialEq, Eq)] +pub struct InputMethod_Direction(pub ::core::ffi::c_uint); +impl InputMethod_ExtendAction { + /// Select all text. + pub const IME_EXTEND_ACTION_SELECT_ALL: InputMethod_ExtendAction = InputMethod_ExtendAction(0); +} +impl InputMethod_ExtendAction { + /// Cut selected text. + pub const IME_EXTEND_ACTION_CUT: InputMethod_ExtendAction = InputMethod_ExtendAction(3); +} +impl InputMethod_ExtendAction { + /// Copy selected text. + pub const IME_EXTEND_ACTION_COPY: InputMethod_ExtendAction = InputMethod_ExtendAction(4); +} +impl InputMethod_ExtendAction { + /// Paste from paste board. + pub const IME_EXTEND_ACTION_PASTE: InputMethod_ExtendAction = InputMethod_ExtendAction(5); +} +#[repr(transparent)] +/** @brief The extend action. + +@since 12*/ +#[derive(Clone, Hash, PartialEq, Eq)] +pub struct InputMethod_ExtendAction(pub ::core::ffi::c_uint); +impl InputMethod_TextInputType { + /// The text input type is NONE. + pub const IME_TEXT_INPUT_TYPE_NONE: InputMethod_TextInputType = InputMethod_TextInputType(-1); +} +impl InputMethod_TextInputType { + /// The text input type is TEXT. + pub const IME_TEXT_INPUT_TYPE_TEXT: InputMethod_TextInputType = InputMethod_TextInputType(0); +} +impl InputMethod_TextInputType { + /// The text input type is MULTILINE. + pub const IME_TEXT_INPUT_TYPE_MULTILINE: InputMethod_TextInputType = + InputMethod_TextInputType(1); +} +impl InputMethod_TextInputType { + /// The text input type is NUMBER. + pub const IME_TEXT_INPUT_TYPE_NUMBER: InputMethod_TextInputType = InputMethod_TextInputType(2); +} +impl InputMethod_TextInputType { + /// The text input type is PHONE. + pub const IME_TEXT_INPUT_TYPE_PHONE: InputMethod_TextInputType = InputMethod_TextInputType(3); +} +impl InputMethod_TextInputType { + /// The text input type is DATETIME. + pub const IME_TEXT_INPUT_TYPE_DATETIME: InputMethod_TextInputType = + InputMethod_TextInputType(4); +} +impl InputMethod_TextInputType { + /// The text input type is EMAIL ADDRESS. + pub const IME_TEXT_INPUT_TYPE_EMAIL_ADDRESS: InputMethod_TextInputType = + InputMethod_TextInputType(5); +} +impl InputMethod_TextInputType { + /// The text input type is URL. + pub const IME_TEXT_INPUT_TYPE_URL: InputMethod_TextInputType = InputMethod_TextInputType(6); +} +impl InputMethod_TextInputType { + /// The text input type is VISIBLE PASSWORD. + pub const IME_TEXT_INPUT_TYPE_VISIBLE_PASSWORD: InputMethod_TextInputType = + InputMethod_TextInputType(7); +} +impl InputMethod_TextInputType { + /// The text input type is NUMBER PASSWORD. + pub const IME_TEXT_INPUT_TYPE_NUMBER_PASSWORD: InputMethod_TextInputType = + InputMethod_TextInputType(8); +} +impl InputMethod_TextInputType { + /// The text input type is SCREEN LOCK PASSWORD. + pub const IME_TEXT_INPUT_TYPE_SCREEN_LOCK_PASSWORD: InputMethod_TextInputType = + InputMethod_TextInputType(9); +} +impl InputMethod_TextInputType { + /// The text input type is USER NAME. + pub const IME_TEXT_INPUT_TYPE_USER_NAME: InputMethod_TextInputType = + InputMethod_TextInputType(10); +} +impl InputMethod_TextInputType { + /// The text input type is NEW PASSWORD. + pub const IME_TEXT_INPUT_TYPE_NEW_PASSWORD: InputMethod_TextInputType = + InputMethod_TextInputType(11); +} +impl InputMethod_TextInputType { + /// The text input type is NUMBER DECIMAL. + pub const IME_TEXT_INPUT_TYPE_NUMBER_DECIMAL: InputMethod_TextInputType = + InputMethod_TextInputType(12); +} +#[repr(transparent)] +/** @brief The text input type. + +@since 12*/ +#[derive(Clone, Hash, PartialEq, Eq)] +pub struct InputMethod_TextInputType(pub ::core::ffi::c_int); +impl InputMethod_CommandValueType { + /// Value type is NONE. + pub const IME_COMMAND_VALUE_TYPE_NONE: InputMethod_CommandValueType = + InputMethod_CommandValueType(0); +} +impl InputMethod_CommandValueType { + /// Value type is STRING. + pub const IME_COMMAND_VALUE_TYPE_STRING: InputMethod_CommandValueType = + InputMethod_CommandValueType(1); +} +impl InputMethod_CommandValueType { + /// Value type is BOOL. + pub const IME_COMMAND_VALUE_TYPE_BOOL: InputMethod_CommandValueType = + InputMethod_CommandValueType(2); +} +impl InputMethod_CommandValueType { + /// Value type is INT32. + pub const IME_COMMAND_VALUE_TYPE_INT32: InputMethod_CommandValueType = + InputMethod_CommandValueType(3); +} +#[repr(transparent)] +/** @brief The value type of command data. + +@since 12*/ +#[derive(Clone, Hash, PartialEq, Eq)] +pub struct InputMethod_CommandValueType(pub ::core::ffi::c_uint); +impl InputMethod_ErrorCode { + /// @error The error code in the correct case. + pub const IME_ERR_OK: InputMethod_ErrorCode = InputMethod_ErrorCode(0); +} +impl InputMethod_ErrorCode { + /// @error The error code when error is undefined. + pub const IME_ERR_UNDEFINED: InputMethod_ErrorCode = InputMethod_ErrorCode(1); +} +impl InputMethod_ErrorCode { + /// @error The error code when parameter check failed. + pub const IME_ERR_PARAMCHECK: InputMethod_ErrorCode = InputMethod_ErrorCode(401); +} +impl InputMethod_ErrorCode { + /// @error The error code when the package manager error. + pub const IME_ERR_PACKAGEMANAGER: InputMethod_ErrorCode = InputMethod_ErrorCode(12800001); +} +impl InputMethod_ErrorCode { + /// @error The error code when input method engine error. + pub const IME_ERR_IMENGINE: InputMethod_ErrorCode = InputMethod_ErrorCode(12800002); +} +impl InputMethod_ErrorCode { + /// @error The error code when input method client error. + pub const IME_ERR_IMCLIENT: InputMethod_ErrorCode = InputMethod_ErrorCode(12800003); +} +impl InputMethod_ErrorCode { + /// @error The error code when configuration persisting error. + pub const IME_ERR_CONFIG_PERSIST: InputMethod_ErrorCode = InputMethod_ErrorCode(12800005); +} +impl InputMethod_ErrorCode { + /// @error The error code when input method controller error. + pub const IME_ERR_CONTROLLER: InputMethod_ErrorCode = InputMethod_ErrorCode(12800006); +} +impl InputMethod_ErrorCode { + /// @error The error code when input method setting error. + pub const IME_ERR_SETTINGS: InputMethod_ErrorCode = InputMethod_ErrorCode(12800007); +} +impl InputMethod_ErrorCode { + /// @error The error code when input method manager service error. + pub const IME_ERR_IMMS: InputMethod_ErrorCode = InputMethod_ErrorCode(12800008); +} +impl InputMethod_ErrorCode { + /// @error The error code when input method client is detached. + pub const IME_ERR_DETACHED: InputMethod_ErrorCode = InputMethod_ErrorCode(12800009); +} +impl InputMethod_ErrorCode { + /// @error The error code when unexpected null pointer. + pub const IME_ERR_NULL_POINTER: InputMethod_ErrorCode = InputMethod_ErrorCode(12802000); +} +impl InputMethod_ErrorCode { + /// @error The error code when query failed. + pub const IME_ERR_QUERY_FAILED: InputMethod_ErrorCode = InputMethod_ErrorCode(12802001); +} +#[repr(transparent)] +/** @brief The value type of command data. + +@since 12*/ +#[derive(Clone, Hash, PartialEq, Eq)] +pub struct InputMethod_ErrorCode(pub ::core::ffi::c_uint); diff --git a/scripts/generate_bindings.sh b/scripts/generate_bindings.sh index 73e8caf..7989a3f 100755 --- a/scripts/generate_bindings.sh +++ b/scripts/generate_bindings.sh @@ -225,6 +225,8 @@ for abs_drawing_header in "${OHOS_SYSROOT_DIR}/usr/include/native_drawing"/* ; d additional_args_var_name="DRAWING_${rust_name}_ADDITIONAL_ARGS" if [[ ! -z "${!additional_args_var_name+x}" ]]; then echo "Have additional args!" + # Add [@] to the name, so that the indirect expansion via `${!name}` expands everything. + additional_args_var_name="${additional_args_var_name}[@]" rs_includes+=( "${!additional_args_var_name}" ) fi # We want to commit all generated files to version control, so we can easily see if something changed, @@ -247,7 +249,7 @@ for abs_drawing_header in "${OHOS_SYSROOT_DIR}/usr/include/native_drawing"/* ; d "${rs_includes[@]}" \ "${DRAWING_NOCOPY_ARGS[@]}" \ --output "${output_dir}/${rust_name}_api${OHOS_API_VERSION}${no_publish_suffix}.rs" \ - "${OHOS_SYSROOT_DIR}/usr/include/native_drawing/${drawing_header}" \ + "${abs_drawing_header}" \ -- "${BASE_CLANG_ARGS[@]}" \ -x c++ \ -include stdbool.h \ @@ -255,6 +257,66 @@ for abs_drawing_header in "${OHOS_SYSROOT_DIR}/usr/include/native_drawing"/* ; d -include stdint.h done +IME_text_editor_proxy_ADDITIONAL_ARGS=("--raw-line=use crate::private_command::InputMethod_PrivateCommand;") +IME_text_editor_proxy_ADDITIONAL_ARGS+=("--raw-line=use crate::text_config::InputMethod_TextConfig;") +IME_text_config_ADDITIONAL_ARGS=("--raw-line=use crate::text_avoid_info::InputMethod_TextAvoidInfo;") +IME_text_config_ADDITIONAL_ARGS+=("--raw-line=use crate::cursor_info::InputMethod_CursorInfo;") +IME_inputmethod_proxy_ADDITIONAL_ARGS=("--raw-line=use crate::private_command::InputMethod_PrivateCommand;") +IME_inputmethod_proxy_ADDITIONAL_ARGS+=("--raw-line=use crate::cursor_info::InputMethod_CursorInfo;") +IME_controller_ADDITIONAL_ARGS=("--raw-line=use crate::inputmethod_proxy::InputMethod_InputMethodProxy;") +IME_controller_ADDITIONAL_ARGS+=("--raw-line=use crate::text_editor_proxy::InputMethod_TextEditorProxy;") +IME_controller_ADDITIONAL_ARGS+=("--raw-line=use crate::attach_options::InputMethod_AttachOptions;") + +if (( OHOS_API_VERSION >= 12)); then + for abs_ime_header in "${OHOS_SYSROOT_DIR}/usr/include/inputmethod"/* ; do + ime_header=$(basename "${abs_ime_header}") + echo "Generating bindings for ${ime_header}" + rust_name=${ime_header#"inputmethod_"} + rust_name=${rust_name%"_capi.h"} + output_dir="${ROOT_DIR}/components/inputmethod/src/${rust_name}" + if [ ! -d "${output_dir}" ]; then + mkdir "${output_dir}" + fi + rs_includes=() + if [[ "${rust_name}" != "types" ]]; then + rs_includes+=("--raw-line=use crate::types::*;") + fi + additional_args_var_name="IME_${rust_name}_ADDITIONAL_ARGS" + if [[ ! -z "${!additional_args_var_name+x}" ]]; then + echo "Have additional args!" + additional_args_var_name="${additional_args_var_name}[@]" + rs_includes+=( "${!additional_args_var_name}" ) + fi + # We want to commit all generated files to version control, so we can easily see if something changed, + # when updating bindgen or the SDK patch release. + # However, we any split changes into incremental modules, and don't use any of the newer versions of the API + # besides the first one. If a binding was not introduced in the current api version, then we add a nopublish + # suffix, so we can exclude the file from cargo publish and save some download bandwidth. + no_publish_suffix="" + if [[ -f "${output_dir}/${rust_name}_api${PREVIOUS_API_VERSION}.rs" + || -f "${output_dir}/${rust_name}_api${PREVIOUS_API_VERSION}_nopublish.rs" ]]; then + no_publish_suffix="_nopublish" + fi + + # Some drawing headers are not valid C, so we need to use libclang in c++ mode. + # Note: block-listing `^std_.*` doesn't seem to work, perhaps the underscore replaces some other character. + bindgen "${BASE_BINDGEN_ARGS[@]}" \ + --default-enum-style=newtype \ + --allowlist-file ".*/${ime_header}$" \ + --no-recursive-allowlist \ + "${rs_includes[@]}" \ + --no-derive-copy \ + --no-derive-debug \ + --output "${output_dir}/${rust_name}_api${OHOS_API_VERSION}${no_publish_suffix}.rs" \ + "${abs_ime_header}" \ + -- "${BASE_CLANG_ARGS[@]}" \ + -x c++ \ + #-include stdbool.h \ + #-include stddef.h \ + #-include stdint.h + done +fi + cargo fmt fd -e rs . 'src/' --exec rustfmt fd -e rs . 'components' --exec rustfmt