Change the parameters of ime_update_preedit_string() 36/40936/1
authorSungmin Kwak <sungmin.kwak@samsung.com>
Fri, 10 Apr 2015 12:18:58 +0000 (21:18 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 10 Jun 2015 09:12:39 +0000 (18:12 +0900)
Change-Id: I3e3304de07966730b0065df1bf22322b5475528b

CMakeLists.txt
include/inputmethod.h
src/inputmethod.cpp

index cb15238dcba834081ceba3635e8c1df37367e1fa..ae0f013186823cc3be5fcd65a92f209f5dc2eab8 100644 (file)
@@ -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")
index d0f4de54ee7a2af41de74560904511b69081a41d..b63b187ae087862180b32013909da484efdc54ca 100644 (file)
@@ -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.
index 0d0389461a87cdfa240930efcd1f174fc72f588e..309ef232d7abd92e9432d3bdba40aa644f063bb2 100644 (file)
@@ -14,6 +14,9 @@
  * limitations under the License.
  */
 
+#define Uses_SCIM_ATTRIBUTE
+
+#include <scim.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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<ime_layout_variation_e>(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<bool>(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<bool>(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<bool>(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;