bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=04d4aeb8b78c086a0f3ea4febca126f28ad4cce0

commit 04d4aeb8b78c086a0f3ea4febca126f28ad4cce0
Author: WooHyun Jung <wh0705.j...@samsung.com>
Date:   Tue Jan 14 09:22:52 2020 +0000

    edje_entry: fix some preediting bugs
    
    1. Attributes can come with random sequence.
       So, attribute list should be sorted based on start_index.
    2. None tag can be used for some languages' preediting.
       So, the tag also needs to be handled the same with other tags.
    
    Reviewed-by: Marcel Hollerbach <m...@marcel-hollerbach.de>
    Differential Revision: https://phab.enlightenment.org/D11059
---
 src/lib/edje/edje_entry.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c
index 3d4e47207d..eb63c4f61f 100644
--- a/src/lib/edje/edje_entry.c
+++ b/src/lib/edje/edje_entry.c
@@ -4865,6 +4865,20 @@ _edje_entry_imf_event_commit_cb(void *data, 
Ecore_IMF_Context *ctx EINA_UNUSED,
    _edje_entry_real_part_configure(ed, rp);
 }
 
+static int
+_sort_cb(const void *a1, const void *a2)
+{
+   Ecore_IMF_Preedit_Attr *attr1 = (Ecore_IMF_Preedit_Attr *)a1;
+   Ecore_IMF_Preedit_Attr *attr2 = (Ecore_IMF_Preedit_Attr *)a2;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(attr1, 0);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(attr2, 0);
+
+   if (attr1->start_index < attr2->start_index) return -1;
+   else if (attr1->start_index == attr2->start_index) return 0;
+   else return 1;
+}
+
 static void
 _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx 
EINA_UNUSED, void *event_info EINA_UNUSED)
 {
@@ -4927,10 +4941,11 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, 
Ecore_IMF_Context *ctx EINA
         buf = eina_strbuf_new();
         if (attrs)
           {
+             attrs = eina_list_sort(attrs, 0, EINA_COMPARE_CB(_sort_cb));
+
              EINA_LIST_FOREACH(attrs, l, attr)
                {
-                  if (attr->preedit_type < preedit_type_size &&
-                      tagname[attr->preedit_type])
+                  if (attr->preedit_type < preedit_type_size)
                     {
                        preedit_attr_str = eina_strbuf_new();
                        if (preedit_attr_str)
@@ -4940,7 +4955,10 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, 
Ecore_IMF_Context *ctx EINA
 
                             if (markup_txt)
                               {
-                                 eina_strbuf_append_printf(buf, "<%s>%s</%s>", 
tagname[attr->preedit_type], markup_txt, tagname[attr->preedit_type]);
+                                 if (tagname[attr->preedit_type])
+                                   eina_strbuf_append_printf(buf, 
"<%s>%s</%s>", tagname[attr->preedit_type], markup_txt, 
tagname[attr->preedit_type]);
+                                 else
+                                   eina_strbuf_append_printf(buf, "%s", 
markup_txt);
                                  free(markup_txt);
                               }
                             eina_strbuf_free(preedit_attr_str);

-- 


Reply via email to