Re: [E-devel] [PATCH] support to get style attribute of XIM module

2011-12-20 Thread The Rasterman
On Thu, 15 Dec 2011 13:59:26 +0900 Jihoon Kim  said:

> Hi, EFL developers.
> 
> ATM, edje entry doesn't display the style of preedit string such as
> underline, reverse, and Highlight.
> It's because XIM module doesn't provide the style attribute.
> This patch is made for providing the style attibute information to entry or
> other editable widget.
> 
> edje_test.patch.txt is for verifying this patch. (This patch is written by
> Woohyun and Woohyun will commit edje_entry patch with edc patch)
> 
> Would you please review ecore_imf_xim_attribute.patch.txt file?

i had a look - looks fine to me. in svn it goes! :)


-- 
- Codito, ergo sum - "I code, therefore I am" --
The Rasterman (Carsten Haitzler)ras...@rasterman.com


--
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[E-devel] [PATCH] support to get style attribute of XIM module

2011-12-14 Thread Jihoon Kim
Hi, EFL developers.

ATM, edje entry doesn't display the style of preedit string such as
underline, reverse, and Highlight.
It's because XIM module doesn't provide the style attribute.
This patch is made for providing the style attibute information to entry or
other editable widget.

edje_test.patch.txt is for verifying this patch. (This patch is written by
Woohyun and Woohyun will commit edje_entry patch with edc patch)

Would you please review ecore_imf_xim_attribute.patch.txt file?

Thanks.
Index: src/modules/immodules/xim/ecore_imf_xim.c
===
--- src/modules/immodules/xim/ecore_imf_xim.c   (revision 66175)
+++ src/modules/immodules/xim/ecore_imf_xim.c   (working copy)
@@ -23,6 +23,8 @@
 static Eina_List *open_ims = NULL;
 #endif
 
+#define FEEDBACK_MASK (XIMReverse | XIMUnderline | XIMHighlight)
+
 typedef struct _XIM_Im_Info XIM_Im_Info;
 struct _XIM_Im_Info
 {
@@ -51,6 +53,7 @@
Eina_Bool  finalizing;
Eina_Bool  has_focus;
Eina_Bool  in_toplevel;
+   XIMFeedback   *feedbacks;
 
XIMCallbackpreedit_start_cb;
XIMCallbackpreedit_done_cb;
@@ -63,6 +66,12 @@
 voidimf_context_data_destroy(Ecore_IMF_Context_Data 
*imf_context_data);
 
 #ifdef ENABLE_XIM
+static void add_feedback_attr (Eina_List **attrs,
+   const char   *str,
+   XIMFeedback   feedback,
+   int   start_pos,
+   int   end_pos);
+
 static void reinitialize_ic(Ecore_IMF_Context *ctx);
 static void reinitialize_all_ics(XIM_Im_Info *info);
 static void set_ic_client_window(Ecore_IMF_Context *ctx,
@@ -99,6 +108,19 @@
  XPointer call_data);
 #endif
 
+static unsigned int
+utf8_offset_to_index(const char *str, int offset)
+{
+   int index = 0;
+   int i;
+   for (i = 0; i < offset; i++)
+ {
+eina_unicode_utf8_get_next(str, &index);
+ }
+
+   return index;
+}
+
 static void
 _ecore_imf_context_xim_add(Ecore_IMF_Context *ctx)
 {
@@ -204,6 +226,43 @@
 }
 
 static void
+_ecore_imf_context_xim_preedit_string_with_attributes_get(Ecore_IMF_Context 
*ctx,
+  char **str,
+  Eina_List**attrs,
+  int   *cursor_pos)
+{
+   EINA_LOG_DBG("in");
+
+   Ecore_IMF_Context_Data *imf_context_data = ecore_imf_context_data_get(ctx);
+
+   _ecore_imf_context_xim_preedit_string_get(ctx, str, cursor_pos);
+
+   if (!attrs) return;
+   if (!imf_context_data || !imf_context_data->feedbacks) return;
+
+   int i = 0;
+   XIMFeedback last_feedback = 0;
+   int start = -1;
+
+   for (i = 0; i < imf_context_data->preedit_length; i++)
+ {
+XIMFeedback new_feedback = imf_context_data->feedbacks[i] & 
FEEDBACK_MASK;
+
+if (new_feedback != last_feedback)
+  {
+ if (start >= 0)
+   add_feedback_attr (attrs, *str, last_feedback, start, i);
+
+ last_feedback = new_feedback;
+ start = i;
+  }
+ }
+
+   if (start >= 0)
+ add_feedback_attr (attrs, *str, last_feedback, start, i);
+}
+
+static void
 _ecore_imf_context_xim_focus_in(Ecore_IMF_Context *ctx)
 {
EINA_LOG_DBG("in");
@@ -291,11 +350,18 @@
 
XFree(preedit_attr);
 
+   if (imf_context_data->feedbacks)
+ {
+free(imf_context_data->feedbacks);
+imf_context_data->feedbacks = NULL;
+ }
+
if(imf_context_data->preedit_length)
  {
 imf_context_data->preedit_length = 0;
 free(imf_context_data->preedit_chars);
 imf_context_data->preedit_chars = NULL;
+
 ecore_imf_context_preedit_changed_event_add(ctx);
  }
 
@@ -333,6 +399,36 @@
 }
 
 static void
+add_feedback_attr (Eina_List **attrs,
+   const char   *str,
+   XIMFeedback   feedback,
+   int   start_pos,
+   int   end_pos)
+{
+   Ecore_IMF_Preedit_Attr *attr = NULL;
+
+   unsigned int start_index = utf8_offset_to_index (str, start_pos);
+   unsigned int end_index = utf8_offset_to_index (str, end_pos);
+
+   if (feedback & FEEDBACK_MASK)
+{
+attr = (Ecore_IMF_Preedit_Attr *)calloc(1, 
sizeof(Ecore_IMF_Preedit_Attr));
+attr->start_index = start_index;
+attr->end_index = end_index;
+*attrs = eina_list_append(*attrs, (void *)attr);
+}
+
+   if (feedback & XIMUnderline)
+ attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB1;
+
+   if (feedback & XIMReverse)
+ attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB2;
+
+   if (feedback & XIMHighlight)
+ attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB3;
+}
+
+static void
 _ecore_imf_context_xim_cursor_location_set (Ecore_IMF_Context   *ctx,
 int x, int y, int w, int h)
 {
@@ -608,7 +