Modified to decorate preedit strings by underlining 39/92539/2
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 17 Oct 2016 09:40:26 +0000 (18:40 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 17 Oct 2016 09:42:52 +0000 (02:42 -0700)
Change-Id: I1216980c9240c5c45e8f35a9bdfcad437c08b249

src/include/ise.h
src/ise.cpp
src/sdk/sdk.cpp

index 5a3b491..9d6d66c 100644 (file)
@@ -233,7 +233,7 @@ class CCoreEventCallback : public ISCLCoreEventCallback
 };
 
 void ise_send_string(const sclchar *key_value);
-void ise_update_preedit_string(const sclchar *str);
+void ise_update_preedit_string(const sclchar *str, const sclboolean underline = TRUE);
 void ise_send_event(sclulong key_event, sclulong key_mask);
 void ise_forward_key_event(sclulong key_event);
 
index e09b692..14c6bb9 100644 (file)
@@ -15,6 +15,8 @@
  *
  */
 
+#define Uses_SCIM_ATTRIBUTE
+
 #include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
@@ -23,6 +25,7 @@
 #include <vconf.h>
 #include <Ecore_IMF.h>
 #include <Elementary.h>
+#include <scim.h>
 
 #include "sclui.h"
 #include "sclcore.h"
@@ -692,13 +695,28 @@ ise_send_string(const sclchar *key_value)
 * Send the preedit string to input framework
 */
 void
-ise_update_preedit_string(const sclchar *str)
+ise_update_preedit_string(const sclchar *str, const sclboolean underline)
 {
     int ic = -1;
     if (!check_ic_temporary(g_keyboard_state.ic)) {
         ic = g_keyboard_state.ic;
     }
-    g_core.update_preedit_string(ic, "", str);
+    if (underline) {
+        /* Count UTF-8 string length */
+        int len = 0;
+        const sclchar *s = str;
+        while (*s) len += (*s++ & 0xc0) != 0x80;
+        scim::Attribute attr;
+        attr.set_start(0);
+        attr.set_length(len);
+        attr.set_type(scim::SCIM_ATTR_DECORATE);
+        attr.set_value(scim::SCIM_ATTR_DECORATE_UNDERLINE);
+        std::vector<scim::Attribute> underline_attribute;
+        underline_attribute.push_back(attr);
+        g_core.update_preedit_string(ic, "", str, underline_attribute);
+    } else {
+        g_core.update_preedit_string(ic, "", str);
+    }
     LOGD("ic : %x, %s\n", ic, str);
 }
 
index ae6a22e..d17c9ce 100644 (file)
@@ -174,7 +174,7 @@ int process_korean_automata(int is_consonant, unsigned short key_index, bool ski
     iconv_string(AUTOMATA_BASE_ENCODING, SYSTEM_OUTPUT_ENCODING,
         (const char*)(CJI_GetMakeCode().ucode), buffer, CJI_GetMakeCode().size * 2, KOREAN_ENCODING_BUFFER_SIZE);
     if (buffer[0] || makecode.size > 0) {
-        ise_update_preedit_string(buffer);
+        ise_update_preedit_string(buffer, FALSE);
         ret = TRUE;
     }