From: Jihoon Kim Date: Tue, 12 Sep 2017 02:17:28 +0000 (+0900) Subject: Add ime_get_selected_text API for getting selected text X-Git-Tag: submit/tizen/20170925.054231~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3be0f947f83942e9ad33432f91fc44f3fb752254;p=platform%2Fcore%2Fapi%2Finputmethod.git Add ime_get_selected_text API for getting selected text Change-Id: I436301569f9e6bca3459ba193ade28747562d9d7 Signed-off-by: Jihoon Kim --- diff --git a/include/inputmethod.h b/include/inputmethod.h index 11b51f3..a6dccc3 100644 --- a/include/inputmethod.h +++ b/include/inputmethod.h @@ -1664,6 +1664,27 @@ int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, i */ int ime_set_selection(int start, int end); +/** + * @brief Gets the selected text synchronously. + * + * @remarks @a text must be released using free(). + * + * @since_tizen 4.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[out] text The selected text + * + * @return 0 on success, otherwise a negative error value + * @retval #IME_ERROR_NONE No error + * @retval #IME_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function + * @retval #IME_ERROR_NOT_RUNNING IME main loop isn't started yet + */ +EXPORT_API int ime_get_selected_text(char **text); + /** * @brief This API returns the pointer of input panel main window. * diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp index 2f36cf3..99fa9e7 100644 --- a/src/inputmethod.cpp +++ b/src/inputmethod.cpp @@ -1246,6 +1246,31 @@ EXPORT_API int ime_set_selection(int start, int end) return IME_ERROR_NONE; } +EXPORT_API int ime_get_selected_text(char **text) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!text) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) { + LOGE("_check_privilege returned %d.", retVal); + return retVal; + } + + g_core.get_selection_text(text); + + return IME_ERROR_NONE; +} + EXPORT_API Evas_Object* ime_get_main_window(void) { ime_error_e retVal = IME_ERROR_NONE;