Dear, Tom, Raster and EFL people.
Now I'm trying to reduce the code diffs between EFL svn and my company's
local git repository.
I'm sending you entry-related patches continuously those are specialized in
mobile environment such as selection handlers and magnifier.
First, I attached edje entry patch for double click word selection.
It can be applied in all current entry selection modes (default and
explicit mode).
But at this moment default mode has some bugs with scrollers due to
'EVAS_EVENT_FLAGS_ON_HOLD' event flag, and in the explicit mode canceling
selection is not as familiar as other word processor. Therefore current
word selection is just same with selecting word by clicking select
contextual menu and dragging mouse to the end of the word.
This can be improved with selection mode later and triple click line
selection also can be added in a similar way.
I added an API (edje_object_part_text_word_separators_set) to control word
separators in an application.
Please review this patch and apply it if it's acceptable.
Or if you have any opinion for this feel free to give me a feedback.
Thanks.
Index: src/lib/Edje.h
===================================================================
--- src/lib/Edje.h (revision 65983)
+++ src/lib/Edje.h (working copy)
@@ -2629,6 +2629,15 @@ EAPI void edje_object_part_text_select
*/
EAPI void edje_object_part_text_select_extend (const
Evas_Object *obj, const char *part);
+/**
+ * @brief Set the word-separator characters on double click word selection
+ *
+ * @param obj A valid Evas_Object handle
+ * @param part The part name
+ * @param sep The characters set
+ * - default separators : 0x0d (Carriage Return, '\n'), 0x20 (Space)
+ */
+EAPI void edje_object_part_text_word_separators_set
(const Evas_Object *obj, const char *part, const char *sep);
/**
* @brief Advances the cursor to the next cursor position.
Index: src/lib/edje_util.c
===================================================================
--- src/lib/edje_util.c (revision 65983)
+++ src/lib/edje_util.c (working copy)
@@ -1475,6 +1475,21 @@ edje_object_part_text_select_extend(const Evas_Obj
_edje_entry_select_extend(rp);
}
+EAPI void
+edje_object_part_text_word_separators_set(const Evas_Object *obj, const char
*part, const char *sep)
+{
+ Edje *ed;
+ Edje_Real_Part *rp;
+
+ ed = _edje_fetch(obj);
+ if ((!ed) || (!part)) return;
+ rp = _edje_real_part_recursive_get(ed, (char *)part);
+ if (!rp) return;
+ if (!sep) return;
+ if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
+ _edje_entry_select_word_separators_set(rp, sep);
+}
+
EAPI Eina_Bool
edje_object_part_text_cursor_next(Evas_Object *obj, const char *part,
Edje_Cursor cur)
{
Index: src/lib/edje_entry.c
===================================================================
--- src/lib/edje_entry.c (revision 65983)
+++ src/lib/edje_entry.c (working copy)
@@ -7,6 +7,8 @@ static Eina_Bool _edje_entry_imf_event_preedit_cha
static Eina_Bool _edje_entry_imf_event_delete_surrounding_cb(void *data, int
type, void *event);
#endif
+static void _edje_entry_mouse_double_clicked(void *data, Evas_Object *obj
__UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__);
+
typedef struct _Entry Entry;
typedef struct _Sel Sel;
typedef struct _Anchor Anchor;
@@ -29,6 +31,7 @@ struct _Entry
Eina_List *anchorlist;
Eina_List *itemlist;
char *selection;
+ char *separators;
Eina_Bool selecting : 1;
Eina_Bool have_selection : 1;
Eina_Bool select_allow : 1;
@@ -272,18 +275,21 @@ _curs_update_from_curs(Evas_Textblock_Cursor *c, E
*cy += (ch / 2);
}
-static void
+static Eina_Bool
_curs_back(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
Entry *en __UNUSED__)
{
- evas_textblock_cursor_char_prev(c);
+ if (evas_textblock_cursor_char_prev(c))
+ return EINA_TRUE;
+
+ return evas_textblock_cursor_paragraph_prev(c);
}
-static void
+static Eina_Bool
_curs_next(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
Entry *en __UNUSED__)
{
- evas_textblock_cursor_char_next(c);
+ return evas_textblock_cursor_char_next(c);
}
static int
@@ -2067,6 +2073,8 @@ _edje_entry_real_part_init(Edje_Real_Part *rp)
done:
#endif
en->cursor = (Evas_Textblock_Cursor
*)evas_object_textblock_cursor_get(rp->object);
+
+ edje_object_signal_callback_add(rp->edje->obj, "mouse,down,1,double",
rp->part->name, _edje_entry_mouse_double_clicked, rp);
}
void
@@ -2089,6 +2097,12 @@ _edje_entry_real_part_shutdown(Edje_Real_Part *rp)
en->pw_timer = NULL;
}
+ if (en->separators)
+ {
+ free(en->separators);
+ en->separators = NULL;
+ }
+
#ifdef HAVE_ECORE_IMF
if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
{
@@ -2462,6 +2476,35 @@ _edje_entry_select_abort(Edje_Real_Part *rp)
}
}
+Eina_Bool
+_edje_entry_select_word_separators_set(Edje_Real_Part *rp, const char *sep)
+{
+ Entry *en;
+ int len;
+ const char default_sep[] = {'\n', ' ', '\0'};
+
+ if (!rp) return EINA_FALSE;
+ en = rp->entry_data;
+ if (!en) return EINA_FALSE;
+ if (!sep) return EINA_FALSE;
+
+ len = strlen(sep);
+
+ if (en->separators)
+ {
+ free(en->separators);
+ en->separators = NULL;
+ }
+
+ en->separators = (char *)malloc(len + 3);
+ if (!en->separators) return EINA_FALSE;
+
+ memcpy(en->separators, sep, len);
+ memcpy(en->separators + len, default_sep, 3);
+
+ return EINA_TRUE;
+}
+
void
_edje_entry_autocapital_type_set(Edje_Real_Part *rp,
Edje_Text_Autocapital_Type autocapital_type)
{
@@ -2810,6 +2853,107 @@ _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edj
return evas_textblock_cursor_pos_get(c);
}
+Eina_Bool
+_is_separator(Edje_Real_Part *rp, const char *c)
+{
+ Entry *en;
+ char *sep = NULL;
+
+ if (!rp) return EINA_TRUE;
+ en = rp->entry_data;
+ if (!en) return EINA_TRUE;
+
+ if (!en->separators)
+ _edje_entry_select_word_separators_set(rp, "");
+
+ sep = en->separators;
+ if (!c) return EINA_TRUE;
+ if (!sep) return EINA_TRUE;
+ if (!strcmp(c, "<ps>")) return EINA_TRUE;
+ if (!strcmp(c, "<br>")) return EINA_TRUE;
+
+ while (*sep)
+ {
+ if (*c == *sep)
+ return EINA_TRUE;
+ sep++;
+ }
+ return EINA_FALSE;
+}
+
+static Eina_Bool
+_edje_entry_select_word(Edje_Real_Part *rp)
+{
+ Entry *en;
+ const char *ct = NULL;
+
+ if (!rp) return EINA_FALSE;
+ en = rp->entry_data;
+
+ ct = _edje_entry_cursor_content_get(rp, EDJE_CURSOR_MAIN);
+ if (!ct || strlen(ct) == 0)
+ {
+ if (_curs_back(en->cursor, rp->object, en))
+ {
+ ct = _edje_entry_cursor_content_get(rp, EDJE_CURSOR_MAIN);
+ if (!ct || strlen(ct) == 0) return EINA_FALSE;
+ }
+ else
+ return EINA_FALSE;
+ }
+
+ if (en->cursor_fg) evas_object_hide(en->cursor_fg);
+ if (en->cursor_bg) evas_object_hide(en->cursor_bg);
+
+ /* move cursor to the start point of the word */
+ do {
+ ct = _edje_entry_cursor_content_get(rp, EDJE_CURSOR_MAIN);
+ if (!ct || strlen(ct) == 0) return EINA_FALSE;
+ if (_is_separator(rp, ct))
+ {
+ _curs_next(en->cursor, rp->object, en);
+ break;
+ }
+ } while (_curs_back(en->cursor, rp->object, en));
+
+ _sel_clear(en->cursor, rp->object, en);
+ _sel_enable(en->cursor, rp->object, en);
+ _sel_start(en->cursor, rp->object, en);
+
+ /* move cursor to the end point of the word */
+ do {
+ ct = _edje_entry_cursor_content_get(rp, EDJE_CURSOR_MAIN);
+ if (!ct || strlen(ct) == 0) break;
+ if (_is_separator(rp, ct)) break;
+ } while (_curs_next(en->cursor, rp->object, en));
+
+ _sel_extend(en->cursor, rp->object, en);
+ _edje_entry_real_part_configure(rp);
+
+ return EINA_TRUE;
+}
+
+static void
+_edje_entry_mouse_double_clicked(void *data, Evas_Object *obj __UNUSED__,
const char *emission __UNUSED__, const char *source __UNUSED__)
+{
+ Edje_Real_Part *rp = data;
+ Entry *en;
+ if (!rp) return;
+ en = rp->entry_data;
+
+ if (!en) return;
+ _sel_clear(en->cursor, rp->object, en);
+
+ en->select_allow = EINA_FALSE;
+
+ if (_edje_entry_select_word(rp))
+ {
+ en->had_sel = EINA_TRUE;
+ en->have_selection = EINA_TRUE;
+ en->select_allow = EINA_TRUE;
+ }
+}
+
void
_edje_entry_input_panel_layout_set(Edje_Real_Part *rp, Edje_Input_Panel_Layout
layout)
{
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of
discussion for anyone considering optimizing the pricing and packaging model
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel