From: Jihoon Kim Date: Thu, 26 Sep 2019 12:51:33 +0000 (+0900) Subject: Add API for updating the cursor position of preedit string X-Git-Tag: submit/tizen/20210202.072159~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f5a0efbd9ed3b1a69d0311bf8e2ca9bb942a1011;p=platform%2Fcore%2Fapi%2Finputmethod.git Add API for updating the cursor position of preedit string Change-Id: Ib7fe9293abb69f70911cfdab0001940853da25eb Signed-off-by: Jihoon Kim --- diff --git a/inputmethod/include/inputmethod.h b/inputmethod/include/inputmethod.h index 3ae712a..8e1db30 100644 --- a/inputmethod/include/inputmethod.h +++ b/inputmethod/include/inputmethod.h @@ -1668,6 +1668,7 @@ int ime_hide_preedit_string(void); * @see ime_commit_string() * @see ime_show_preedit_string() * @see ime_hide_preedit_string() + * @see ime_update_preedit_cursor() * * @code { @@ -1705,6 +1706,58 @@ int ime_hide_preedit_string(void); */ int ime_update_preedit_string(const char *str, Eina_List *attrs); +/** + * @brief Updates the cursor position in the preedit string. + * + * @since_tizen 6.5 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] pos The cursor position in the preedit string + * + * @return 0 on success, otherwise a negative error value + * @retval #IME_ERROR_NONE No error + * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function. + * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet + * + * @post This function is supposed to be followed by the ime_update_preedit_string() function. + * + * @see ime_show_preedit_string() + * @see ime_hide_preedit_string() + * @see ime_update_preedit_string() + * + * @code + { + int ret; + Eina_List *list = NULL; + + ime_preedit_attribute *attr = calloc(1, sizeof(ime_preedit_attribute)); + attr->start = 0; + attr->length = 1; + attr->type = IME_ATTR_FONTSTYLE; + attr->value = IME_ATTR_FONTSTYLE_UNDERLINE; + list = eina_list_append(list, attr); + + attr = calloc(1, sizeof(ime_preedit_attribute)); + attr->start = 1; + attr->length = 3; + attr->type = IME_ATTR_FONTSTYLE; + attr->value = IME_ATTR_FONTSTYLE_REVERSAL; + list = eina_list_append(list, attr); + + ret = ime_update_preedit_string("abcd", list); + if (ret != IME_ERROR_NONE) { + EINA_LIST_FREE(list, attr) + free(attr); + } + ret = ime_update_preedit_cursor(1); + } + * @endcode + */ +int ime_update_preedit_cursor(unsigned int pos); + /** * @brief Requests the surrounding text from the position of the cursor, asynchronously. * diff --git a/inputmethod/src/inputmethod.cpp b/inputmethod/src/inputmethod.cpp index e05d6be..94bbe76 100644 --- a/inputmethod/src/inputmethod.cpp +++ b/inputmethod/src/inputmethod.cpp @@ -1353,6 +1353,23 @@ EXPORT_API int ime_update_preedit_string(const char *str, Eina_List *attrs) //LCOV_EXCL_STOP } +EXPORT_API int ime_update_preedit_cursor(unsigned int pos) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_core.update_preedit_caret(pos); + + return IME_ERROR_NONE; +} + EXPORT_API int ime_request_surrounding_text(int maxlen_before, int maxlen_after) { ime_error_e retVal = IME_ERROR_NONE;