mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-23 06:40:06 +00:00
输入法 ffi 桥接层代码函数名变更
Signed-off-by: PipiSummer <xiatian44@huawei.com> Change-Id: I2e570c8f48fa8cdd8d7e7bf2b6d0719815b6b82b
This commit is contained in:
parent
7b03e79976
commit
0d071e18ff
70
.vscode/settings.json
vendored
70
.vscode/settings.json
vendored
@ -1,70 +0,0 @@
|
|||||||
{
|
|
||||||
"files.associations": {
|
|
||||||
"algorithm": "cpp",
|
|
||||||
"array": "cpp",
|
|
||||||
"atomic": "cpp",
|
|
||||||
"bit": "cpp",
|
|
||||||
"*.tcc": "cpp",
|
|
||||||
"bitset": "cpp",
|
|
||||||
"cctype": "cpp",
|
|
||||||
"chrono": "cpp",
|
|
||||||
"cinttypes": "cpp",
|
|
||||||
"clocale": "cpp",
|
|
||||||
"cmath": "cpp",
|
|
||||||
"codecvt": "cpp",
|
|
||||||
"compare": "cpp",
|
|
||||||
"concepts": "cpp",
|
|
||||||
"condition_variable": "cpp",
|
|
||||||
"csignal": "cpp",
|
|
||||||
"cstdarg": "cpp",
|
|
||||||
"cstddef": "cpp",
|
|
||||||
"cstdint": "cpp",
|
|
||||||
"cstdio": "cpp",
|
|
||||||
"cstdlib": "cpp",
|
|
||||||
"cstring": "cpp",
|
|
||||||
"ctime": "cpp",
|
|
||||||
"cwchar": "cpp",
|
|
||||||
"cwctype": "cpp",
|
|
||||||
"deque": "cpp",
|
|
||||||
"list": "cpp",
|
|
||||||
"map": "cpp",
|
|
||||||
"set": "cpp",
|
|
||||||
"string": "cpp",
|
|
||||||
"unordered_map": "cpp",
|
|
||||||
"unordered_set": "cpp",
|
|
||||||
"vector": "cpp",
|
|
||||||
"exception": "cpp",
|
|
||||||
"functional": "cpp",
|
|
||||||
"iterator": "cpp",
|
|
||||||
"memory": "cpp",
|
|
||||||
"memory_resource": "cpp",
|
|
||||||
"numeric": "cpp",
|
|
||||||
"optional": "cpp",
|
|
||||||
"random": "cpp",
|
|
||||||
"ratio": "cpp",
|
|
||||||
"regex": "cpp",
|
|
||||||
"string_view": "cpp",
|
|
||||||
"system_error": "cpp",
|
|
||||||
"tuple": "cpp",
|
|
||||||
"type_traits": "cpp",
|
|
||||||
"utility": "cpp",
|
|
||||||
"fstream": "cpp",
|
|
||||||
"initializer_list": "cpp",
|
|
||||||
"iosfwd": "cpp",
|
|
||||||
"istream": "cpp",
|
|
||||||
"limits": "cpp",
|
|
||||||
"mutex": "cpp",
|
|
||||||
"new": "cpp",
|
|
||||||
"numbers": "cpp",
|
|
||||||
"ostream": "cpp",
|
|
||||||
"ranges": "cpp",
|
|
||||||
"semaphore": "cpp",
|
|
||||||
"sstream": "cpp",
|
|
||||||
"stdexcept": "cpp",
|
|
||||||
"stop_token": "cpp",
|
|
||||||
"streambuf": "cpp",
|
|
||||||
"thread": "cpp",
|
|
||||||
"typeinfo": "cpp",
|
|
||||||
"variant": "cpp"
|
|
||||||
}
|
|
||||||
}
|
|
2
BUILD.gn
2
BUILD.gn
@ -21,11 +21,11 @@ group("imf_packages") {
|
|||||||
"etc/init:inputmethodservice.cfg",
|
"etc/init:inputmethodservice.cfg",
|
||||||
"etc/para:inputmethod.para",
|
"etc/para:inputmethod.para",
|
||||||
"etc/para:inputmethod_para",
|
"etc/para:inputmethod_para",
|
||||||
|
"frameworks/cj:cj_inputmethod_ffi",
|
||||||
"frameworks/js/napi/inputmethodability:inputmethodengine",
|
"frameworks/js/napi/inputmethodability:inputmethodengine",
|
||||||
"frameworks/js/napi/inputmethodclient:inputmethod",
|
"frameworks/js/napi/inputmethodclient:inputmethod",
|
||||||
"frameworks/js/napi/inputmethodlist:inputmethodlist",
|
"frameworks/js/napi/inputmethodlist:inputmethodlist",
|
||||||
"frameworks/js/napi/keyboardpanelmanager:keyboardpanelmanager",
|
"frameworks/js/napi/keyboardpanelmanager:keyboardpanelmanager",
|
||||||
"frameworks/cj:cj_inputmethod_ffi",
|
|
||||||
"interfaces/inner_api/inputmethod_ability:inputmethod_ability",
|
"interfaces/inner_api/inputmethod_ability:inputmethod_ability",
|
||||||
"interfaces/inner_api/inputmethod_controller:inputmethod_client",
|
"interfaces/inner_api/inputmethod_controller:inputmethod_client",
|
||||||
"profile:inputmethod_inputmethod_sa_profiles",
|
"profile:inputmethod_inputmethod_sa_profiles",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2022-2023 Huawei Device Co., Ltd.
|
# Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
@ -42,17 +42,17 @@ ohos_shared_library("cj_inputmethod_ffi") {
|
|||||||
debug = false
|
debug = false
|
||||||
}
|
}
|
||||||
sources = [
|
sources = [
|
||||||
|
"src/cj_input_method_controller.cpp",
|
||||||
|
"src/cj_input_method_textchanged_listener.cpp",
|
||||||
"src/input_method_ffi.cpp",
|
"src/input_method_ffi.cpp",
|
||||||
"src/setting_listeners.cpp",
|
"src/setting_listeners.cpp",
|
||||||
"src/utils.cpp",
|
"src/utils.cpp",
|
||||||
"src/cj_input_method_controller.cpp",
|
|
||||||
"src/cj_input_method_textchanged_listener.cpp"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
configs = [ ":imf_config" ]
|
configs = [ ":imf_config" ]
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
"${inputmethod_path}/frameworks/js/napi/common:inputmethod_js_common",
|
"${inputmethod_path}/common:inputmethod_common",
|
||||||
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client",
|
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -60,15 +60,27 @@ private:
|
|||||||
static constexpr int32_t MAX_TIMEOUT = 2500;
|
static constexpr int32_t MAX_TIMEOUT = 2500;
|
||||||
void RegisterListener(int8_t type, int64_t id);
|
void RegisterListener(int8_t type, int64_t id);
|
||||||
void UnRegisterListener(int8_t type);
|
void UnRegisterListener(int8_t type);
|
||||||
|
void InitInsertText(int64_t id);
|
||||||
|
void InitDeleteRight(int64_t id);
|
||||||
|
void InitDeleteLeft(int64_t id);
|
||||||
|
void InitSendKeyboardStatus(int64_t id);
|
||||||
|
void InitSendFunctionKey(int64_t id);
|
||||||
|
void InitMoveCursor(int64_t id);
|
||||||
|
void InitHandleExtendAction(int64_t id);
|
||||||
|
void InitGetLeftText(int64_t id);
|
||||||
|
void InitGetRightText(int64_t id);
|
||||||
|
void InitSelectByRange(int64_t id);
|
||||||
|
void InitSelectByMovement(int64_t id);
|
||||||
|
void InitGetTextIndexAtCursor(int64_t id);
|
||||||
std::recursive_mutex mutex_;
|
std::recursive_mutex mutex_;
|
||||||
std::function<void(int32_t start, int32_t end)> onSelectByRange;
|
std::function<void(Range)> onSelectByRange;
|
||||||
std::function<void(int32_t)> onSelectByMovement;
|
std::function<void(int32_t)> onSelectByMovement;
|
||||||
std::function<void(const char* text)> insertText;
|
std::function<void(const char* text)> insertText;
|
||||||
std::function<void(int32_t length)> deleteRight;
|
std::function<void(int32_t length)> deleteRight;
|
||||||
std::function<void(int32_t length)> deleteLeft;
|
std::function<void(int32_t length)> deleteLeft;
|
||||||
std::function<void(int64_t status)> sendKeyboardStatus;
|
std::function<void(int32_t status)> sendKeyboardStatus;
|
||||||
std::function<void(int64_t functionKey)> sendFunctionKey;
|
std::function<void(int32_t functionKey)> sendFunctionKey;
|
||||||
std::function<void(int64_t direction)> moveCursor;
|
std::function<void(int32_t direction)> moveCursor;
|
||||||
std::function<void(int32_t action)> handleExtendAction;
|
std::function<void(int32_t action)> handleExtendAction;
|
||||||
std::function<char*(int32_t number)> getLeftText;
|
std::function<char*(int32_t number)> getLeftText;
|
||||||
std::function<char*(int32_t number)> getRightText;
|
std::function<char*(int32_t number)> getRightText;
|
||||||
|
@ -19,34 +19,35 @@
|
|||||||
#include "input_method_ffi_structs.h"
|
#include "input_method_ffi_structs.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
FFI_EXPORT int32_t CJ_GetDefaultInputMethod(CInputMethodProperty &props);
|
FFI_EXPORT int32_t FfiInputMethodGetDefaultInputMethod(CInputMethodProperty &props);
|
||||||
FFI_EXPORT int32_t CJ_GetCurrentInputMethod(CInputMethodProperty &props);
|
FFI_EXPORT int32_t FfiInputMethodGetCurrentInputMethod(CInputMethodProperty &props);
|
||||||
FFI_EXPORT int32_t CJ_SwitchInputMethod(bool &result, CInputMethodProperty props);
|
FFI_EXPORT int32_t FfiInputMethodSwitchInputMethod(bool &result, CInputMethodProperty props);
|
||||||
FFI_EXPORT int32_t CJ_SwitchCurrentInputMethodSubtype(bool &result, CInputMethodSubtype target);
|
FFI_EXPORT int32_t FfiInputMethodSwitchCurrentInputMethodSubtype(bool &result, CInputMethodSubtype target);
|
||||||
FFI_EXPORT int32_t CJ_GetCurrentInputMethodSubtype(CInputMethodSubtype &props);
|
FFI_EXPORT int32_t FfiInputMethodGetCurrentInputMethodSubtype(CInputMethodSubtype &props);
|
||||||
FFI_EXPORT int32_t CJ_SwitchCurrentInputMethodAndSubtype(bool &result, CInputMethodProperty target, CInputMethodSubtype subtype);
|
FFI_EXPORT int32_t FfiInputMethodSwitchCurrentInputMethodAndSubtype(bool &result, CInputMethodProperty target,
|
||||||
FFI_EXPORT int32_t CJ_GetSystemInputMethodConfigAbility(CElementName &elem);
|
CInputMethodSubtype subtype);
|
||||||
FFI_EXPORT RetInputMethodSubtype CJ_ListInputMethodSubtype(CInputMethodProperty props);
|
FFI_EXPORT int32_t FfiInputMethodGetSystemInputMethodConfigAbility(CElementName &elem);
|
||||||
FFI_EXPORT RetInputMethodSubtype CJ_ListCurrentInputMethodSubtype();
|
FFI_EXPORT RetInputMethodSubtype FfiInputMethodSettingListInputMethodSubtype(CInputMethodProperty props);
|
||||||
FFI_EXPORT RetInputMethodProperty CJ_GetInputMethods(bool enable);
|
FFI_EXPORT RetInputMethodSubtype FfiInputMethodSettingListCurrentInputMethodSubtype();
|
||||||
FFI_EXPORT RetInputMethodProperty CJ_GetAllInputMethods();
|
FFI_EXPORT RetInputMethodProperty FfiInputMethodSettingGetInputMethods(bool enable);
|
||||||
FFI_EXPORT int32_t CJ_InputMethodSettingOn(uint32_t type, void (*func)(CInputMethodProperty, CInputMethodSubtype));
|
FFI_EXPORT RetInputMethodProperty FfiInputMethodSettingGetAllInputMethods();
|
||||||
FFI_EXPORT int32_t CJ_InputMethodSettingOff(uint32_t type);
|
FFI_EXPORT int32_t FfiInputMethodSettingOn(uint32_t type, void (*func)(CInputMethodProperty, CInputMethodSubtype));
|
||||||
FFI_EXPORT int32_t CJ_ShowOptionalInputMethods(bool& result);
|
FFI_EXPORT int32_t FfiInputMethodSettingOff(uint32_t type);
|
||||||
FFI_EXPORT int32_t CJ_InputMethodControllerOn(int8_t type, int64_t id);
|
FFI_EXPORT int32_t FfiInputMethodSettingShowOptionalInputMethods(bool& result);
|
||||||
FFI_EXPORT int32_t CJ_InputMethodControllerOff(int8_t type);
|
FFI_EXPORT int32_t FfiInputMethodControllerOn(int8_t type, int64_t id);
|
||||||
|
FFI_EXPORT int32_t FfiInputMethodControllerOff(int8_t type);
|
||||||
|
|
||||||
FFI_EXPORT int32_t OHOSFfiAttach(bool showKeyboard, CTextConfig txtCfg);
|
FFI_EXPORT int32_t FfiInputMethodControllerAttach(bool showKeyboard, CTextConfig txtCfg);
|
||||||
FFI_EXPORT int32_t OHOSFfiDetach();
|
FFI_EXPORT int32_t FfiInputMethodControllerDetach();
|
||||||
FFI_EXPORT int32_t OHOSFfiShowTextInput();
|
FFI_EXPORT int32_t FfiInputMethodControllerShowTextInput();
|
||||||
FFI_EXPORT int32_t OHOSFfiHideTextInput();
|
FFI_EXPORT int32_t FfiInputMethodControllerHideTextInput();
|
||||||
FFI_EXPORT int32_t OHOSFfiSetCallingWindow(uint32_t windowId);
|
FFI_EXPORT int32_t FfiInputMethodControllerSetCallingWindow(uint32_t windowId);
|
||||||
FFI_EXPORT int32_t OHOSFfiUpdateCursor(CCursorInfo cursor);
|
FFI_EXPORT int32_t FfiInputMethodControllerUpdateCursor(CCursorInfo cursor);
|
||||||
FFI_EXPORT int32_t OHOSFfiChangeSelection(char *text, int32_t start, int32_t end);
|
FFI_EXPORT int32_t FfiInputMethodControllerChangeSelection(char *text, int32_t start, int32_t end);
|
||||||
FFI_EXPORT int32_t OHOSFfiUpdateAttribute(CInputAttribute inputAttribute);
|
FFI_EXPORT int32_t FfiInputMethodControllerUpdateAttribute(CInputAttribute inputAttribute);
|
||||||
FFI_EXPORT int32_t OHOSFfiShowSoftKeyboard();
|
FFI_EXPORT int32_t FfiInputMethodControllerShowSoftKeyboard();
|
||||||
FFI_EXPORT int32_t OHOSFfiHideSoftKeyboard();
|
FFI_EXPORT int32_t FfiInputMethodControllerHideSoftKeyboard();
|
||||||
FFI_EXPORT int32_t OHOSFfiStopInputSession();
|
FFI_EXPORT int32_t FfiInputMethodControllerStopInputSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // INPUT_METHOD_FFI_H
|
#endif // INPUT_METHOD_FFI_H
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
namespace OHOS::MiscServices {
|
namespace OHOS::MiscServices {
|
||||||
class CJGetInputMethodSetting : public ImeEventListener {
|
class CJGetInputMethodSetting : public ImeEventListener {
|
||||||
public :
|
public:
|
||||||
CJGetInputMethodSetting() = default;
|
CJGetInputMethodSetting() = default;
|
||||||
~CJGetInputMethodSetting() = default;
|
~CJGetInputMethodSetting() = default;
|
||||||
static std::shared_ptr<CJGetInputMethodSetting> GetIMSInstance();
|
static std::shared_ptr<CJGetInputMethodSetting> GetIMSInstance();
|
||||||
|
@ -39,6 +39,7 @@ const int8_t GET_LEFT_TEXT = 7;
|
|||||||
const int8_t GET_RIGHT_TEXT = 8;
|
const int8_t GET_RIGHT_TEXT = 8;
|
||||||
const int8_t GET_TEXT_INDEX = 9;
|
const int8_t GET_TEXT_INDEX = 9;
|
||||||
const int8_t SELECT_BY_MOVEMENT = 10;
|
const int8_t SELECT_BY_MOVEMENT = 10;
|
||||||
|
const int8_t SELECT_BY_RANGE = 11;
|
||||||
|
|
||||||
std::shared_ptr<CjInputMethodController> CjInputMethodController::GetInstance()
|
std::shared_ptr<CjInputMethodController> CjInputMethodController::GetInstance()
|
||||||
{
|
{
|
||||||
@ -56,7 +57,7 @@ std::shared_ptr<CjInputMethodController> CjInputMethodController::GetInstance()
|
|||||||
int32_t CjInputMethodController::Attach(const CTextConfig &txtCfg, bool showKeyboard)
|
int32_t CjInputMethodController::Attach(const CTextConfig &txtCfg, bool showKeyboard)
|
||||||
{
|
{
|
||||||
auto textListener = CjInputMethodTextChangedListener::GetInstance();
|
auto textListener = CjInputMethodTextChangedListener::GetInstance();
|
||||||
if (!textListener) {
|
if (textListener == nullptr) {
|
||||||
IMSA_HILOGE("failed to create CjInputMethodTextChangedListener!");
|
IMSA_HILOGE("failed to create CjInputMethodTextChangedListener!");
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
@ -79,7 +80,7 @@ int32_t CjInputMethodController::Attach(const CTextConfig &txtCfg, bool showKeyb
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto controller = InputMethodController::GetInstance();
|
auto controller = InputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
return controller->Attach(textListener, showKeyboard, textCfg);
|
return controller->Attach(textListener, showKeyboard, textCfg);
|
||||||
@ -88,7 +89,7 @@ int32_t CjInputMethodController::Attach(const CTextConfig &txtCfg, bool showKeyb
|
|||||||
int32_t CjInputMethodController::Detach()
|
int32_t CjInputMethodController::Detach()
|
||||||
{
|
{
|
||||||
auto controller = InputMethodController::GetInstance();
|
auto controller = InputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
return controller->Close();
|
return controller->Close();
|
||||||
@ -97,7 +98,7 @@ int32_t CjInputMethodController::Detach()
|
|||||||
int32_t CjInputMethodController::ShowTextInput()
|
int32_t CjInputMethodController::ShowTextInput()
|
||||||
{
|
{
|
||||||
auto controller = InputMethodController::GetInstance();
|
auto controller = InputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
return controller->ShowTextInput();
|
return controller->ShowTextInput();
|
||||||
@ -106,7 +107,7 @@ int32_t CjInputMethodController::ShowTextInput()
|
|||||||
int32_t CjInputMethodController::HideTextInput()
|
int32_t CjInputMethodController::HideTextInput()
|
||||||
{
|
{
|
||||||
auto controller = InputMethodController::GetInstance();
|
auto controller = InputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
return controller->HideTextInput();
|
return controller->HideTextInput();
|
||||||
@ -115,7 +116,7 @@ int32_t CjInputMethodController::HideTextInput()
|
|||||||
int32_t CjInputMethodController::SetCallingWindow(uint32_t windowId)
|
int32_t CjInputMethodController::SetCallingWindow(uint32_t windowId)
|
||||||
{
|
{
|
||||||
auto controller = InputMethodController::GetInstance();
|
auto controller = InputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
return controller->SetCallingWindow(windowId);
|
return controller->SetCallingWindow(windowId);
|
||||||
@ -124,7 +125,7 @@ int32_t CjInputMethodController::SetCallingWindow(uint32_t windowId)
|
|||||||
int32_t CjInputMethodController::UpdateCursor(const CCursorInfo &cursor)
|
int32_t CjInputMethodController::UpdateCursor(const CCursorInfo &cursor)
|
||||||
{
|
{
|
||||||
auto controller = InputMethodController::GetInstance();
|
auto controller = InputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
CursorInfo cursorInfo = {
|
CursorInfo cursorInfo = {
|
||||||
@ -139,7 +140,7 @@ int32_t CjInputMethodController::UpdateCursor(const CCursorInfo &cursor)
|
|||||||
int32_t CjInputMethodController::ChangeSelection(const std::string &text, int32_t start, int32_t end)
|
int32_t CjInputMethodController::ChangeSelection(const std::string &text, int32_t start, int32_t end)
|
||||||
{
|
{
|
||||||
auto controller = InputMethodController::GetInstance();
|
auto controller = InputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
|
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
|
||||||
@ -150,7 +151,7 @@ int32_t CjInputMethodController::ChangeSelection(const std::string &text, int32_
|
|||||||
int32_t CjInputMethodController::UpdateAttribute(const CInputAttribute &inputAttribute)
|
int32_t CjInputMethodController::UpdateAttribute(const CInputAttribute &inputAttribute)
|
||||||
{
|
{
|
||||||
auto controller = InputMethodController::GetInstance();
|
auto controller = InputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
Configuration config = Configuration();
|
Configuration config = Configuration();
|
||||||
@ -162,7 +163,7 @@ int32_t CjInputMethodController::UpdateAttribute(const CInputAttribute &inputAtt
|
|||||||
int32_t CjInputMethodController::ShowSoftKeyboard()
|
int32_t CjInputMethodController::ShowSoftKeyboard()
|
||||||
{
|
{
|
||||||
auto controller = InputMethodController::GetInstance();
|
auto controller = InputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
return controller->ShowSoftKeyboard();
|
return controller->ShowSoftKeyboard();
|
||||||
@ -171,7 +172,7 @@ int32_t CjInputMethodController::ShowSoftKeyboard()
|
|||||||
int32_t CjInputMethodController::HideSoftKeyboard()
|
int32_t CjInputMethodController::HideSoftKeyboard()
|
||||||
{
|
{
|
||||||
auto controller = InputMethodController::GetInstance();
|
auto controller = InputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
return controller->HideSoftKeyboard();
|
return controller->HideSoftKeyboard();
|
||||||
@ -180,7 +181,7 @@ int32_t CjInputMethodController::HideSoftKeyboard()
|
|||||||
int32_t CjInputMethodController::StopInputSession()
|
int32_t CjInputMethodController::StopInputSession()
|
||||||
{
|
{
|
||||||
auto controller = InputMethodController::GetInstance();
|
auto controller = InputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
return controller->StopInputSession();
|
return controller->StopInputSession();
|
||||||
@ -190,90 +191,44 @@ void CjInputMethodController::RegisterListener(int8_t type, int64_t id)
|
|||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case INSERT_TEXT: {
|
case INSERT_TEXT:
|
||||||
auto callback = reinterpret_cast<void(*)(const char*)>(id);
|
InitInsertText(id);
|
||||||
insertText = [lambda = CJLambda::Create(callback)](const char* text) -> void {
|
|
||||||
lambda(text);
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
case DELETE_LEFT:
|
||||||
case DELETE_LEFT: {
|
InitDeleteRight(id);
|
||||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
|
||||||
deleteLeft = [lambda = CJLambda::Create(callback)](int32_t length) -> void {
|
|
||||||
lambda(length);
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
case DELETE_RIGHT:
|
||||||
case DELETE_RIGHT: {
|
InitDeleteLeft(id);
|
||||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
|
||||||
deleteRight = [lambda = CJLambda::Create(callback)](int32_t length) -> void {
|
|
||||||
lambda(length);
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
case SEND_KEYBOARD_STATUS:
|
||||||
case SEND_KEYBOARD_STATUS: {
|
InitSendKeyboardStatus(id);
|
||||||
auto callback = reinterpret_cast<void(*)(int64_t)>(id);
|
|
||||||
sendKeyboardStatus = [lambda = CJLambda::Create(callback)](int64_t status) -> void {
|
|
||||||
lambda(status);
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
case SEND_FUNCTION_KEY:
|
||||||
case SEND_FUNCTION_KEY: {
|
InitSendFunctionKey(id);
|
||||||
auto callback = reinterpret_cast<void(*)(int64_t)>(id);
|
|
||||||
sendFunctionKey = [lambda = CJLambda::Create(callback)](int64_t functionKey) -> void {
|
|
||||||
lambda(functionKey);
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
case MOVE_CURSOR:
|
||||||
case MOVE_CURSOR: {
|
InitMoveCursor(id);
|
||||||
auto callback = reinterpret_cast<void(*)(int64_t)>(id);
|
|
||||||
moveCursor = [lambda = CJLambda::Create(callback)](int64_t direction) -> void {
|
|
||||||
lambda(direction);
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
case HANDLE_EXTEND_ACTION:
|
||||||
case HANDLE_EXTEND_ACTION: {
|
InitHandleExtendAction(id);
|
||||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
|
||||||
handleExtendAction = [lambda = CJLambda::Create(callback)](int32_t action) -> void {
|
|
||||||
lambda(action);
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
case GET_LEFT_TEXT:
|
||||||
case GET_LEFT_TEXT: {
|
InitGetLeftText(id);
|
||||||
auto callback = reinterpret_cast<char*(*)(int32_t)>(id);
|
|
||||||
getLeftText = [lambda = CJLambda::Create(callback)](int32_t number) -> char* {
|
|
||||||
return lambda(number);
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
case GET_RIGHT_TEXT:
|
||||||
case GET_RIGHT_TEXT: {
|
InitGetRightText(id);
|
||||||
auto callback = reinterpret_cast<char*(*)(int32_t)>(id);
|
|
||||||
getRightText = [lambda = CJLambda::Create(callback)](int32_t number) -> char* {
|
|
||||||
return lambda(number);
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
case GET_TEXT_INDEX:
|
||||||
case GET_TEXT_INDEX: {
|
InitGetTextIndexAtCursor(id);
|
||||||
auto callback = reinterpret_cast<int32_t(*)()>(id);
|
|
||||||
getTextIndexAtCursor = [lambda = CJLambda::Create(callback)](void) -> int32_t {
|
|
||||||
return lambda();
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
case SELECT_BY_MOVEMENT:
|
||||||
case SELECT_BY_MOVEMENT: {
|
InitSelectByMovement(id);
|
||||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
|
||||||
onSelectByMovement = [lambda = CJLambda::Create(callback)](int32_t direction) -> void {
|
|
||||||
lambda(direction);
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
case SELECT_BY_RANGE:
|
||||||
default: {
|
InitSelectByRange(id);
|
||||||
auto callback = reinterpret_cast<void(*)(int32_t, int32_t)>(id);
|
|
||||||
onSelectByRange = [lambda = CJLambda::Create(callback)](int32_t start, int32_t end) -> void {
|
|
||||||
lambda(start, end);
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,16 +269,18 @@ void CjInputMethodController::UnRegisterListener(int8_t type)
|
|||||||
case SELECT_BY_MOVEMENT:
|
case SELECT_BY_MOVEMENT:
|
||||||
onSelectByMovement = nullptr;
|
onSelectByMovement = nullptr;
|
||||||
break;
|
break;
|
||||||
default:
|
case SELECT_BY_RANGE:
|
||||||
onSelectByRange = nullptr;
|
onSelectByRange = nullptr;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CjInputMethodController::Subscribe(int8_t type, int64_t id)
|
int32_t CjInputMethodController::Subscribe(int8_t type, int64_t id)
|
||||||
{
|
{
|
||||||
auto controller = CjInputMethodController::GetInstance();
|
auto controller = CjInputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
controller->RegisterListener(type, id);
|
controller->RegisterListener(type, id);
|
||||||
@ -333,7 +290,7 @@ int32_t CjInputMethodController::Subscribe(int8_t type, int64_t id)
|
|||||||
int32_t CjInputMethodController::Unsubscribe(int8_t type)
|
int32_t CjInputMethodController::Unsubscribe(int8_t type)
|
||||||
{
|
{
|
||||||
auto controller = CjInputMethodController::GetInstance();
|
auto controller = CjInputMethodController::GetInstance();
|
||||||
if (!controller) {
|
if (controller == nullptr) {
|
||||||
return ERR_NO_MEMORY;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
controller->UnRegisterListener(type);
|
controller->UnRegisterListener(type);
|
||||||
@ -342,21 +299,22 @@ int32_t CjInputMethodController::Unsubscribe(int8_t type)
|
|||||||
|
|
||||||
void CjInputMethodController::OnSelectByRange(int32_t start, int32_t end)
|
void CjInputMethodController::OnSelectByRange(int32_t start, int32_t end)
|
||||||
{
|
{
|
||||||
if (onSelelctByRange == nullptr) {
|
if (onSelectByRange == nullptr) {
|
||||||
IMSA_HILOGI("onSelelctByRange null");
|
IMSA_HILOGD("onSelelctByRange null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMSA_HILOGI("onSelelctByRange runs");
|
IMSA_HILOGD("onSelelctByRange runs");
|
||||||
return onSelectByRange(start, end);
|
Range range = { .start = start, .end = end };
|
||||||
|
return onSelectByRange(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CjInputMethodController::OnSelectByMovement(int32_t direction)
|
void CjInputMethodController::OnSelectByMovement(int32_t direction)
|
||||||
{
|
{
|
||||||
if (onSelectByMovement == nullptr) {
|
if (onSelectByMovement == nullptr) {
|
||||||
IMSA_HILOGI("onSelectByMovement null");
|
IMSA_HILOGD("onSelectByMovement null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMSA_HILOGI("onSelectByMovement runs");
|
IMSA_HILOGD("onSelectByMovement runs");
|
||||||
return onSelectByMovement(direction);
|
return onSelectByMovement(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,10 +326,11 @@ void CjInputMethodController::InsertText(const std::u16string &text)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (insertText == nullptr) {
|
if (insertText == nullptr) {
|
||||||
IMSA_HILOGI("insertText null");
|
IMSA_HILOGD("insertText null");
|
||||||
|
free(insertTxt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMSA_HILOGI("insertText runs");
|
IMSA_HILOGD("insertText runs");
|
||||||
insertText(insertTxt);
|
insertText(insertTxt);
|
||||||
free(insertTxt);
|
free(insertTxt);
|
||||||
return;
|
return;
|
||||||
@ -380,10 +339,10 @@ void CjInputMethodController::InsertText(const std::u16string &text)
|
|||||||
void CjInputMethodController::DeleteRight(int32_t length)
|
void CjInputMethodController::DeleteRight(int32_t length)
|
||||||
{
|
{
|
||||||
if (deleteRight == nullptr) {
|
if (deleteRight == nullptr) {
|
||||||
IMSA_HILOGI("deleteRight null");
|
IMSA_HILOGD("deleteRight null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMSA_HILOGI("deleteRight runs");
|
IMSA_HILOGD("deleteRight runs");
|
||||||
deleteRight(length);
|
deleteRight(length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -391,10 +350,10 @@ void CjInputMethodController::DeleteRight(int32_t length)
|
|||||||
void CjInputMethodController::DeleteLeft(int32_t length)
|
void CjInputMethodController::DeleteLeft(int32_t length)
|
||||||
{
|
{
|
||||||
if (deleteLeft == nullptr) {
|
if (deleteLeft == nullptr) {
|
||||||
IMSA_HILOGI("deleteLeft null");
|
IMSA_HILOGD("deleteLeft null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMSA_HILOGI("deleteLeft runs");
|
IMSA_HILOGD("deleteLeft runs");
|
||||||
deleteLeft(length);
|
deleteLeft(length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -402,11 +361,11 @@ void CjInputMethodController::DeleteLeft(int32_t length)
|
|||||||
void CjInputMethodController::SendKeyboardStatus(const KeyboardStatus &status)
|
void CjInputMethodController::SendKeyboardStatus(const KeyboardStatus &status)
|
||||||
{
|
{
|
||||||
if (sendKeyboardStatus == nullptr) {
|
if (sendKeyboardStatus == nullptr) {
|
||||||
IMSA_HILOGI("sendKeyboardStatus null");
|
IMSA_HILOGD("sendKeyboardStatus null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMSA_HILOGI("sendKeyboardStatus runs");
|
IMSA_HILOGD("sendKeyboardStatus runs");
|
||||||
auto statusNum = static_cast<int64_t>(status);
|
auto statusNum = static_cast<int32_t>(status);
|
||||||
sendKeyboardStatus(statusNum);
|
sendKeyboardStatus(statusNum);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -414,11 +373,11 @@ void CjInputMethodController::SendKeyboardStatus(const KeyboardStatus &status)
|
|||||||
void CjInputMethodController::SendFunctionKey(const FunctionKey &functionKey)
|
void CjInputMethodController::SendFunctionKey(const FunctionKey &functionKey)
|
||||||
{
|
{
|
||||||
if (sendFunctionKey == nullptr) {
|
if (sendFunctionKey == nullptr) {
|
||||||
IMSA_HILOGI("sendFunctionKey null");
|
IMSA_HILOGD("sendFunctionKey null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMSA_HILOGI("sendFunctionKey runs");
|
IMSA_HILOGD("sendFunctionKey runs");
|
||||||
auto type = static_cast<int64_t>(functionKey.GetEnterKeyType());
|
auto type = static_cast<int32_t>(functionKey.GetEnterKeyType());
|
||||||
sendFunctionKey(type);
|
sendFunctionKey(type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -426,11 +385,11 @@ void CjInputMethodController::SendFunctionKey(const FunctionKey &functionKey)
|
|||||||
void CjInputMethodController::MoveCursor(const Direction direction)
|
void CjInputMethodController::MoveCursor(const Direction direction)
|
||||||
{
|
{
|
||||||
if (moveCursor == nullptr) {
|
if (moveCursor == nullptr) {
|
||||||
IMSA_HILOGI("moveCursor null");
|
IMSA_HILOGD("moveCursor null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMSA_HILOGI("moveCursor runs");
|
IMSA_HILOGD("moveCursor runs");
|
||||||
auto dir = static_cast<int64_t>(direction);
|
auto dir = static_cast<int32_t>(direction);
|
||||||
moveCursor(dir);
|
moveCursor(dir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -438,10 +397,10 @@ void CjInputMethodController::MoveCursor(const Direction direction)
|
|||||||
void CjInputMethodController::HandleExtendAction(int32_t action)
|
void CjInputMethodController::HandleExtendAction(int32_t action)
|
||||||
{
|
{
|
||||||
if (handleExtendAction == nullptr) {
|
if (handleExtendAction == nullptr) {
|
||||||
IMSA_HILOGI("handleExtendAction null");
|
IMSA_HILOGD("handleExtendAction null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMSA_HILOGI("handleExtendAction runs");
|
IMSA_HILOGD("handleExtendAction runs");
|
||||||
handleExtendAction(action);
|
handleExtendAction(action);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -449,10 +408,10 @@ void CjInputMethodController::HandleExtendAction(int32_t action)
|
|||||||
std::u16string CjInputMethodController::GetLeftText(int32_t number)
|
std::u16string CjInputMethodController::GetLeftText(int32_t number)
|
||||||
{
|
{
|
||||||
if (getLeftText == nullptr) {
|
if (getLeftText == nullptr) {
|
||||||
IMSA_HILOGI("getLeftText null");
|
IMSA_HILOGD("getLeftText null");
|
||||||
return u"";
|
return u"";
|
||||||
}
|
}
|
||||||
IMSA_HILOGI("getLeftText runs");
|
IMSA_HILOGD("getLeftText runs");
|
||||||
char *text = getLeftText(number);
|
char *text = getLeftText(number);
|
||||||
auto ret = Str8ToStr16(std::string(text));
|
auto ret = Str8ToStr16(std::string(text));
|
||||||
free(text);
|
free(text);
|
||||||
@ -462,10 +421,10 @@ std::u16string CjInputMethodController::GetLeftText(int32_t number)
|
|||||||
std::u16string CjInputMethodController::GetRightText(int32_t number)
|
std::u16string CjInputMethodController::GetRightText(int32_t number)
|
||||||
{
|
{
|
||||||
if (getRightText == nullptr) {
|
if (getRightText == nullptr) {
|
||||||
IMSA_HILOGI("getRightText null");
|
IMSA_HILOGD("getRightText null");
|
||||||
return u"";
|
return u"";
|
||||||
}
|
}
|
||||||
IMSA_HILOGI("getRightText runs");
|
IMSA_HILOGD("getRightText runs");
|
||||||
char *text = getRightText(number);
|
char *text = getRightText(number);
|
||||||
auto ret = Str8ToStr16(std::string(text));
|
auto ret = Str8ToStr16(std::string(text));
|
||||||
free(text);
|
free(text);
|
||||||
@ -475,11 +434,108 @@ std::u16string CjInputMethodController::GetRightText(int32_t number)
|
|||||||
int32_t CjInputMethodController::GetTextIndexAtCursor()
|
int32_t CjInputMethodController::GetTextIndexAtCursor()
|
||||||
{
|
{
|
||||||
if (getTextIndexAtCursor == nullptr) {
|
if (getTextIndexAtCursor == nullptr) {
|
||||||
IMSA_HILOGI("getTextIndexAtCursor null");
|
IMSA_HILOGD("getTextIndexAtCursor null");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
IMSA_HILOGI("getTextIndexAtCursor runs");
|
IMSA_HILOGD("getTextIndexAtCursor runs");
|
||||||
return getTextIndexAtCursor();
|
return getTextIndexAtCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CjInputMethodController::InitInsertText(int64_t id)
|
||||||
|
{
|
||||||
|
auto callback = reinterpret_cast<void(*)(const char*)>(id);
|
||||||
|
insertText = [lambda = CJLambda::Create(callback)](const char* text) -> void {
|
||||||
|
lambda(text);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CjInputMethodController::InitDeleteRight(int64_t id)
|
||||||
|
{
|
||||||
|
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||||
|
deleteLeft = [lambda = CJLambda::Create(callback)](int32_t length) -> void {
|
||||||
|
lambda(length);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CjInputMethodController::InitDeleteLeft(int64_t id)
|
||||||
|
{
|
||||||
|
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||||
|
deleteRight = [lambda = CJLambda::Create(callback)](int32_t length) -> void {
|
||||||
|
lambda(length);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CjInputMethodController::InitSendKeyboardStatus(int64_t id)
|
||||||
|
{
|
||||||
|
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||||
|
sendKeyboardStatus = [lambda = CJLambda::Create(callback)](int32_t status) -> void {
|
||||||
|
lambda(status);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CjInputMethodController::InitSendFunctionKey(int64_t id)
|
||||||
|
{
|
||||||
|
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||||
|
sendFunctionKey = [lambda = CJLambda::Create(callback)](int32_t functionKey) -> void {
|
||||||
|
lambda(functionKey);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CjInputMethodController::InitMoveCursor(int64_t id)
|
||||||
|
{
|
||||||
|
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||||
|
moveCursor = [lambda = CJLambda::Create(callback)](int32_t direction) -> void {
|
||||||
|
lambda(direction);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CjInputMethodController::InitHandleExtendAction(int64_t id)
|
||||||
|
{
|
||||||
|
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||||
|
handleExtendAction = [lambda = CJLambda::Create(callback)](int32_t action) -> void {
|
||||||
|
lambda(action);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CjInputMethodController::InitGetLeftText(int64_t id)
|
||||||
|
{
|
||||||
|
auto callback = reinterpret_cast<char*(*)(int32_t)>(id);
|
||||||
|
getLeftText = [lambda = CJLambda::Create(callback)](int32_t number) -> char* {
|
||||||
|
return lambda(number);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CjInputMethodController::InitGetRightText(int64_t id)
|
||||||
|
{
|
||||||
|
auto callback = reinterpret_cast<char*(*)(int32_t)>(id);
|
||||||
|
getRightText = [lambda = CJLambda::Create(callback)](int32_t number) -> char* {
|
||||||
|
return lambda(number);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CjInputMethodController::InitGetTextIndexAtCursor(int64_t id)
|
||||||
|
{
|
||||||
|
auto callback = reinterpret_cast<int32_t(*)()>(id);
|
||||||
|
getTextIndexAtCursor = [lambda = CJLambda::Create(callback)](void) -> int32_t {
|
||||||
|
return lambda();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CjInputMethodController::InitSelectByMovement(int64_t id)
|
||||||
|
{
|
||||||
|
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||||
|
onSelectByMovement = [lambda = CJLambda::Create(callback)](int32_t direction) -> void {
|
||||||
|
lambda(direction);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CjInputMethodController::InitSelectByRange(int64_t id)
|
||||||
|
{
|
||||||
|
auto callback = reinterpret_cast<void(*)(Range)>(id);
|
||||||
|
onSelectByRange = [lambda = CJLambda::Create(callback)](Range range) -> void {
|
||||||
|
lambda(range);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace MiscServices
|
} // namespace MiscServices
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
@ -22,84 +22,108 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
namespace OHOS::MiscServices
|
namespace OHOS::MiscServices {
|
||||||
|
extern "C" {
|
||||||
|
int32_t FfiInputMethodGetDefaultInputMethod(CInputMethodProperty &props)
|
||||||
{
|
{
|
||||||
extern "C"
|
auto ctrl = InputMethodController::GetInstance();
|
||||||
{
|
if (ctrl == nullptr) {
|
||||||
int32_t CJ_GetDefaultInputMethod(CInputMethodProperty &props)
|
return ERR_NO_MEMORY;
|
||||||
{
|
}
|
||||||
std::shared_ptr<Property> property;
|
std::shared_ptr<Property> property;
|
||||||
int32_t ret = InputMethodController::GetInstance()->GetDefaultInputMethod(property);
|
int32_t ret = ctrl->GetDefaultInputMethod(property);
|
||||||
if (property == nullptr)
|
if (property == nullptr) {
|
||||||
{
|
|
||||||
IMSA_HILOGE("default input method is nullptr!");
|
IMSA_HILOGE("default input method is nullptr!");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
Utils::InputMethodProperty2C(props, *property);
|
Utils::InputMethodProperty2C(props, *property);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CJ_GetCurrentInputMethod(CInputMethodProperty &props)
|
int32_t FfiInputMethodGetCurrentInputMethod(CInputMethodProperty &props)
|
||||||
{
|
{
|
||||||
std::shared_ptr<Property> property = InputMethodController::GetInstance()->GetCurrentInputMethod();
|
auto ctrl = InputMethodController::GetInstance();
|
||||||
if (property == nullptr)
|
if (ctrl == nullptr) {
|
||||||
{
|
return ERR_NO_MEMORY;
|
||||||
|
}
|
||||||
|
std::shared_ptr<Property> property = ctrl->GetCurrentInputMethod();
|
||||||
|
if (property == nullptr) {
|
||||||
IMSA_HILOGE("current input method is nullptr!");
|
IMSA_HILOGE("current input method is nullptr!");
|
||||||
return 0;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
Utils::InputMethodProperty2C(props, *property);
|
Utils::InputMethodProperty2C(props, *property);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CJ_SwitchInputMethod(bool &result, CInputMethodProperty props)
|
int32_t FfiInputMethodSwitchInputMethod(bool &result, CInputMethodProperty props)
|
||||||
{
|
{
|
||||||
InputMethodSyncTrace tracer("CJInputMethod_SwitchInputMethod");
|
InputMethodSyncTrace tracer("CJInputMethod_SwitchInputMethod");
|
||||||
|
auto ctrl = InputMethodController::GetInstance();
|
||||||
|
if (ctrl == nullptr) {
|
||||||
|
return ERR_NO_MEMORY;
|
||||||
|
}
|
||||||
int32_t errCode =
|
int32_t errCode =
|
||||||
InputMethodController::GetInstance()->SwitchInputMethod(SwitchTrigger::CURRENT_IME, std::string(props.name), std::string(props.id));
|
ctrl->SwitchInputMethod(SwitchTrigger::CURRENT_IME, std::string(props.name), std::string(props.id));
|
||||||
if (errCode == ErrorCode::NO_ERROR)
|
|
||||||
{
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
return errCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t CJ_SwitchCurrentInputMethodSubtype(bool &result, CInputMethodSubtype target)
|
|
||||||
{
|
|
||||||
InputMethodSyncTrace tracer("CJInputMethod_SwitchCurrentInputMethodSubtype");
|
|
||||||
int32_t errCode = InputMethodController::GetInstance()->SwitchInputMethod(
|
|
||||||
SwitchTrigger::CURRENT_IME, std::string(target.name), std::string(target.id));
|
|
||||||
if (errCode == ErrorCode::NO_ERROR) {
|
if (errCode == ErrorCode::NO_ERROR) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
return errCode;
|
return errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CJ_GetCurrentInputMethodSubtype(CInputMethodSubtype &props)
|
int32_t FfiInputMethodSwitchCurrentInputMethodSubtype(bool &result, CInputMethodSubtype target)
|
||||||
{
|
{
|
||||||
std::shared_ptr<SubProperty> subProperty = InputMethodController::GetInstance()->GetCurrentInputMethodSubtype();
|
InputMethodSyncTrace tracer("CJInputMethod_SwitchCurrentInputMethodSubtype");
|
||||||
|
auto ctrl = InputMethodController::GetInstance();
|
||||||
|
if (ctrl == nullptr) {
|
||||||
|
return ERR_NO_MEMORY;
|
||||||
|
}
|
||||||
|
int32_t errCode =
|
||||||
|
ctrl->SwitchInputMethod(SwitchTrigger::CURRENT_IME, std::string(target.name), std::string(target.id));
|
||||||
|
if (errCode == ErrorCode::NO_ERROR) {
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
return errCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t FfiInputMethodGetCurrentInputMethodSubtype(CInputMethodSubtype &props)
|
||||||
|
{
|
||||||
|
auto ctrl = InputMethodController::GetInstance();
|
||||||
|
if (ctrl == nullptr) {
|
||||||
|
return ERR_NO_MEMORY;
|
||||||
|
}
|
||||||
|
std::shared_ptr<SubProperty> subProperty = ctrl->GetCurrentInputMethodSubtype();
|
||||||
if (subProperty == nullptr) {
|
if (subProperty == nullptr) {
|
||||||
IMSA_HILOGE("current input method subtype is nullptr!");
|
IMSA_HILOGE("current input method subtype is nullptr!");
|
||||||
return -1;
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
Utils::InputMethodSubProperty2C(props, *subProperty);
|
Utils::InputMethodSubProperty2C(props, *subProperty);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CJ_SwitchCurrentInputMethodAndSubtype(bool &result, CInputMethodProperty target, CInputMethodSubtype subtype)
|
int32_t FfiInputMethodSwitchCurrentInputMethodAndSubtype(bool &result,
|
||||||
{
|
CInputMethodProperty target, CInputMethodSubtype subtype)
|
||||||
|
{
|
||||||
InputMethodSyncTrace tracer("CJInputMethod_SwitchCurrentInputMethodAndSubtype");
|
InputMethodSyncTrace tracer("CJInputMethod_SwitchCurrentInputMethodAndSubtype");
|
||||||
int32_t errCode =
|
auto ctrl = InputMethodController::GetInstance();
|
||||||
InputMethodController::GetInstance()->SwitchInputMethod(SwitchTrigger::CURRENT_IME, std::string(subtype.name), std::string(subtype.id));
|
if (ctrl == nullptr) {
|
||||||
|
return ERR_NO_MEMORY;
|
||||||
|
}
|
||||||
|
int32_t errCode = ctrl->SwitchInputMethod(SwitchTrigger::CURRENT_IME,
|
||||||
|
std::string(subtype.name), std::string(subtype.id));
|
||||||
if (errCode == ErrorCode::NO_ERROR) {
|
if (errCode == ErrorCode::NO_ERROR) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
return errCode;
|
return errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CJ_GetSystemInputMethodConfigAbility(CElementName &elem)
|
int32_t FfiInputMethodGetSystemInputMethodConfigAbility(CElementName &elem)
|
||||||
{
|
{
|
||||||
OHOS::AppExecFwk::ElementName inputMethodConfig;
|
OHOS::AppExecFwk::ElementName inputMethodConfig;
|
||||||
int32_t ret = InputMethodController::GetInstance()->GetInputMethodConfig(inputMethodConfig);
|
auto ctrl = InputMethodController::GetInstance();
|
||||||
|
if (ctrl == nullptr) {
|
||||||
|
return ERR_NO_MEMORY;
|
||||||
|
}
|
||||||
|
int32_t ret = ctrl->GetInputMethodConfig(inputMethodConfig);
|
||||||
if (ret == ErrorCode::NO_ERROR) {
|
if (ret == ErrorCode::NO_ERROR) {
|
||||||
elem.deviceId = Utils::MallocCString(inputMethodConfig.GetDeviceID());
|
elem.deviceId = Utils::MallocCString(inputMethodConfig.GetDeviceID());
|
||||||
elem.bundleName = Utils::MallocCString(inputMethodConfig.GetBundleName());
|
elem.bundleName = Utils::MallocCString(inputMethodConfig.GetBundleName());
|
||||||
@ -107,16 +131,20 @@ namespace OHOS::MiscServices
|
|||||||
elem.moduleName = Utils::MallocCString(inputMethodConfig.GetModuleName());
|
elem.moduleName = Utils::MallocCString(inputMethodConfig.GetModuleName());
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetInputMethodSubtype CJ_ListInputMethodSubtype(CInputMethodProperty props)
|
RetInputMethodSubtype FfiInputMethodSettingListInputMethodSubtype(CInputMethodProperty props)
|
||||||
{
|
{
|
||||||
IMSA_HILOGD("run in ListInputMethodSubtype");
|
IMSA_HILOGD("run in ListInputMethodSubtype");
|
||||||
RetInputMethodSubtype ret{};
|
RetInputMethodSubtype ret{};
|
||||||
Property property = Utils::C2InputMethodProperty(props);
|
Property property = Utils::C2InputMethodProperty(props);
|
||||||
std::vector<SubProperty> subProps;
|
std::vector<SubProperty> subProps;
|
||||||
int32_t errCode =
|
auto ctrl = InputMethodController::GetInstance();
|
||||||
InputMethodController::GetInstance()->ListInputMethodSubtype(property, subProps);
|
if (ctrl == nullptr) {
|
||||||
|
ret.code = ERR_NO_MEMORY;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int32_t errCode = ctrl->ListInputMethodSubtype(property, subProps);
|
||||||
ret.code = errCode;
|
ret.code = errCode;
|
||||||
if (errCode != ErrorCode::NO_ERROR) {
|
if (errCode != ErrorCode::NO_ERROR) {
|
||||||
return ret;
|
return ret;
|
||||||
@ -136,14 +164,19 @@ namespace OHOS::MiscServices
|
|||||||
ret.head[i] = props;
|
ret.head[i] = props;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetInputMethodSubtype CJ_ListCurrentInputMethodSubtype()
|
RetInputMethodSubtype FfiInputMethodSettingListCurrentInputMethodSubtype()
|
||||||
{
|
{
|
||||||
IMSA_HILOGD("run in ListCurrentInputMethodSubtype");
|
IMSA_HILOGD("run in ListCurrentInputMethodSubtype");
|
||||||
RetInputMethodSubtype ret{};
|
RetInputMethodSubtype ret{};
|
||||||
std::vector<SubProperty> subProps;
|
std::vector<SubProperty> subProps;
|
||||||
int32_t errCode = InputMethodController::GetInstance()->ListCurrentInputMethodSubtype(subProps);
|
auto ctrl = InputMethodController::GetInstance();
|
||||||
|
if (ctrl == nullptr) {
|
||||||
|
ret.code = ERR_NO_MEMORY;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int32_t errCode = ctrl->ListCurrentInputMethodSubtype(subProps);
|
||||||
ret.code = errCode;
|
ret.code = errCode;
|
||||||
if (errCode != ErrorCode::NO_ERROR) {
|
if (errCode != ErrorCode::NO_ERROR) {
|
||||||
return ret;
|
return ret;
|
||||||
@ -163,14 +196,19 @@ namespace OHOS::MiscServices
|
|||||||
ret.head[i] = props;
|
ret.head[i] = props;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetInputMethodProperty CJ_GetInputMethods(bool enable)
|
RetInputMethodProperty FfiInputMethodSettingGetInputMethods(bool enable)
|
||||||
{
|
{
|
||||||
IMSA_HILOGD("run in");
|
IMSA_HILOGD("run in");
|
||||||
RetInputMethodProperty ret{};
|
RetInputMethodProperty ret{};
|
||||||
std::vector<Property> properties;
|
std::vector<Property> properties;
|
||||||
int32_t errCode = InputMethodController::GetInstance()->ListInputMethod(enable, properties);
|
auto ctrl = InputMethodController::GetInstance();
|
||||||
|
if (ctrl == nullptr) {
|
||||||
|
ret.code = ERR_NO_MEMORY;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int32_t errCode = ctrl->ListInputMethod(enable, properties);
|
||||||
ret.code = errCode;
|
ret.code = errCode;
|
||||||
if (errCode != ErrorCode::NO_ERROR) {
|
if (errCode != ErrorCode::NO_ERROR) {
|
||||||
return ret;
|
return ret;
|
||||||
@ -189,14 +227,19 @@ namespace OHOS::MiscServices
|
|||||||
ret.head[i] = props;
|
ret.head[i] = props;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetInputMethodProperty CJ_GetAllInputMethods()
|
RetInputMethodProperty FfiInputMethodSettingGetAllInputMethods()
|
||||||
{
|
{
|
||||||
IMSA_HILOGD("run in");
|
IMSA_HILOGD("run in");
|
||||||
RetInputMethodProperty ret{};
|
RetInputMethodProperty ret{};
|
||||||
std::vector<Property> properties;
|
std::vector<Property> properties;
|
||||||
int32_t errCode = InputMethodController::GetInstance()->ListInputMethod(properties);
|
auto ctrl = InputMethodController::GetInstance();
|
||||||
|
if (ctrl == nullptr) {
|
||||||
|
ret.code = ERR_NO_MEMORY;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int32_t errCode = ctrl->ListInputMethod(properties);
|
||||||
ret.code = errCode;
|
ret.code = errCode;
|
||||||
if (errCode != ErrorCode::NO_ERROR) {
|
if (errCode != ErrorCode::NO_ERROR) {
|
||||||
return ret;
|
return ret;
|
||||||
@ -215,92 +258,104 @@ namespace OHOS::MiscServices
|
|||||||
ret.head[i] = props;
|
ret.head[i] = props;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CJ_InputMethodSettingOn(uint32_t type, void (*func)(CInputMethodProperty, CInputMethodSubtype))
|
int32_t FfiInputMethodSettingOn(uint32_t type, void (*func)(CInputMethodProperty, CInputMethodSubtype))
|
||||||
{
|
{
|
||||||
return CJGetInputMethodSetting::GetIMSInstance()->Subscribe(type, func);
|
auto setting = CJGetInputMethodSetting::GetIMSInstance();
|
||||||
|
if (setting == nullptr) {
|
||||||
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
return setting->Subscribe(type, func);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t CJ_InputMethodSettingOff(uint32_t type)
|
int32_t FfiInputMethodSettingOff(uint32_t type)
|
||||||
{
|
{
|
||||||
return CJGetInputMethodSetting::GetIMSInstance()->UnSubscribe(type);
|
auto setting = CJGetInputMethodSetting::GetIMSInstance();
|
||||||
|
if (setting == nullptr) {
|
||||||
|
return ERR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
return setting->UnSubscribe(type);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t CJ_ShowOptionalInputMethods(bool& result)
|
int32_t FfiInputMethodSettingShowOptionalInputMethods(bool& result)
|
||||||
{
|
{
|
||||||
IMSA_HILOGD("start JsGetInputMethodSetting.");
|
IMSA_HILOGD("start JsGetInputMethodSetting.");
|
||||||
int32_t errCode = InputMethodController::GetInstance()->DisplayOptionalInputMethod();
|
auto ctrl = InputMethodController::GetInstance();
|
||||||
|
if (ctrl == nullptr) {
|
||||||
|
return ERR_NO_MEMORY;
|
||||||
|
}
|
||||||
|
int32_t errCode = ctrl->DisplayOptionalInputMethod();
|
||||||
if (errCode == ErrorCode::NO_ERROR) {
|
if (errCode == ErrorCode::NO_ERROR) {
|
||||||
IMSA_HILOGI("exec DisplayOptionalInputMethod success");
|
IMSA_HILOGI("exec DisplayOptionalInputMethod success");
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
return errCode;
|
return errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CJ_InputMethodControllerOn(int8_t type, int64_t id)
|
int32_t FfiInputMethodControllerOn(int8_t type, int64_t id)
|
||||||
{
|
{
|
||||||
return CjInputMethodController::Subscribe(type, id);
|
return CjInputMethodController::Subscribe(type, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CJ_InputMethodControllerOff(int8_t type)
|
int32_t FfiInputMethodControllerOff(int8_t type)
|
||||||
{
|
{
|
||||||
return CjInputMethodController::Unsubscribe(type);
|
return CjInputMethodController::Unsubscribe(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t OHOSFfiAttach(bool showKeyboard, CTextConfig txtCfg)
|
int32_t FfiInputMethodControllerAttach(bool showKeyboard, CTextConfig txtCfg)
|
||||||
{
|
{
|
||||||
return CjInputMethodController::Attach(txtCfg, showKeyboard);
|
return CjInputMethodController::Attach(txtCfg, showKeyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t OHOSFfiDetach()
|
int32_t FfiInputMethodControllerDetach()
|
||||||
{
|
{
|
||||||
return CjInputMethodController::Detach();
|
return CjInputMethodController::Detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t OHOSFfiShowTextInput()
|
int32_t FfiInputMethodControllerShowTextInput()
|
||||||
{
|
{
|
||||||
return CjInputMethodController::ShowTextInput();
|
return CjInputMethodController::ShowTextInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t OHOSFfiHideTextInput()
|
int32_t FfiInputMethodControllerHideTextInput()
|
||||||
{
|
{
|
||||||
return CjInputMethodController::HideTextInput();
|
return CjInputMethodController::HideTextInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t OHOSFfiSetCallingWindow(uint32_t windowId)
|
int32_t FfiInputMethodControllerSetCallingWindow(uint32_t windowId)
|
||||||
{
|
{
|
||||||
return CjInputMethodController::SetCallingWindow(windowId);
|
return CjInputMethodController::SetCallingWindow(windowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t OHOSFfiUpdateCursor(CCursorInfo cursor)
|
int32_t FfiInputMethodControllerUpdateCursor(CCursorInfo cursor)
|
||||||
{
|
{
|
||||||
return CjInputMethodController::UpdateCursor(cursor);
|
return CjInputMethodController::UpdateCursor(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t OHOSFfiChangeSelection(char *text, int32_t start, int32_t end)
|
int32_t FfiInputMethodControllerChangeSelection(char *text, int32_t start, int32_t end)
|
||||||
{
|
{
|
||||||
return CjInputMethodController::ChangeSelection(std::string(text), start, end);
|
return CjInputMethodController::ChangeSelection(std::string(text), start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t OHOSFfiUpdateAttribute(CInputAttribute inputAttribute)
|
int32_t FfiInputMethodControllerUpdateAttribute(CInputAttribute inputAttribute)
|
||||||
{
|
{
|
||||||
return CjInputMethodController::UpdateAttribute(inputAttribute);
|
return CjInputMethodController::UpdateAttribute(inputAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t OHOSFfiShowSoftKeyboard()
|
int32_t FfiInputMethodControllerShowSoftKeyboard()
|
||||||
{
|
{
|
||||||
return CjInputMethodController::ShowSoftKeyboard();
|
return CjInputMethodController::ShowSoftKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t OHOSFfiHideSoftKeyboard()
|
int32_t FfiInputMethodControllerHideSoftKeyboard()
|
||||||
{
|
{
|
||||||
return CjInputMethodController::HideSoftKeyboard();
|
return CjInputMethodController::HideSoftKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t OHOSFfiStopInputSession()
|
int32_t FfiInputMethodControllerStopInputSession()
|
||||||
{
|
{
|
||||||
return CjInputMethodController::StopInputSession();
|
return CjInputMethodController::StopInputSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,14 +17,12 @@
|
|||||||
namespace OHOS::MiscServices {
|
namespace OHOS::MiscServices {
|
||||||
char* Utils::MallocCString(const std::string &origin)
|
char* Utils::MallocCString(const std::string &origin)
|
||||||
{
|
{
|
||||||
if (origin.empty())
|
if (origin.empty()) {
|
||||||
{
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto len = origin.length() + 1;
|
auto len = origin.length() + 1;
|
||||||
char *res = static_cast<char *>(malloc(sizeof(char) * len));
|
char *res = static_cast<char *>(malloc(sizeof(char) * len));
|
||||||
if (res == nullptr)
|
if (res == nullptr) {
|
||||||
{
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return std::char_traits<char>::copy(res, origin.c_str(), len);
|
return std::char_traits<char>::copy(res, origin.c_str(), len);
|
||||||
|
Loading…
Reference in New Issue
Block a user