From: Sungmin Kwak Date: Fri, 10 Apr 2015 12:18:58 +0000 (+0900) Subject: Change the parameters of ime_update_preedit_string() X-Git-Tag: submit/tizen/20150612.024017~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ea8b20156f86a3f49ddf5bfd4fe8f822cb90027c;p=platform%2Fcore%2Fapi%2Finputmethod.git Change the parameters of ime_update_preedit_string() Change-Id: I3e3304de07966730b0065df1bf22322b5475528b --- diff --git a/CMakeLists.txt b/CMakeLists.txt index cb15238..ae0f013 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -fpermissive") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" STREQUAL "arm") diff --git a/include/inputmethod.h b/include/inputmethod.h index d0f4de5..b63b187 100644 --- a/include/inputmethod.h +++ b/include/inputmethod.h @@ -85,6 +85,56 @@ typedef enum IME_LAYOUT_PASSWORD_VARIATION_NUMBERONLY, /**< The password layout to allow only number */ } ime_layout_variation_e; +/** + * @brief Enumeration of string attribute type + * + * @remarks Currently, a font style is available to use. + * + * @since_tizen 2.4 + * + * @see ime_preedit_attribute, ime_update_preedit_string + */ +typedef enum +{ + IME_ATTR_NONE, /**< No attribute */ + IME_ATTR_FONTSTYLE, /**< A font style attribute, e.g., underline, etc. */ +} ime_attribute_type; + +/** + * @brief Value for #IME_ATTR_FONTSTYLE. Draw a line under the text. + * @since_tizen 2.4 + */ +#define IME_ATTR_FONTSTYLE_UNDERLINE 1 + +/** + * @brief Value for #IME_ATTR_FONTSTYLE. Draw text in highlighted color. + * @since_tizen 2.4 + */ +#define IME_ATTR_FONTSTYLE_HIGHLIGHT 2 + +/** + * @brief Value for #IME_ATTR_FONTSTYLE. Draw text in reversal color. + * @since_tizen 2.4 + */ +#define IME_ATTR_FONTSTYLE_REVERSAL 4 + +/** + * @brief The structure type to contain the attributes for preedit string. + * + * @remarks A preedit string may have one or more different attributes. This structure describes each attribute of the string. + * + * @since_tizen 2.4 + * + * @see ime_update_preedit_string, ime_attribute_type + */ +typedef struct +{ + unsigned int start; /**< The start position in the string of this attribute */ + unsigned int length; /**< The byte length of this attribute, the range is [start, start+length] */ + ime_attribute_type type; /**< The type of this attribute */ + unsigned int value; /**< The value of this attribute */ +} ime_preedit_attribute; + /** * @brief Handle of an associated text input UI control's input context. * @@ -1354,6 +1404,8 @@ EXPORT_API int ime_hide_preedit_string(void); * @privilege %http://tizen.org/privilege/ime * * @param[in] str The UTF-8 string to be updated in preedit + * @paran[in] attrs The Eina_List which has #ime_preedit_attribute lists; @a str can be composed of multiple + * string attributes: underline, highlight color and reversal color. The @a attrs will be released internally on success * * @return 0 on success, otherwise a negative error value * @retval #IME_ERROR_NONE No error @@ -1361,9 +1413,43 @@ EXPORT_API int ime_hide_preedit_string(void); * @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 * - * @see ime_commit_string, ime_show_preedit_string, ime_hide_preedit_string + * @see ime_preedit_attribute, ime_commit_string, ime_show_preedit_string, ime_hide_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 = 1; + attr->type = IME_ATTR_FONTSTYLE; + attr->value = IME_ATTR_FONTSTYLE_HIGHLIGHT; + list = eina_list_append(list, attr); + + attr = calloc(1, sizeof (ime_preedit_attribute)); + attr->start = 2; + attr->length = 1; + 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); + } + } + * @endcode */ -EXPORT_API int ime_update_preedit_string(const char *str); +EXPORT_API int ime_update_preedit_string(const char *str, Eina_List *attrs); /** * @brief Requests the surrounding text from the position of the cursor, asynchronously. diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp index 0d03894..309ef23 100644 --- a/src/inputmethod.cpp +++ b/src/inputmethod.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +#define Uses_SCIM_ATTRIBUTE + +#include #include #include #include @@ -658,6 +661,9 @@ int ime_commit_string(const char *str) if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!str) + return IME_ERROR_INVALID_PARAMETER; + g_core.commit_string(-1, NULL, str); return IME_ERROR_NONE; @@ -683,7 +689,7 @@ int ime_hide_preedit_string(void) return IME_ERROR_NONE; } -int ime_update_preedit_string(const char *str) +int ime_update_preedit_string(const char *str, Eina_List *attrs) { if (!g_running) return IME_ERROR_NOT_RUNNING; @@ -691,6 +697,19 @@ int ime_update_preedit_string(const char *str) if (!str) return IME_ERROR_INVALID_PARAMETER; + scim::AttributeList attrv; + ime_preedit_attribute *attr = NULL; + + if (attrs) { + EINA_LIST_FREE(attrs, attr) { + if (attr) { + attrv.push_back(scim::Attribute(attr->start, attr->length, (scim::AttributeType)attr->type, attr->value)); + free(attr); + } + } + } + + //g_core.update_preedit_string(-1, NULL, str, attrv); g_core.update_preedit_string(-1, NULL, str); return IME_ERROR_NONE; @@ -778,14 +797,14 @@ int ime_create_option_window(void) int ime_destroy_option_window(Evas_Object *window) { + if (!g_running) + return IME_ERROR_NOT_RUNNING; + if (!window) { LOGW("Window pointer is null."); return IME_ERROR_INVALID_PARAMETER; } - if (!g_running) - return IME_ERROR_NOT_RUNNING; - if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) { LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set."); return IME_ERROR_NO_CALLBACK_FUNCTION; @@ -798,12 +817,12 @@ int ime_destroy_option_window(Evas_Object *window) int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout *layout) { - if (!context || !layout) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!context || !layout) + return IME_ERROR_INVALID_PARAMETER; + *layout = context->layout; return IME_ERROR_NONE; @@ -811,12 +830,12 @@ int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout * int ime_context_get_layout_variation(ime_context_h context, ime_layout_variation_e *layout_variation) { - if (!context || !layout_variation) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!context || !layout_variation) + return IME_ERROR_INVALID_PARAMETER; + *layout_variation = static_cast(context->layout_variation); return IME_ERROR_NONE; @@ -824,12 +843,12 @@ int ime_context_get_layout_variation(ime_context_h context, ime_layout_variation int ime_context_get_cursor_position(ime_context_h context, int *cursor_pos) { - if (!context || !cursor_pos) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!context || !cursor_pos) + return IME_ERROR_INVALID_PARAMETER; + *cursor_pos = context->cursor_pos; return IME_ERROR_NONE; @@ -837,12 +856,12 @@ int ime_context_get_cursor_position(ime_context_h context, int *cursor_pos) int ime_context_get_autocapital_type(ime_context_h context, Ecore_IMF_Autocapital_Type *autocapital_type) { - if (!context || !autocapital_type) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!context || !autocapital_type) + return IME_ERROR_INVALID_PARAMETER; + *autocapital_type = context->autocapital_type; return IME_ERROR_NONE; @@ -850,12 +869,12 @@ int ime_context_get_autocapital_type(ime_context_h context, Ecore_IMF_Autocapita int ime_context_get_return_key_type(ime_context_h context, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type) { - if (!context || !return_key_type) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!context || !return_key_type) + return IME_ERROR_INVALID_PARAMETER; + *return_key_type = context->return_key_type; return IME_ERROR_NONE; @@ -863,12 +882,12 @@ int ime_context_get_return_key_type(ime_context_h context, Ecore_IMF_Input_Panel int ime_context_get_return_key_state(ime_context_h context, bool *return_key_state) { - if (!context || !return_key_state) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!context || !return_key_state) + return IME_ERROR_INVALID_PARAMETER; + *return_key_state = static_cast(context->return_key_disabled); return IME_ERROR_NONE; @@ -876,12 +895,12 @@ int ime_context_get_return_key_state(ime_context_h context, bool *return_key_sta int ime_context_get_prediction_mode(ime_context_h context, bool *prediction_mode) { - if (!context || !prediction_mode) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!context || !prediction_mode) + return IME_ERROR_INVALID_PARAMETER; + *prediction_mode = static_cast(context->prediction_allow); return IME_ERROR_NONE; @@ -889,12 +908,12 @@ int ime_context_get_prediction_mode(ime_context_h context, bool *prediction_mode int ime_context_get_password_mode(ime_context_h context, bool *password_mode) { - if (!context || !password_mode) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!context || !password_mode) + return IME_ERROR_INVALID_PARAMETER; + *password_mode = static_cast(context->password_mode); return IME_ERROR_NONE; @@ -902,12 +921,12 @@ int ime_context_get_password_mode(ime_context_h context, bool *password_mode) int ime_context_get_input_hint(ime_context_h context, Ecore_IMF_Input_Hints *input_hint) { - if (!context || !input_hint) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!context || !input_hint) + return IME_ERROR_INVALID_PARAMETER; + *input_hint = context->input_hint; return IME_ERROR_NONE; @@ -915,12 +934,12 @@ int ime_context_get_input_hint(ime_context_h context, Ecore_IMF_Input_Hints *inp int ime_context_get_bidi_direction(ime_context_h context, Ecore_IMF_BiDi_Direction *bidi) { - if (!context || !bidi) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!context || !bidi) + return IME_ERROR_INVALID_PARAMETER; + *bidi = context->bidi_direction; return IME_ERROR_NONE; @@ -928,12 +947,12 @@ int ime_context_get_bidi_direction(ime_context_h context, Ecore_IMF_BiDi_Directi int ime_context_get_language(ime_context_h context, Ecore_IMF_Input_Panel_Lang *language) { - if (!context || !language) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!context || !language) + return IME_ERROR_INVALID_PARAMETER; + *language = context->language; return IME_ERROR_NONE; @@ -941,12 +960,12 @@ int ime_context_get_language(ime_context_h context, Ecore_IMF_Input_Panel_Lang * int ime_device_info_get_name(ime_device_info_h dev_info, char **dev_name) { - if (!dev_info || !dev_name) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!dev_info || !dev_name) + return IME_ERROR_INVALID_PARAMETER; + if (!dev_info->dev_name) *dev_name = strdup(""); else @@ -957,12 +976,12 @@ int ime_device_info_get_name(ime_device_info_h dev_info, char **dev_name) int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_Device_Class *dev_class) { - if (!dev_info || !dev_class) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!dev_info || !dev_class) + return IME_ERROR_INVALID_PARAMETER; + *dev_class = dev_info->dev_class; return IME_ERROR_NONE; @@ -970,12 +989,12 @@ int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_Device_Class int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IMF_Device_Subclass *dev_subclass) { - if (!dev_info || !dev_subclass) - return IME_ERROR_INVALID_PARAMETER; - if (!g_running) return IME_ERROR_NOT_RUNNING; + if (!dev_info || !dev_subclass) + return IME_ERROR_INVALID_PARAMETER; + *dev_subclass = dev_info->dev_subclass; return IME_ERROR_NONE;