From: sungwook79.park Date: Tue, 8 Dec 2015 04:41:34 +0000 (+0900) Subject: Add a new API for set_selection in inputmethod X-Git-Tag: accepted/tizen/common/20160516.143107~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=43669e4560e67c575cf04946fe7260f30e82ad29;p=platform%2Fcore%2Fapi%2Finputmethod.git Add a new API for set_selection in inputmethod Change-Id: I955e82ba9ccb6b3be190785d19372511d112fe3d --- diff --git a/include/inputmethod.h b/include/inputmethod.h index 6b38eaa..27e4d5f 100644 --- a/include/inputmethod.h +++ b/include/inputmethod.h @@ -1599,6 +1599,26 @@ EXPORT_API int ime_delete_surrounding_text(int offset, int len); EXPORT_API int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, int *cursor_pos); /** + * @brief Requests to set selection. + * + * @since_tizen 3.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] start The start cursor position in text (in characters not bytes) + * @param[in] end The end cursor position in text (in characters not bytes) + * + * @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_set_selection(int start, int end); + +/** * @brief This API returns the pointer of input panel main window. * * @remarks The specific error code can be obtained using the get_last_result() method if this function returns NULL. diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp index f90de02..01c08e6 100644 --- a/src/inputmethod.cpp +++ b/src/inputmethod.cpp @@ -1107,6 +1107,31 @@ int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, i return IME_ERROR_NONE; } +int ime_set_selection(int start, int end) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (start < 0) { + 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.set_selection(start, end); + + return IME_ERROR_NONE; +} + Evas_Object* ime_get_main_window(void) { ime_error_e retVal = IME_ERROR_NONE;