2008-10-13 02:19:04 -07:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
|
|
|
|
2008-10-26 10:18:19 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_ALLOCA_H
|
|
|
|
# include <alloca.h>
|
|
|
|
#elif defined __GNUC__
|
|
|
|
# define alloca __builtin_alloca
|
|
|
|
#elif defined _AIX
|
|
|
|
# define alloca __alloca
|
|
|
|
#elif defined _MSC_VER
|
|
|
|
# include <malloc.h>
|
|
|
|
# define alloca _alloca
|
|
|
|
#else
|
|
|
|
# include <stddef.h>
|
|
|
|
# ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
# endif
|
|
|
|
void *alloca (size_t);
|
|
|
|
#endif
|
|
|
|
|
2008-10-13 02:19:04 -07:00
|
|
|
#include "edje_private.h"
|
|
|
|
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
static int _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos);
|
|
|
|
static int _edje_entry_imf_event_commit_cb(void *data, int type, void *event);
|
|
|
|
static int _edje_entry_imf_event_changed_cb(void *data, int type, void *event);
|
|
|
|
static int _edje_entry_imf_event_delete_surrounding_cb(void *data, int type, void *event);
|
2009-05-13 15:11:06 -07:00
|
|
|
#endif
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2008-10-13 02:19:04 -07:00
|
|
|
typedef struct _Entry Entry;
|
2008-10-15 02:58:25 -07:00
|
|
|
typedef struct _Sel Sel;
|
2008-10-16 23:40:46 -07:00
|
|
|
typedef struct _Anchor Anchor;
|
2008-10-13 02:19:04 -07:00
|
|
|
|
|
|
|
struct _Entry
|
|
|
|
{
|
2008-10-15 08:15:06 -07:00
|
|
|
Edje_Real_Part *rp;
|
|
|
|
Evas_Coord cx, cy;
|
2008-10-13 02:19:04 -07:00
|
|
|
Evas_Object *cursor_bg;
|
|
|
|
Evas_Object *cursor_fg;
|
|
|
|
Evas_Textblock_Cursor *cursor;
|
|
|
|
Evas_Textblock_Cursor *sel_start, *sel_end;
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *sel;
|
|
|
|
Eina_List *anchors;
|
|
|
|
Eina_List *anchorlist;
|
2010-04-26 07:55:45 -07:00
|
|
|
Eina_List *itemlist;
|
2008-10-16 02:17:44 -07:00
|
|
|
char *selection;
|
2009-06-17 04:10:32 -07:00
|
|
|
Eina_Bool selecting : 1;
|
|
|
|
Eina_Bool have_selection : 1;
|
|
|
|
Eina_Bool select_allow : 1;
|
|
|
|
Eina_Bool select_mod_start : 1;
|
|
|
|
Eina_Bool select_mod_end : 1;
|
|
|
|
Eina_Bool had_sel : 1;
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
int comp_len;
|
2009-06-17 04:10:32 -07:00
|
|
|
Eina_Bool have_composition : 1;
|
2009-05-13 06:29:30 -07:00
|
|
|
Ecore_IMF_Context *imf_context;
|
|
|
|
|
|
|
|
Ecore_Event_Handler *imf_ee_handler_commit;
|
|
|
|
Ecore_Event_Handler *imf_ee_handler_delete;
|
|
|
|
Ecore_Event_Handler *imf_ee_handler_changed;
|
|
|
|
#endif
|
2008-10-13 02:19:04 -07:00
|
|
|
};
|
|
|
|
|
2008-10-15 02:58:25 -07:00
|
|
|
struct _Sel
|
|
|
|
{
|
|
|
|
Evas_Textblock_Rectangle rect;
|
2008-10-23 17:44:26 -07:00
|
|
|
Evas_Object *obj_fg, *obj_bg, *obj, *sobj;
|
2008-10-16 23:40:46 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Anchor
|
|
|
|
{
|
|
|
|
Entry *en;
|
|
|
|
char *name;
|
|
|
|
Evas_Textblock_Cursor *start, *end;
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *sel;
|
2010-04-25 06:06:58 -07:00
|
|
|
Eina_Bool item : 1;
|
2008-10-15 02:58:25 -07:00
|
|
|
};
|
|
|
|
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_entry_focus_in_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2009-05-13 06:29:30 -07:00
|
|
|
{
|
2009-08-24 10:20:33 -07:00
|
|
|
Edje_Real_Part *rp;
|
|
|
|
Entry *en;
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-08-24 10:20:33 -07:00
|
|
|
rp = data;
|
|
|
|
if (!rp || !rp->entry_data || !rp->edje || !rp->edje->obj) return;
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-08-24 10:20:33 -07:00
|
|
|
en = rp->entry_data;
|
2009-05-13 06:29:30 -07:00
|
|
|
if (!en->imf_context) return;
|
|
|
|
|
|
|
|
if (evas_object_focus_get(rp->edje->obj))
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_focus_in(en->imf_context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_entry_focus_out_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2009-05-13 06:29:30 -07:00
|
|
|
{
|
2009-08-24 10:20:33 -07:00
|
|
|
Edje_Real_Part *rp;
|
|
|
|
Entry *en;
|
|
|
|
|
|
|
|
rp = data;
|
|
|
|
if (!rp || !rp->entry_data) return;
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-08-24 10:20:33 -07:00
|
|
|
en = rp->entry_data;
|
2009-05-13 06:29:30 -07:00
|
|
|
if (!en->imf_context) return;
|
|
|
|
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context, evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
ecore_imf_context_focus_out(en->imf_context);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-13 02:19:04 -07:00
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_focus_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
|
|
|
Edje *ed = data;
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
Edje_Real_Part *rp;
|
|
|
|
Entry *en;
|
|
|
|
#endif
|
|
|
|
|
2008-10-13 02:19:04 -07:00
|
|
|
_edje_emit(ed, "focus,in", "");
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
rp = ed->focused_part;
|
|
|
|
if (rp == NULL) return;
|
|
|
|
|
|
|
|
en = rp->entry_data;
|
|
|
|
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
|
|
|
|
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_focus_in(en->imf_context);
|
|
|
|
}
|
|
|
|
#endif
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_focus_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
|
|
|
Edje *ed = data;
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
Edje_Real_Part *rp = ed->focused_part;
|
|
|
|
Entry *en;
|
|
|
|
#endif
|
|
|
|
|
2008-10-13 02:19:04 -07:00
|
|
|
_edje_emit(ed, "focus,out", "");
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
if (!rp) return;
|
|
|
|
en = rp->entry_data;
|
|
|
|
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
|
|
|
|
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
ecore_imf_context_focus_out(en->imf_context);
|
|
|
|
}
|
|
|
|
#endif
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
|
2008-10-15 08:15:06 -07:00
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_curs_update_from_curs(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en)
|
2008-10-15 08:15:06 -07:00
|
|
|
{
|
|
|
|
Evas_Coord cx, cy, cw, ch;
|
2009-12-01 03:02:46 -08:00
|
|
|
if (c != en->cursor) return;
|
2008-10-15 08:15:06 -07:00
|
|
|
evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
|
|
|
|
en->cx = cx + (cw / 2);
|
|
|
|
en->cy = cy + (ch / 2);
|
|
|
|
}
|
|
|
|
|
2008-10-15 02:58:25 -07:00
|
|
|
static void
|
|
|
|
_curs_back(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
2008-10-15 08:15:06 -07:00
|
|
|
if (!evas_textblock_cursor_char_prev(c))
|
2008-10-15 02:58:25 -07:00
|
|
|
{
|
2008-10-15 08:15:06 -07:00
|
|
|
if (evas_textblock_cursor_node_prev(c))
|
|
|
|
{
|
|
|
|
while (evas_textblock_cursor_node_format_get(c))
|
|
|
|
{
|
|
|
|
if (evas_textblock_cursor_node_format_is_visible_get(c)) break;
|
|
|
|
if (!evas_textblock_cursor_node_prev(c)) break;
|
|
|
|
}
|
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
2008-10-15 08:15:06 -07:00
|
|
|
_curs_update_from_curs(c, o, en);
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_curs_next(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
2010-03-15 21:10:03 -07:00
|
|
|
int ln, ln2, ok;
|
2009-05-14 05:53:56 -07:00
|
|
|
Eina_Bool eol;
|
|
|
|
|
|
|
|
ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
|
|
|
|
eol = evas_textblock_cursor_eol_get(c);
|
2008-10-15 08:15:06 -07:00
|
|
|
if (!evas_textblock_cursor_char_next(c))
|
2008-10-15 02:58:25 -07:00
|
|
|
{
|
2009-05-14 05:53:56 -07:00
|
|
|
if (!eol)
|
|
|
|
{
|
|
|
|
ln2 = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
|
|
|
|
if (ln2 != ln)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_char_prev(c);
|
|
|
|
evas_textblock_cursor_eol_set(c, 1);
|
2010-03-13 05:25:40 -08:00
|
|
|
_curs_update_from_curs(c, o, en);
|
|
|
|
return;
|
|
|
|
}
|
2010-03-15 21:10:03 -07:00
|
|
|
ok = evas_textblock_cursor_node_next(c);
|
|
|
|
if (!ok)
|
2010-03-13 05:25:40 -08:00
|
|
|
{
|
|
|
|
evas_textblock_cursor_line_last(c);
|
|
|
|
_curs_update_from_curs(c, o, en);
|
2009-05-14 05:53:56 -07:00
|
|
|
return;
|
|
|
|
}
|
2010-03-15 21:10:03 -07:00
|
|
|
while (evas_textblock_cursor_node_format_get(c))
|
|
|
|
{
|
|
|
|
if (evas_textblock_cursor_node_format_is_visible_get(c))
|
|
|
|
break;
|
|
|
|
if (!evas_textblock_cursor_node_next(c))
|
|
|
|
break;
|
|
|
|
}
|
2010-03-15 02:45:02 -07:00
|
|
|
return;
|
2009-05-14 05:53:56 -07:00
|
|
|
}
|
|
|
|
evas_textblock_cursor_eol_set(c, 0);
|
2008-10-15 08:15:06 -07:00
|
|
|
if (evas_textblock_cursor_node_next(c))
|
|
|
|
{
|
|
|
|
while (evas_textblock_cursor_node_format_get(c))
|
|
|
|
{
|
2008-10-16 18:40:10 -07:00
|
|
|
if (evas_textblock_cursor_node_format_is_visible_get(c))
|
|
|
|
break;
|
|
|
|
if (!evas_textblock_cursor_node_next(c))
|
|
|
|
break;
|
2008-10-15 08:15:06 -07:00
|
|
|
}
|
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
2008-10-16 18:40:10 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
int len, pos;
|
|
|
|
|
|
|
|
len = evas_textblock_cursor_node_text_length_get(c);
|
|
|
|
pos = evas_textblock_cursor_pos_get(c);
|
|
|
|
if (pos == len)
|
2009-05-14 05:53:56 -07:00
|
|
|
{
|
|
|
|
evas_textblock_cursor_node_next(c);
|
|
|
|
if (!eol)
|
|
|
|
{
|
|
|
|
ln2 = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
|
|
|
|
if (ln2 != ln)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_node_prev(c);
|
|
|
|
evas_textblock_cursor_line_last(c);
|
2010-03-13 05:25:40 -08:00
|
|
|
_curs_update_from_curs(c, o, en);
|
2009-05-14 05:53:56 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!eol)
|
|
|
|
{
|
|
|
|
ln2 = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
|
|
|
|
if (ln2 != ln)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_char_prev(c);
|
|
|
|
evas_textblock_cursor_eol_set(c, 1);
|
2010-03-13 05:25:40 -08:00
|
|
|
_curs_update_from_curs(c, o, en);
|
2009-05-14 05:53:56 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
evas_textblock_cursor_eol_set(c, 0);
|
2008-10-16 18:40:10 -07:00
|
|
|
}
|
2008-10-15 08:15:06 -07:00
|
|
|
_curs_update_from_curs(c, o, en);
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-08-24 09:40:42 -07:00
|
|
|
_curs_line_last_get(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en __UNUSED__)
|
2008-10-15 02:58:25 -07:00
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *cc;
|
|
|
|
int ln;
|
|
|
|
|
|
|
|
cc = evas_object_textblock_cursor_new(o);
|
|
|
|
evas_textblock_cursor_node_last(cc);
|
|
|
|
ln = evas_textblock_cursor_line_geometry_get(cc, NULL, NULL, NULL, NULL);
|
|
|
|
evas_textblock_cursor_free(cc);
|
|
|
|
return ln;
|
|
|
|
}
|
|
|
|
|
2010-04-17 08:50:27 -07:00
|
|
|
static void
|
|
|
|
_curs_lin_start(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_line_first(c);
|
|
|
|
_curs_update_from_curs(c, o, en);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_curs_lin_end(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_line_last(c);
|
|
|
|
// if (!evas_textblock_cursor_node_format_get(c))
|
|
|
|
// _curs_next(c, o, en);
|
|
|
|
_curs_update_from_curs(c, o, en);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_curs_start(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_line_set(c, 0);
|
|
|
|
evas_textblock_cursor_line_first(c);
|
|
|
|
_curs_update_from_curs(c, o, en);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_curs_end(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_node_last(c);
|
|
|
|
_curs_lin_end(c, o, en);
|
|
|
|
// evas_textblock_cursor_line_set(c, _curs_line_last_get(c, o, en));
|
|
|
|
// _curs_lin_end(c, o, en);
|
|
|
|
_curs_update_from_curs(c, o, en);
|
|
|
|
}
|
|
|
|
|
2008-10-15 02:58:25 -07:00
|
|
|
static void
|
|
|
|
_curs_jump_line(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int ln)
|
|
|
|
{
|
2008-10-15 08:15:06 -07:00
|
|
|
Evas_Coord lx, ly, lw, lh;
|
2010-04-17 08:50:27 -07:00
|
|
|
int last = _curs_line_last_get(c, o, en);
|
2008-10-15 02:58:25 -07:00
|
|
|
|
|
|
|
if (ln < 0) ln = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ln > last) ln = last;
|
|
|
|
}
|
|
|
|
if (!evas_object_textblock_line_number_geometry_get(o, ln, &lx, &ly, &lw, &lh))
|
|
|
|
return;
|
2008-10-15 08:15:06 -07:00
|
|
|
if (evas_textblock_cursor_char_coord_set(c, en->cx, ly + (lh / 2)))
|
2008-10-15 02:58:25 -07:00
|
|
|
return;
|
2010-04-17 09:19:28 -07:00
|
|
|
evas_textblock_cursor_line_set(c, ln);
|
2010-04-17 08:50:27 -07:00
|
|
|
if (en->cx < (lx + (lw / 2)))
|
|
|
|
{
|
|
|
|
if (ln == last) _curs_end(c, o, en);
|
2010-04-17 09:19:28 -07:00
|
|
|
// evas_textblock_cursor_line_first(c);
|
2010-04-17 08:50:27 -07:00
|
|
|
_curs_lin_start(c, o, en);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ln == last)
|
|
|
|
_curs_end(c, o, en);
|
|
|
|
else
|
|
|
|
_curs_lin_end(c, o, en);
|
2010-04-17 09:19:28 -07:00
|
|
|
// evas_textblock_cursor_line_last(c);
|
2010-04-17 08:50:27 -07:00
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_curs_jump_line_by(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int by)
|
|
|
|
{
|
|
|
|
int ln;
|
|
|
|
|
|
|
|
ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL) + by;
|
|
|
|
_curs_jump_line(c, o, en, ln);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_curs_up(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
|
|
|
_curs_jump_line_by(c, o, en, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_curs_down(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
|
|
|
_curs_jump_line_by(c, o, en, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_sel_start(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
|
|
|
if (en->sel_start) return;
|
|
|
|
en->sel_start = evas_object_textblock_cursor_new(o);
|
2008-10-16 02:17:44 -07:00
|
|
|
evas_textblock_cursor_copy(c, en->sel_start);
|
2008-10-15 02:58:25 -07:00
|
|
|
en->sel_end = evas_object_textblock_cursor_new(o);
|
2009-02-14 18:55:56 -08:00
|
|
|
evas_textblock_cursor_copy(c, en->sel_end);
|
2009-05-14 05:53:56 -07:00
|
|
|
|
2009-06-17 04:10:32 -07:00
|
|
|
en->have_selection = EINA_FALSE;
|
2008-11-18 18:14:50 -08:00
|
|
|
if (en->selection)
|
|
|
|
{
|
|
|
|
free(en->selection);
|
|
|
|
en->selection = NULL;
|
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_sel_enable(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
|
2008-10-15 02:58:25 -07:00
|
|
|
{
|
|
|
|
if (en->have_selection) return;
|
2009-06-17 04:10:32 -07:00
|
|
|
en->have_selection = EINA_TRUE;
|
2008-11-18 18:14:50 -08:00
|
|
|
if (en->selection)
|
|
|
|
{
|
|
|
|
free(en->selection);
|
|
|
|
en->selection = NULL;
|
|
|
|
}
|
2008-10-16 02:17:44 -07:00
|
|
|
_edje_emit(en->rp->edje, "selection,start", en->rp->part->name);
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_sel_extend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
|
|
|
if (!en->sel_end) return;
|
|
|
|
_sel_enable(c, o, en);
|
|
|
|
if (!evas_textblock_cursor_compare(c, en->sel_end)) return;
|
|
|
|
evas_textblock_cursor_copy(c, en->sel_end);
|
2008-11-18 18:14:50 -08:00
|
|
|
if (en->selection)
|
|
|
|
{
|
|
|
|
free(en->selection);
|
|
|
|
en->selection = NULL;
|
|
|
|
}
|
2008-10-16 02:17:44 -07:00
|
|
|
_edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
|
|
|
|
2009-03-22 06:50:53 -07:00
|
|
|
static void
|
|
|
|
_sel_preextend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
|
|
|
if (!en->sel_end) return;
|
|
|
|
_sel_enable(c, o, en);
|
|
|
|
if (!evas_textblock_cursor_compare(c, en->sel_start)) return;
|
|
|
|
evas_textblock_cursor_copy(c, en->sel_start);
|
|
|
|
if (en->selection)
|
|
|
|
{
|
|
|
|
free(en->selection);
|
|
|
|
en->selection = NULL;
|
|
|
|
}
|
|
|
|
_edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
|
|
|
|
}
|
|
|
|
|
2008-10-15 02:58:25 -07:00
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_sel_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
|
2008-10-15 02:58:25 -07:00
|
|
|
{
|
2009-06-17 04:10:32 -07:00
|
|
|
en->had_sel = EINA_FALSE;
|
2008-10-15 02:58:25 -07:00
|
|
|
if (en->sel_start)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_free(en->sel_start);
|
|
|
|
evas_textblock_cursor_free(en->sel_end);
|
|
|
|
en->sel_start = NULL;
|
|
|
|
en->sel_end = NULL;
|
|
|
|
}
|
2008-10-16 02:17:44 -07:00
|
|
|
if (en->selection)
|
|
|
|
{
|
|
|
|
free(en->selection);
|
|
|
|
en->selection = NULL;
|
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
while (en->sel)
|
|
|
|
{
|
|
|
|
Sel *sel;
|
|
|
|
|
|
|
|
sel = en->sel->data;
|
2008-11-16 21:54:01 -08:00
|
|
|
en->rp->edje->subobjs = eina_list_remove(en->rp->edje->subobjs, sel->obj_bg);
|
|
|
|
en->rp->edje->subobjs = eina_list_remove(en->rp->edje->subobjs, sel->obj_fg);
|
2008-10-15 02:58:25 -07:00
|
|
|
if (sel->obj_bg) evas_object_del(sel->obj_bg);
|
|
|
|
if (sel->obj_fg) evas_object_del(sel->obj_fg);
|
|
|
|
free(sel);
|
2008-10-22 04:34:42 -07:00
|
|
|
en->sel = eina_list_remove_list(en->sel, en->sel);
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
2008-10-16 02:17:44 -07:00
|
|
|
if (en->have_selection)
|
|
|
|
{
|
2009-06-17 04:10:32 -07:00
|
|
|
en->have_selection = EINA_FALSE;
|
2008-10-16 02:17:44 -07:00
|
|
|
_edje_emit(en->rp->edje, "selection,cleared", en->rp->part->name);
|
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_sel_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
|
2008-10-15 02:58:25 -07:00
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *range = NULL, *l;
|
2008-10-15 02:58:25 -07:00
|
|
|
Sel *sel;
|
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
Evas_Object *smart, *clip;
|
|
|
|
|
|
|
|
smart = evas_object_smart_parent_get(o);
|
|
|
|
clip = evas_object_clip_get(o);
|
|
|
|
if (en->sel_start)
|
|
|
|
range = evas_textblock_cursor_range_geometry_get(en->sel_start, en->sel_end);
|
2009-03-18 14:27:38 -07:00
|
|
|
else
|
|
|
|
return;
|
2008-10-22 04:34:42 -07:00
|
|
|
if (eina_list_count(range) != eina_list_count(en->sel))
|
2008-10-15 02:58:25 -07:00
|
|
|
{
|
|
|
|
while (en->sel)
|
|
|
|
{
|
|
|
|
sel = en->sel->data;
|
2008-11-16 21:54:01 -08:00
|
|
|
en->rp->edje->subobjs = eina_list_remove(en->rp->edje->subobjs, sel->obj_bg);
|
|
|
|
en->rp->edje->subobjs = eina_list_remove(en->rp->edje->subobjs, sel->obj_fg);
|
2008-10-15 02:58:25 -07:00
|
|
|
if (sel->obj_bg) evas_object_del(sel->obj_bg);
|
|
|
|
if (sel->obj_fg) evas_object_del(sel->obj_fg);
|
|
|
|
free(sel);
|
2008-10-22 04:34:42 -07:00
|
|
|
en->sel = eina_list_remove_list(en->sel, en->sel);
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
|
|
|
if (en->have_selection)
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
for (l = range; l; l = eina_list_next(l))
|
2008-10-15 02:58:25 -07:00
|
|
|
{
|
2008-10-16 23:40:46 -07:00
|
|
|
Evas_Object *ob;
|
|
|
|
|
2008-10-15 02:58:25 -07:00
|
|
|
sel = calloc(1, sizeof(Sel));
|
2008-10-22 04:34:42 -07:00
|
|
|
en->sel = eina_list_append(en->sel, sel);
|
2008-10-15 08:15:06 -07:00
|
|
|
ob = edje_object_add(en->rp->edje->evas);
|
|
|
|
edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source);
|
2008-10-15 02:58:25 -07:00
|
|
|
evas_object_smart_member_add(ob, smart);
|
|
|
|
evas_object_stack_below(ob, o);
|
|
|
|
evas_object_clip_set(ob, clip);
|
|
|
|
evas_object_pass_events_set(ob, 1);
|
|
|
|
evas_object_show(ob);
|
|
|
|
sel->obj_bg = ob;
|
2008-11-16 21:54:01 -08:00
|
|
|
en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, sel->obj_bg);
|
|
|
|
|
2008-10-15 08:15:06 -07:00
|
|
|
ob = edje_object_add(en->rp->edje->evas);
|
|
|
|
edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source2);
|
|
|
|
evas_object_smart_member_add(ob, smart);
|
|
|
|
evas_object_stack_above(ob, o);
|
|
|
|
evas_object_clip_set(ob, clip);
|
|
|
|
evas_object_pass_events_set(ob, 1);
|
|
|
|
evas_object_show(ob);
|
|
|
|
sel->obj_fg = ob;
|
2008-11-16 21:54:01 -08:00
|
|
|
en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, sel->obj_fg);
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
x = y = w = h = -1;
|
|
|
|
evas_object_geometry_get(o, &x, &y, &w, &h);
|
2008-10-27 21:58:39 -07:00
|
|
|
if (en->have_selection)
|
2008-10-15 02:58:25 -07:00
|
|
|
{
|
2008-10-27 21:58:39 -07:00
|
|
|
EINA_LIST_FOREACH(en->sel, l, sel)
|
2008-10-15 02:58:25 -07:00
|
|
|
{
|
2008-10-27 21:58:39 -07:00
|
|
|
Evas_Textblock_Rectangle *r;
|
|
|
|
|
|
|
|
r = range->data;
|
|
|
|
if (sel->obj_bg)
|
|
|
|
{
|
|
|
|
evas_object_move(sel->obj_bg, x + r->x, y + r->y);
|
|
|
|
evas_object_resize(sel->obj_bg, r->w, r->h);
|
|
|
|
}
|
|
|
|
if (sel->obj_fg)
|
|
|
|
{
|
|
|
|
evas_object_move(sel->obj_fg, x + r->x, y + r->y);
|
|
|
|
evas_object_resize(sel->obj_fg, r->w, r->h);
|
|
|
|
}
|
2009-03-22 06:50:53 -07:00
|
|
|
*(&(sel->rect)) = *r;
|
2008-10-27 21:58:39 -07:00
|
|
|
range = eina_list_remove_list(range, range);
|
|
|
|
free(r);
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
2008-10-27 21:58:39 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (range)
|
2008-10-15 02:58:25 -07:00
|
|
|
{
|
2008-10-27 21:58:39 -07:00
|
|
|
free(range->data);
|
|
|
|
range = eina_list_remove_list(range, range);
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-16 23:40:46 -07:00
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_anchor_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2008-10-16 23:40:46 -07:00
|
|
|
{
|
|
|
|
Anchor *an = data;
|
|
|
|
Evas_Event_Mouse_Down *ev = event_info;
|
|
|
|
Edje_Real_Part *rp = an->en->rp;
|
|
|
|
char *buf, *n;
|
|
|
|
int len;
|
|
|
|
int ignored;
|
2009-03-22 06:50:53 -07:00
|
|
|
Entry *en;
|
|
|
|
|
|
|
|
en = rp->entry_data;
|
|
|
|
if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) &&
|
|
|
|
(en->select_allow))
|
|
|
|
return;
|
2008-10-16 23:40:46 -07:00
|
|
|
ignored = rp->part->ignore_flags & ev->event_flags;
|
|
|
|
if ((!ev->event_flags) || (!ignored))
|
|
|
|
{
|
|
|
|
n = an->name;
|
|
|
|
if (!n) n = "";
|
|
|
|
len = 200 + strlen(n);
|
|
|
|
buf = alloca(len);
|
|
|
|
if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
|
|
|
|
snprintf(buf, len, "anchor,mouse,down,%i,%s,triple", ev->button, an->name);
|
|
|
|
else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
|
|
|
|
snprintf(buf, len, "anchor,mouse,down,%i,%s,double", ev->button, an->name);
|
|
|
|
else
|
|
|
|
snprintf(buf, len, "anchor,mouse,down,%i,%s", ev->button, an->name);
|
|
|
|
_edje_emit(rp->edje, buf, rp->part->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_anchor_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2008-10-16 23:40:46 -07:00
|
|
|
{
|
|
|
|
Anchor *an = data;
|
|
|
|
Evas_Event_Mouse_Up *ev = event_info;
|
|
|
|
Edje_Real_Part *rp = an->en->rp;
|
|
|
|
char *buf, *n;
|
|
|
|
int len;
|
|
|
|
int ignored;
|
2009-03-22 06:50:53 -07:00
|
|
|
Entry *en;
|
|
|
|
|
|
|
|
en = rp->entry_data;
|
2008-10-16 23:40:46 -07:00
|
|
|
ignored = rp->part->ignore_flags & ev->event_flags;
|
2009-03-22 06:50:53 -07:00
|
|
|
if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) &&
|
|
|
|
(en->select_allow))
|
|
|
|
return;
|
2008-10-16 23:40:46 -07:00
|
|
|
if ((!ev->event_flags) || (!ignored))
|
|
|
|
{
|
|
|
|
n = an->name;
|
|
|
|
if (!n) n = "";
|
|
|
|
len = 200 + strlen(n);
|
|
|
|
buf = alloca(len);
|
|
|
|
snprintf(buf, len, "anchor,mouse,up,%i,%s", ev->button, an->name);
|
|
|
|
_edje_emit(rp->edje, buf, rp->part->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_anchor_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2008-10-16 23:40:46 -07:00
|
|
|
{
|
|
|
|
Anchor *an = data;
|
|
|
|
Evas_Event_Mouse_Move *ev = event_info;
|
|
|
|
Edje_Real_Part *rp = an->en->rp;
|
|
|
|
char *buf, *n;
|
|
|
|
int len;
|
|
|
|
int ignored;
|
2009-03-22 06:50:53 -07:00
|
|
|
Entry *en;
|
|
|
|
|
|
|
|
en = rp->entry_data;
|
|
|
|
if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) &&
|
|
|
|
(en->select_allow))
|
|
|
|
return;
|
2008-10-16 23:40:46 -07:00
|
|
|
ignored = rp->part->ignore_flags & ev->event_flags;
|
|
|
|
if ((!ev->event_flags) || (!ignored))
|
|
|
|
{
|
|
|
|
n = an->name;
|
|
|
|
if (!n) n = "";
|
|
|
|
len = 200 + strlen(n);
|
|
|
|
buf = alloca(len);
|
|
|
|
snprintf(buf, len, "anchor,mouse,move,%s", an->name);
|
|
|
|
_edje_emit(rp->edje, buf, rp->part->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_anchor_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2008-10-16 23:40:46 -07:00
|
|
|
{
|
|
|
|
Anchor *an = data;
|
|
|
|
Evas_Event_Mouse_In *ev = event_info;
|
|
|
|
Edje_Real_Part *rp = an->en->rp;
|
|
|
|
char *buf, *n;
|
|
|
|
int len;
|
|
|
|
int ignored;
|
|
|
|
|
|
|
|
ignored = rp->part->ignore_flags & ev->event_flags;
|
|
|
|
if ((!ev->event_flags) || (!ignored))
|
|
|
|
{
|
|
|
|
n = an->name;
|
|
|
|
if (!n) n = "";
|
|
|
|
len = 200 + strlen(n);
|
|
|
|
buf = alloca(len);
|
|
|
|
snprintf(buf, len, "anchor,mouse,in,%s", an->name);
|
|
|
|
_edje_emit(rp->edje, buf, rp->part->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_anchor_mouse_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2008-10-16 23:40:46 -07:00
|
|
|
{
|
|
|
|
Anchor *an = data;
|
|
|
|
Evas_Event_Mouse_Out *ev = event_info;
|
|
|
|
Edje_Real_Part *rp = an->en->rp;
|
|
|
|
char *buf, *n;
|
|
|
|
int len;
|
|
|
|
int ignored;
|
|
|
|
|
|
|
|
ignored = rp->part->ignore_flags & ev->event_flags;
|
|
|
|
if ((!ev->event_flags) || (!ignored))
|
|
|
|
{
|
|
|
|
n = an->name;
|
|
|
|
if (!n) n = "";
|
|
|
|
len = 200 + strlen(n);
|
|
|
|
buf = alloca(len);
|
|
|
|
snprintf(buf, len, "anchor,mouse,out,%s", an->name);
|
|
|
|
_edje_emit(rp->edje, buf, rp->part->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_anchors_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
|
2008-10-16 23:40:46 -07:00
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l, *ll, *range;
|
2008-10-16 23:40:46 -07:00
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
Evas_Object *smart, *clip;
|
|
|
|
Sel *sel;
|
2008-10-22 04:34:42 -07:00
|
|
|
Anchor *an;
|
|
|
|
|
2008-10-16 23:40:46 -07:00
|
|
|
smart = evas_object_smart_parent_get(o);
|
|
|
|
clip = evas_object_clip_get(o);
|
|
|
|
x = y = w = h = -1;
|
|
|
|
evas_object_geometry_get(o, &x, &y, &w, &h);
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(en->anchors, l, an)
|
2008-10-16 23:40:46 -07:00
|
|
|
{
|
2010-04-25 06:06:58 -07:00
|
|
|
// for item anchors
|
|
|
|
if (an->item)
|
|
|
|
{
|
|
|
|
Evas_Object *ob;
|
|
|
|
|
2008-10-16 23:40:46 -07:00
|
|
|
while (an->sel)
|
|
|
|
{
|
|
|
|
sel = an->sel->data;
|
2008-11-16 21:54:01 -08:00
|
|
|
en->rp->edje->subobjs = eina_list_remove(en->rp->edje->subobjs, sel->obj_bg);
|
|
|
|
en->rp->edje->subobjs = eina_list_remove(en->rp->edje->subobjs, sel->obj_fg);
|
2008-10-16 23:40:46 -07:00
|
|
|
if (sel->obj_bg) evas_object_del(sel->obj_bg);
|
|
|
|
if (sel->obj_fg) evas_object_del(sel->obj_fg);
|
|
|
|
if (sel->obj) evas_object_del(sel->obj);
|
|
|
|
free(sel);
|
2008-10-22 04:34:42 -07:00
|
|
|
an->sel = eina_list_remove_list(an->sel, an->sel);
|
2008-10-16 23:40:46 -07:00
|
|
|
}
|
2008-10-22 04:34:42 -07:00
|
|
|
|
2010-04-25 06:06:58 -07:00
|
|
|
sel = calloc(1, sizeof(Sel));
|
|
|
|
an->sel = eina_list_append(an->sel, sel);
|
2010-04-26 07:55:45 -07:00
|
|
|
/*
|
2010-04-25 06:06:58 -07:00
|
|
|
ob = evas_object_rectangle_add(en->rp->edje->evas);
|
|
|
|
evas_object_color_set(ob, 0, 0, 0, 0);
|
|
|
|
evas_object_smart_member_add(ob, smart);
|
|
|
|
evas_object_stack_above(ob, o);
|
|
|
|
evas_object_clip_set(ob, clip);
|
2010-04-25 06:57:41 -07:00
|
|
|
evas_object_pass_events_set(ob, 1);
|
2010-04-25 06:06:58 -07:00
|
|
|
evas_object_show(ob);
|
2010-04-26 07:55:45 -07:00
|
|
|
*/
|
|
|
|
if (en->rp->edje->item_provider.func)
|
|
|
|
{
|
|
|
|
ob = en->rp->edje->item_provider.func
|
|
|
|
(en->rp->edje->item_provider.data, smart,
|
|
|
|
en->rp->part->name, an->name);
|
|
|
|
evas_object_smart_member_add(ob, smart);
|
|
|
|
evas_object_stack_above(ob, o);
|
|
|
|
evas_object_clip_set(ob, clip);
|
|
|
|
evas_object_pass_events_set(ob, 1);
|
|
|
|
evas_object_show(ob);
|
|
|
|
sel->obj = ob;
|
|
|
|
}
|
2010-04-25 06:06:58 -07:00
|
|
|
}
|
|
|
|
// for link anchors
|
|
|
|
else
|
|
|
|
{
|
|
|
|
range = evas_textblock_cursor_range_geometry_get(an->start, an->end);
|
|
|
|
if (eina_list_count(range) != eina_list_count(an->sel))
|
|
|
|
{
|
|
|
|
while (an->sel)
|
|
|
|
{
|
|
|
|
sel = an->sel->data;
|
|
|
|
en->rp->edje->subobjs = eina_list_remove(en->rp->edje->subobjs, sel->obj_bg);
|
|
|
|
en->rp->edje->subobjs = eina_list_remove(en->rp->edje->subobjs, sel->obj_fg);
|
|
|
|
if (sel->obj_bg) evas_object_del(sel->obj_bg);
|
|
|
|
if (sel->obj_fg) evas_object_del(sel->obj_fg);
|
|
|
|
if (sel->obj) evas_object_del(sel->obj);
|
|
|
|
free(sel);
|
|
|
|
an->sel = eina_list_remove_list(an->sel, an->sel);
|
|
|
|
}
|
|
|
|
for (ll = range; ll; ll = eina_list_next(ll))
|
|
|
|
{
|
|
|
|
Evas_Object *ob;
|
|
|
|
|
|
|
|
sel = calloc(1, sizeof(Sel));
|
|
|
|
an->sel = eina_list_append(an->sel, sel);
|
|
|
|
ob = edje_object_add(en->rp->edje->evas);
|
|
|
|
edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source5);
|
|
|
|
evas_object_smart_member_add(ob, smart);
|
|
|
|
evas_object_stack_below(ob, o);
|
|
|
|
evas_object_clip_set(ob, clip);
|
|
|
|
evas_object_pass_events_set(ob, 1);
|
|
|
|
evas_object_show(ob);
|
|
|
|
sel->obj_bg = ob;
|
|
|
|
en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, sel->obj_bg);
|
|
|
|
|
|
|
|
ob = edje_object_add(en->rp->edje->evas);
|
|
|
|
edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source6);
|
|
|
|
evas_object_smart_member_add(ob, smart);
|
|
|
|
evas_object_stack_above(ob, o);
|
|
|
|
evas_object_clip_set(ob, clip);
|
|
|
|
evas_object_pass_events_set(ob, 1);
|
|
|
|
evas_object_show(ob);
|
|
|
|
sel->obj_fg = ob;
|
|
|
|
en->rp->edje->subobjs = eina_list_append(en->rp->edje->subobjs, sel->obj_fg);
|
|
|
|
|
|
|
|
ob = evas_object_rectangle_add(en->rp->edje->evas);
|
|
|
|
evas_object_color_set(ob, 0, 0, 0, 0);
|
|
|
|
evas_object_smart_member_add(ob, smart);
|
|
|
|
evas_object_stack_above(ob, o);
|
|
|
|
evas_object_clip_set(ob, clip);
|
|
|
|
evas_object_repeat_events_set(ob, 1);
|
|
|
|
evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_DOWN, _edje_anchor_mouse_down_cb, an);
|
|
|
|
evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_UP, _edje_anchor_mouse_up_cb, an);
|
|
|
|
evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_MOVE, _edje_anchor_mouse_move_cb, an);
|
|
|
|
evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_IN, _edje_anchor_mouse_in_cb, an);
|
|
|
|
evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_OUT, _edje_anchor_mouse_out_cb, an);
|
|
|
|
evas_object_show(ob);
|
|
|
|
sel->obj = ob;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EINA_LIST_FOREACH(an->sel, ll, sel)
|
|
|
|
{
|
|
|
|
if (an->item)
|
|
|
|
{
|
|
|
|
Evas_Coord cx, cy, cw, ch;
|
2008-11-16 21:54:01 -08:00
|
|
|
|
2010-04-25 06:06:58 -07:00
|
|
|
evas_textblock_cursor_format_item_geometry_get(an->start, &cx, &cy, &cw, &ch);
|
|
|
|
evas_object_move(sel->obj, x + cx, y + cy);
|
|
|
|
evas_object_resize(sel->obj, cw, ch);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Evas_Textblock_Rectangle *r;
|
2008-11-16 21:54:01 -08:00
|
|
|
|
2010-04-25 06:06:58 -07:00
|
|
|
r = range->data;
|
|
|
|
*(&(sel->rect)) = *r;
|
|
|
|
if (sel->obj_bg)
|
|
|
|
{
|
|
|
|
evas_object_move(sel->obj_bg, x + r->x, y + r->y);
|
|
|
|
evas_object_resize(sel->obj_bg, r->w, r->h);
|
|
|
|
}
|
|
|
|
if (sel->obj_fg)
|
|
|
|
{
|
|
|
|
evas_object_move(sel->obj_fg, x + r->x, y + r->y);
|
|
|
|
evas_object_resize(sel->obj_fg, r->w, r->h);
|
|
|
|
}
|
|
|
|
if (sel->obj)
|
|
|
|
{
|
|
|
|
evas_object_move(sel->obj, x + r->x, y + r->y);
|
|
|
|
evas_object_resize(sel->obj, r->w, r->h);
|
|
|
|
}
|
|
|
|
range = eina_list_remove_list(range, range);
|
|
|
|
free(r);
|
|
|
|
}
|
2008-10-16 23:40:46 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_anchors_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
|
2008-10-16 23:40:46 -07:00
|
|
|
{
|
|
|
|
while (en->anchorlist)
|
|
|
|
{
|
|
|
|
free(en->anchorlist->data);
|
2008-10-22 04:34:42 -07:00
|
|
|
en->anchorlist = eina_list_remove_list(en->anchorlist, en->anchorlist);
|
2008-10-16 23:40:46 -07:00
|
|
|
}
|
2010-04-26 07:55:45 -07:00
|
|
|
while (en->itemlist)
|
|
|
|
{
|
|
|
|
free(en->itemlist->data);
|
|
|
|
en->itemlist = eina_list_remove_list(en->itemlist, en->itemlist);
|
|
|
|
}
|
2008-10-16 23:40:46 -07:00
|
|
|
while (en->anchors)
|
|
|
|
{
|
|
|
|
Anchor *an = en->anchors->data;
|
|
|
|
|
|
|
|
evas_textblock_cursor_free(an->start);
|
|
|
|
evas_textblock_cursor_free(an->end);
|
|
|
|
while (an->sel)
|
|
|
|
{
|
|
|
|
Sel *sel = an->sel->data;
|
2008-11-16 21:54:01 -08:00
|
|
|
en->rp->edje->subobjs = eina_list_remove(en->rp->edje->subobjs, sel->obj_bg);
|
|
|
|
en->rp->edje->subobjs = eina_list_remove(en->rp->edje->subobjs, sel->obj_fg);
|
2008-10-16 23:40:46 -07:00
|
|
|
if (sel->obj_bg) evas_object_del(sel->obj_bg);
|
|
|
|
if (sel->obj_fg) evas_object_del(sel->obj_fg);
|
|
|
|
if (sel->obj) evas_object_del(sel->obj);
|
|
|
|
free(sel);
|
2008-10-22 04:34:42 -07:00
|
|
|
an->sel = eina_list_remove_list(an->sel, an->sel);
|
2008-10-16 23:40:46 -07:00
|
|
|
}
|
2009-05-22 14:12:32 -07:00
|
|
|
free(an->name);
|
2008-10-24 19:14:48 -07:00
|
|
|
free(an);
|
2008-10-22 04:34:42 -07:00
|
|
|
en->anchors = eina_list_remove_list(en->anchors, en->anchors);
|
2008-10-16 23:40:46 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *c1;
|
|
|
|
Anchor *an = NULL;
|
|
|
|
int firsttext = 0;
|
|
|
|
|
|
|
|
_anchors_clear(c, o, en);
|
|
|
|
c1 = evas_object_textblock_cursor_new(o);
|
|
|
|
evas_textblock_cursor_node_first(c1);
|
|
|
|
do
|
|
|
|
{
|
2008-12-05 19:08:17 -08:00
|
|
|
const char *s;
|
2008-10-16 23:40:46 -07:00
|
|
|
|
|
|
|
s = evas_textblock_cursor_node_format_get(c1);
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
if ((!strncmp(s, "+ a ", 4)) || (!strncmp(s, "+a ", 3)))
|
|
|
|
{
|
|
|
|
an = calloc(1, sizeof(Anchor));
|
|
|
|
if (an)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
an->en = en;
|
|
|
|
p = strstr(s, "href=");
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
an->name = strdup(p + 5);
|
|
|
|
}
|
2008-10-22 04:34:42 -07:00
|
|
|
en->anchors = eina_list_append(en->anchors, an);
|
2008-10-16 23:40:46 -07:00
|
|
|
an->start = evas_object_textblock_cursor_new(o);
|
|
|
|
an->end = evas_object_textblock_cursor_new(o);
|
|
|
|
evas_textblock_cursor_copy(c1, an->start);
|
|
|
|
evas_textblock_cursor_copy(c1, an->end);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((!strcmp(s, "- a")) || (!strcmp(s, "-a")))
|
|
|
|
{
|
|
|
|
if (an)
|
|
|
|
{
|
|
|
|
if (!firsttext)
|
|
|
|
{
|
|
|
|
if (an->name) free(an->name);
|
|
|
|
evas_textblock_cursor_free(an->start);
|
|
|
|
evas_textblock_cursor_free(an->end);
|
2008-10-22 04:34:42 -07:00
|
|
|
en->anchors = eina_list_remove(en->anchors, an);
|
2008-10-16 23:40:46 -07:00
|
|
|
free(an);
|
|
|
|
}
|
|
|
|
firsttext = 0;
|
|
|
|
an = NULL;
|
|
|
|
}
|
|
|
|
}
|
2010-04-25 06:06:58 -07:00
|
|
|
else if (!strncmp(s, "+ item ", 7))
|
|
|
|
{
|
|
|
|
an = calloc(1, sizeof(Anchor));
|
|
|
|
if (an)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
an->en = en;
|
|
|
|
an->item = 1;
|
|
|
|
p = strstr(s, "href=");
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
an->name = strdup(p + 5);
|
|
|
|
}
|
|
|
|
en->anchors = eina_list_append(en->anchors, an);
|
|
|
|
an->start = evas_object_textblock_cursor_new(o);
|
|
|
|
an->end = evas_object_textblock_cursor_new(o);
|
|
|
|
evas_textblock_cursor_copy(c1, an->start);
|
|
|
|
evas_textblock_cursor_copy(c1, an->end);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((!strcmp(s, "- item")) || (!strcmp(s, "-item")))
|
|
|
|
{
|
|
|
|
if (an)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
if (!firsttext)
|
|
|
|
{
|
|
|
|
if (an->name) free(an->name);
|
|
|
|
evas_textblock_cursor_free(an->start);
|
|
|
|
evas_textblock_cursor_free(an->end);
|
|
|
|
en->anchors = eina_list_remove(en->anchors, an);
|
|
|
|
free(an);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
firsttext = 0;
|
|
|
|
an = NULL;
|
|
|
|
}
|
|
|
|
}
|
2008-10-16 23:40:46 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s = evas_textblock_cursor_node_text_get(c1);
|
|
|
|
if (an)
|
|
|
|
{
|
2010-04-25 06:06:58 -07:00
|
|
|
if (!an->item)
|
|
|
|
{
|
|
|
|
if (!firsttext)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_copy(c1, an->start);
|
|
|
|
firsttext = 1;
|
|
|
|
}
|
|
|
|
}
|
2008-10-16 23:40:46 -07:00
|
|
|
evas_textblock_cursor_char_last(c1);
|
|
|
|
evas_textblock_cursor_copy(c1, an->end);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (evas_textblock_cursor_node_next(c1));
|
|
|
|
evas_textblock_cursor_free(c1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-16 17:07:43 -07:00
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_range_del(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
|
2008-10-16 17:07:43 -07:00
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *c1;
|
|
|
|
|
|
|
|
c1 = evas_object_textblock_cursor_new(o);
|
|
|
|
evas_textblock_cursor_node_last(c1);
|
|
|
|
if (!evas_textblock_cursor_compare(en->sel_end, c1))
|
|
|
|
evas_textblock_cursor_node_prev(en->sel_end);
|
|
|
|
if (!evas_textblock_cursor_compare(en->sel_start, c1))
|
|
|
|
evas_textblock_cursor_node_prev(en->sel_start);
|
|
|
|
evas_textblock_cursor_free(c1);
|
|
|
|
evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
|
|
|
|
}
|
|
|
|
|
2008-10-16 18:40:10 -07:00
|
|
|
static void
|
|
|
|
_backspace(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *c1, *c2;
|
|
|
|
int nodel = 0;
|
|
|
|
|
|
|
|
c1 = evas_object_textblock_cursor_new(o);
|
|
|
|
if (!evas_textblock_cursor_char_prev(c))
|
|
|
|
{
|
|
|
|
if (!evas_textblock_cursor_node_prev(c))
|
|
|
|
nodel = 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_copy(c, c1);
|
|
|
|
if (evas_textblock_cursor_node_format_get(c) &&
|
|
|
|
(!evas_textblock_cursor_node_format_is_visible_get(c)))
|
|
|
|
_curs_back(c, o, en);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-03-13 05:25:40 -08:00
|
|
|
{
|
|
|
|
evas_textblock_cursor_copy(c, c1);
|
|
|
|
}
|
2008-10-16 18:40:10 -07:00
|
|
|
c2 = evas_object_textblock_cursor_new(o);
|
|
|
|
evas_textblock_cursor_copy(c, c2);
|
2010-03-13 05:25:40 -08:00
|
|
|
if (!nodel)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_range_delete(c1, c2);
|
|
|
|
}
|
2008-10-16 18:40:10 -07:00
|
|
|
evas_textblock_cursor_copy(c, c1);
|
|
|
|
_curs_back(c, o, en);
|
2010-03-13 05:25:40 -08:00
|
|
|
evas_textblock_cursor_copy(c, c2);
|
|
|
|
if ((!evas_textblock_cursor_char_next(c2)) &&
|
|
|
|
(!evas_textblock_cursor_node_next(c2)))
|
|
|
|
{
|
|
|
|
_curs_end(c, o, en);
|
|
|
|
}
|
|
|
|
else if (evas_textblock_cursor_compare(c, c1))
|
|
|
|
{
|
|
|
|
_curs_next(c, o, en);
|
|
|
|
}
|
2008-10-16 18:40:10 -07:00
|
|
|
|
|
|
|
evas_textblock_cursor_free(c1);
|
|
|
|
evas_textblock_cursor_free(c2);
|
|
|
|
}
|
|
|
|
|
2010-03-25 01:17:51 -07:00
|
|
|
static void
|
|
|
|
_delete(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
|
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *c1, *c2;
|
|
|
|
|
|
|
|
c1 = evas_object_textblock_cursor_new(o);
|
|
|
|
c2 = evas_object_textblock_cursor_new(o);
|
|
|
|
evas_textblock_cursor_copy(c, c1);
|
|
|
|
evas_textblock_cursor_copy(c, c2);
|
|
|
|
evas_textblock_cursor_char_last(c2);
|
|
|
|
if (evas_textblock_cursor_node_format_get(c1) &&
|
|
|
|
(!evas_textblock_cursor_node_format_is_visible_get(c1)))
|
|
|
|
{
|
|
|
|
// non-visible format-node
|
|
|
|
evas_textblock_cursor_copy(c1, c2);
|
|
|
|
while (evas_textblock_cursor_node_next(c2))
|
|
|
|
{
|
|
|
|
if ((!evas_textblock_cursor_node_format_get(c2)) ||
|
|
|
|
(evas_textblock_cursor_node_format_is_visible_get(c2)))
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_node_prev(c2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (evas_textblock_cursor_node_format_is_visible_get(c1))
|
|
|
|
{
|
|
|
|
// visible format node
|
|
|
|
// do nothing just copy c to c1/c2 and range del
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if it's a text node
|
|
|
|
if (!evas_textblock_cursor_char_next(c1))
|
|
|
|
{
|
|
|
|
if (evas_textblock_cursor_compare(c1, c2) > 0)
|
|
|
|
_curs_next(c, o, en);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
evas_textblock_cursor_copy(c, c1);
|
|
|
|
evas_textblock_cursor_copy(c, c2);
|
|
|
|
}
|
|
|
|
evas_textblock_cursor_range_delete(c1, c2);
|
|
|
|
evas_textblock_cursor_free(c1);
|
|
|
|
evas_textblock_cursor_free(c2);
|
|
|
|
}
|
|
|
|
|
2008-10-13 02:19:04 -07:00
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
|
|
|
Edje *ed = data;
|
|
|
|
Evas_Event_Key_Down *ev = event_info;
|
|
|
|
Edje_Real_Part *rp = ed->focused_part;
|
2008-10-13 04:57:32 -07:00
|
|
|
Entry *en;
|
2009-06-17 04:10:32 -07:00
|
|
|
Eina_Bool control, alt, shift;
|
|
|
|
Eina_Bool multiline;
|
|
|
|
Eina_Bool cursor_changed;
|
2008-10-16 02:17:44 -07:00
|
|
|
Evas_Textblock_Cursor *tc;
|
2008-10-13 04:57:32 -07:00
|
|
|
if (!rp) return;
|
|
|
|
en = rp->entry_data;
|
|
|
|
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
|
2008-10-13 02:19:04 -07:00
|
|
|
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
|
|
|
|
return;
|
|
|
|
if (!ev->key) return;
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
#if 0 // FIXME -- keyboard activated IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
Ecore_IMF_Event_Key_Down ecore_ev;
|
|
|
|
ecore_imf_evas_event_key_down_wrap(ev, &ecore_ev);
|
|
|
|
if (ecore_imf_context_filter_event(en->imf_context,
|
|
|
|
ECORE_IMF_EVENT_KEY_DOWN,
|
|
|
|
(Ecore_IMF_Event *)&ecore_ev))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
2008-10-13 02:19:04 -07:00
|
|
|
|
2008-10-16 02:17:44 -07:00
|
|
|
tc = evas_object_textblock_cursor_new(rp->object);
|
|
|
|
evas_textblock_cursor_copy(en->cursor, tc);
|
|
|
|
|
2008-10-13 02:19:04 -07:00
|
|
|
control = evas_key_modifier_is_set(ev->modifiers, "Control");
|
|
|
|
alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
|
|
|
|
shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
|
2008-10-22 01:57:49 -07:00
|
|
|
multiline = rp->part->multiline;
|
2009-06-17 04:10:32 -07:00
|
|
|
cursor_changed = EINA_FALSE;
|
2008-10-13 02:19:04 -07:00
|
|
|
if (!strcmp(ev->key, "Escape"))
|
|
|
|
{
|
2008-10-13 04:57:32 -07:00
|
|
|
// dead keys here. Escape for now (should emit these)
|
2008-10-22 01:57:49 -07:00
|
|
|
_edje_emit(ed, "entry,key,escape", rp->part->name);
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
else if (!strcmp(ev->key, "Up"))
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
2008-10-22 01:57:49 -07:00
|
|
|
if (multiline)
|
|
|
|
{
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_start(en->cursor, rp->object, en);
|
|
|
|
else _sel_clear(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
_curs_up(en->cursor, rp->object, en);
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_extend(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-22 01:57:49 -07:00
|
|
|
}
|
|
|
|
_edje_emit(ed, "entry,key,up", rp->part->name);
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
else if (!strcmp(ev->key, "Down"))
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
2008-10-22 01:57:49 -07:00
|
|
|
if (multiline)
|
|
|
|
{
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_start(en->cursor, rp->object, en);
|
|
|
|
else _sel_clear(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
_curs_down(en->cursor, rp->object, en);
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_extend(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-22 01:57:49 -07:00
|
|
|
}
|
|
|
|
_edje_emit(ed, "entry,key,down", rp->part->name);
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(ev->key, "Left"))
|
|
|
|
{
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_start(en->cursor, rp->object, en);
|
|
|
|
else _sel_clear(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
_curs_back(en->cursor, rp->object, en);
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_extend(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
_edje_emit(ed, "entry,key,left", rp->part->name);
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(ev->key, "Right"))
|
|
|
|
{
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_start(en->cursor, rp->object, en);
|
|
|
|
else _sel_clear(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
_curs_next(en->cursor, rp->object, en);
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_extend(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
_edje_emit(ed, "entry,key,right", rp->part->name);
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(ev->key, "BackSpace"))
|
|
|
|
{
|
|
|
|
if (control)
|
|
|
|
{
|
2008-10-15 02:58:25 -07:00
|
|
|
// del to start of previous word
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if ((alt) && (shift))
|
|
|
|
{
|
2008-10-15 02:58:25 -07:00
|
|
|
// undo last action
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-10-15 02:58:25 -07:00
|
|
|
if (en->have_selection)
|
2008-10-16 17:07:43 -07:00
|
|
|
_range_del(en->cursor, rp->object, en);
|
2008-10-13 02:19:04 -07:00
|
|
|
else
|
2008-10-16 18:40:10 -07:00
|
|
|
_backspace(en->cursor, rp->object, en);
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
2008-10-16 02:17:44 -07:00
|
|
|
_curs_update_from_curs(en->cursor, rp->object, en);
|
2010-03-15 17:57:04 -07:00
|
|
|
_anchors_get(en->cursor, rp->object, en);
|
2009-01-26 22:17:35 -08:00
|
|
|
_edje_emit(ed, "entry,changed", rp->part->name);
|
2008-10-22 01:57:49 -07:00
|
|
|
_edje_emit(ed, "entry,key,backspace", rp->part->name);
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(ev->key, "Delete"))
|
|
|
|
{
|
|
|
|
if (control)
|
|
|
|
{
|
2008-10-15 02:58:25 -07:00
|
|
|
// del to end of next word
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if (shift)
|
|
|
|
{
|
|
|
|
// cut
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-10-15 02:58:25 -07:00
|
|
|
if (en->have_selection)
|
2008-10-16 17:07:43 -07:00
|
|
|
_range_del(en->cursor, rp->object, en);
|
2008-10-13 02:19:04 -07:00
|
|
|
else
|
2010-03-25 01:17:51 -07:00
|
|
|
_delete(en->cursor, rp->object, en);
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
2008-10-16 02:17:44 -07:00
|
|
|
_curs_update_from_curs(en->cursor, rp->object, en);
|
2008-10-16 23:40:46 -07:00
|
|
|
_anchors_get(en->cursor, rp->object, en);
|
2008-10-15 08:15:06 -07:00
|
|
|
_edje_emit(ed, "entry,changed", rp->part->name);
|
2008-10-22 01:57:49 -07:00
|
|
|
_edje_emit(ed, "entry,key,delete", rp->part->name);
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(ev->key, "Home"))
|
|
|
|
{
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_start(en->cursor, rp->object, en);
|
|
|
|
else _sel_clear(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
if ((control) && (multiline))
|
|
|
|
_curs_start(en->cursor, rp->object, en);
|
2008-10-13 02:19:04 -07:00
|
|
|
else
|
2008-10-15 02:58:25 -07:00
|
|
|
_curs_lin_start(en->cursor, rp->object, en);
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_extend(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
_edje_emit(ed, "entry,key,home", rp->part->name);
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(ev->key, "End"))
|
|
|
|
{
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_start(en->cursor, rp->object, en);
|
|
|
|
else _sel_clear(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
if ((control) && (multiline))
|
|
|
|
_curs_end(en->cursor, rp->object, en);
|
2008-10-13 02:19:04 -07:00
|
|
|
else
|
2008-10-15 02:58:25 -07:00
|
|
|
_curs_lin_end(en->cursor, rp->object, en);
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_extend(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
_edje_emit(ed, "entry,key,end", rp->part->name);
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if ((control) && (!strcmp(ev->key, "v")))
|
|
|
|
{
|
2008-10-16 02:17:44 -07:00
|
|
|
_edje_emit(ed, "entry,paste,request", rp->part->name);
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if ((control) && ((!strcmp(ev->key, "c") || (!strcmp(ev->key, "Insert")))))
|
|
|
|
{
|
2008-10-16 02:17:44 -07:00
|
|
|
// FIXME: copy - save selection
|
|
|
|
_edje_emit(ed, "entry,copy,notify", rp->part->name);
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if ((control) && ((!strcmp(ev->key, "x") || (!strcmp(ev->key, "m")))))
|
|
|
|
{
|
2008-10-16 02:17:44 -07:00
|
|
|
// FIXME: cut - save selection, delete seletion
|
|
|
|
_curs_update_from_curs(en->cursor, rp->object, en);
|
|
|
|
_edje_emit(ed, "entry,cut,notify", rp->part->name);
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if ((control) && (!strcmp(ev->key, "z")))
|
|
|
|
{
|
|
|
|
if (shift)
|
|
|
|
{
|
2008-10-15 02:58:25 -07:00
|
|
|
// redo
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-10-15 02:58:25 -07:00
|
|
|
// undo
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if ((control) && (!strcmp(ev->key, "y")))
|
|
|
|
{
|
2008-10-15 02:58:25 -07:00
|
|
|
// redo
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else if ((control) && (!strcmp(ev->key, "w")))
|
|
|
|
{
|
2008-10-15 02:58:25 -07:00
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
2008-10-13 02:19:04 -07:00
|
|
|
// select current word
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
else if (!strcmp(ev->key, "Tab"))
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
2008-10-22 01:57:49 -07:00
|
|
|
if (multiline)
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
2008-10-22 01:57:49 -07:00
|
|
|
if (shift)
|
|
|
|
{
|
|
|
|
// remove a tab
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_format_prepend(en->cursor, "\t");
|
|
|
|
_curs_update_from_curs(en->cursor, rp->object, en);
|
|
|
|
_anchors_get(en->cursor, rp->object, en);
|
|
|
|
_edje_emit(ed, "entry,changed", rp->part->name);
|
|
|
|
}
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
_edje_emit(ed, "entry,key,tab", rp->part->name);
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
else if ((!strcmp(ev->key, "ISO_Left_Tab")) && (multiline))
|
|
|
|
{
|
2008-10-13 02:19:04 -07:00
|
|
|
// remove a tab
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
else if (!strcmp(ev->key, "Prior"))
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_start(en->cursor, rp->object, en);
|
|
|
|
else _sel_clear(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
_curs_jump_line_by(en->cursor, rp->object, en, -10);
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_extend(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
_edje_emit(ed, "entry,key,pgup", rp->part->name);
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
else if (!strcmp(ev->key, "Next"))
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_start(en->cursor, rp->object, en);
|
|
|
|
else _sel_clear(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-15 02:58:25 -07:00
|
|
|
_curs_jump_line_by(en->cursor, rp->object, en, 10);
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (shift) _sel_extend(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
_edje_emit(ed, "entry,key,pgdn", rp->part->name);
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
else if ((!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter")))
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
2008-10-22 01:57:49 -07:00
|
|
|
if (multiline)
|
|
|
|
{
|
2010-03-14 05:24:54 -07:00
|
|
|
if (en->have_selection)
|
|
|
|
_range_del(en->cursor, rp->object, en);
|
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
2008-10-22 01:57:49 -07:00
|
|
|
evas_textblock_cursor_format_prepend(en->cursor, "\n");
|
|
|
|
_curs_update_from_curs(en->cursor, rp->object, en);
|
|
|
|
_anchors_get(en->cursor, rp->object, en);
|
|
|
|
_edje_emit(ed, "entry,changed", rp->part->name);
|
2009-04-23 05:42:53 -07:00
|
|
|
_edje_emit(ed, "cursor,changed", rp->part->name);
|
2009-06-17 04:10:32 -07:00
|
|
|
cursor_changed = EINA_TRUE;
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-22 01:57:49 -07:00
|
|
|
}
|
|
|
|
_edje_emit(ed, "entry,key,enter", rp->part->name);
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ev->string)
|
2008-10-13 21:35:17 -07:00
|
|
|
{
|
2008-10-15 02:58:25 -07:00
|
|
|
if (en->have_selection)
|
2010-03-11 06:28:44 -08:00
|
|
|
_range_del(en->cursor, rp->object, en);
|
2008-10-15 02:58:25 -07:00
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
2010-03-14 05:24:54 -07:00
|
|
|
evas_textblock_cursor_text_prepend(en->cursor, ev->string);
|
2008-10-16 02:17:44 -07:00
|
|
|
_curs_update_from_curs(en->cursor, rp->object, en);
|
2008-10-16 23:40:46 -07:00
|
|
|
_anchors_get(en->cursor, rp->object, en);
|
2008-10-15 08:15:06 -07:00
|
|
|
_edje_emit(ed, "entry,changed", rp->part->name);
|
2008-10-22 01:57:49 -07:00
|
|
|
_edje_emit(ed, "cursor,changed", rp->part->name);
|
2009-06-17 04:10:32 -07:00
|
|
|
cursor_changed = EINA_TRUE;
|
2008-10-22 04:59:59 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2008-10-13 21:35:17 -07:00
|
|
|
}
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2008-10-22 01:57:49 -07:00
|
|
|
if ((evas_textblock_cursor_compare(tc, en->cursor)) && (!cursor_changed))
|
2008-10-16 02:17:44 -07:00
|
|
|
_edje_emit(ed, "cursor,changed", rp->part->name);
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-16 02:17:44 -07:00
|
|
|
evas_textblock_cursor_free(tc);
|
2008-10-13 02:19:04 -07:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
|
|
|
Edje *ed = data;
|
|
|
|
Edje_Real_Part *rp = ed->focused_part;
|
2008-10-13 04:57:32 -07:00
|
|
|
Entry *en;
|
|
|
|
if (!rp) return;
|
|
|
|
en = rp->entry_data;
|
|
|
|
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
|
2008-10-13 02:19:04 -07:00
|
|
|
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
|
|
|
|
return;
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
#if 0 // FIXME key activation imf
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
Ecore_IMF_Event_Key_Up ecore_ev;
|
|
|
|
ecore_imf_evas_event_key_down_wrap(ev, &ecore_ev);
|
|
|
|
if (ecore_imf_context_filter_event(en->imf_context,
|
|
|
|
ECORE_IMF_EVENT_KEY_UP,
|
|
|
|
(Ecore_IMF_Event *)&ecore_ev))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
|
|
|
Edje_Real_Part *rp = data;
|
|
|
|
Evas_Event_Mouse_Down *ev = event_info;
|
2008-10-13 04:57:32 -07:00
|
|
|
Entry *en;
|
2008-10-13 02:19:04 -07:00
|
|
|
Evas_Coord x, y, w, h;
|
2009-06-17 04:10:32 -07:00
|
|
|
Eina_Bool multiline;
|
2008-10-16 02:17:44 -07:00
|
|
|
Evas_Textblock_Cursor *tc;
|
2009-06-17 04:10:32 -07:00
|
|
|
Eina_Bool dosel = EINA_FALSE;
|
2008-10-13 04:57:32 -07:00
|
|
|
if (!rp) return;
|
2009-04-23 05:42:53 -07:00
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2008-10-13 04:57:32 -07:00
|
|
|
en = rp->entry_data;
|
|
|
|
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
|
2008-10-15 02:58:25 -07:00
|
|
|
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
|
2008-10-13 02:19:04 -07:00
|
|
|
return;
|
2008-11-18 22:22:12 -08:00
|
|
|
if (ev->button == 2)
|
|
|
|
{
|
|
|
|
_edje_emit(rp->edje, "entry,paste,request", rp->part->name);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-14 09:09:46 -08:00
|
|
|
if (ev->button != 1) return;
|
2009-06-17 04:10:32 -07:00
|
|
|
en->select_mod_start = EINA_FALSE;
|
|
|
|
en->select_mod_end = EINA_FALSE;
|
2009-03-19 06:36:10 -07:00
|
|
|
if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
|
2009-06-17 04:10:32 -07:00
|
|
|
dosel = EINA_TRUE;
|
2009-03-19 06:36:10 -07:00
|
|
|
else if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)
|
|
|
|
{
|
2009-06-17 04:10:32 -07:00
|
|
|
if (en->select_allow) dosel = EINA_TRUE;
|
2009-03-19 06:36:10 -07:00
|
|
|
}
|
|
|
|
if (dosel)
|
|
|
|
{
|
|
|
|
// double click -> select word
|
|
|
|
// triple click -> select line
|
|
|
|
}
|
2008-10-16 02:17:44 -07:00
|
|
|
tc = evas_object_textblock_cursor_new(rp->object);
|
|
|
|
evas_textblock_cursor_copy(en->cursor, tc);
|
2008-10-22 01:57:49 -07:00
|
|
|
multiline = rp->part->multiline;
|
2008-10-13 02:19:04 -07:00
|
|
|
evas_object_geometry_get(rp->object, &x, &y, &w, &h);
|
|
|
|
en->cx = ev->canvas.x - x;
|
|
|
|
en->cy = ev->canvas.y - y;
|
|
|
|
if (!evas_textblock_cursor_char_coord_set(en->cursor, en->cx, en->cy))
|
|
|
|
{
|
2009-03-19 06:36:10 -07:00
|
|
|
Evas_Coord lx, ly, lw, lh;
|
2008-11-16 22:17:09 -08:00
|
|
|
int line;
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-03-19 06:36:10 -07:00
|
|
|
line = evas_textblock_cursor_line_coord_set(en->cursor, en->cy);
|
2008-11-16 22:17:09 -08:00
|
|
|
if (line == -1)
|
|
|
|
_curs_end(en->cursor, rp->object, en);
|
|
|
|
else
|
|
|
|
{
|
2010-03-14 05:24:54 -07:00
|
|
|
int lnum;
|
|
|
|
|
|
|
|
lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
|
|
|
|
if (lnum < 0)
|
|
|
|
{
|
|
|
|
_curs_lin_start(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-11-16 22:17:09 -08:00
|
|
|
else
|
2010-03-14 05:24:54 -07:00
|
|
|
{
|
|
|
|
if (en->cx <= lx)
|
|
|
|
_curs_lin_start(en->cursor, rp->object, en);
|
|
|
|
else
|
|
|
|
_curs_lin_end(en->cursor, rp->object, en);
|
|
|
|
}
|
2008-11-16 22:17:09 -08:00
|
|
|
}
|
2009-05-13 06:29:30 -07:00
|
|
|
line = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Evas_Coord lx, ly, lw, lh;
|
|
|
|
int line;
|
|
|
|
|
|
|
|
line = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2009-03-19 06:36:10 -07:00
|
|
|
if (dosel)
|
|
|
|
{
|
|
|
|
if ((en->have_selection) &&
|
|
|
|
(rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT))
|
|
|
|
{
|
2009-03-22 06:50:53 -07:00
|
|
|
Eina_List *first, *last;
|
2009-12-09 07:44:54 -08:00
|
|
|
FLOAT_T sc;
|
2009-03-22 06:50:53 -07:00
|
|
|
|
|
|
|
first = en->sel;
|
|
|
|
last = eina_list_last(en->sel);
|
|
|
|
if (first && last)
|
|
|
|
{
|
|
|
|
Evas_Textblock_Rectangle *r1, *r2;
|
|
|
|
Evas_Coord d, d1, d2;
|
|
|
|
|
|
|
|
r1 = first->data;
|
|
|
|
r2 = last->data;
|
|
|
|
d = r1->x - en->cx;
|
|
|
|
d1 = d * d;
|
|
|
|
d = (r1->y + (r1->h / 2)) - en->cy;
|
|
|
|
d1 += d * d;
|
|
|
|
d = r2->x + r2->w - 1 - en->cx;
|
|
|
|
d2 = d * d;
|
|
|
|
d = (r2->y + (r2->h / 2)) - en->cy;
|
|
|
|
d2 += d * d;
|
|
|
|
sc = rp->edje->scale;
|
2009-12-09 07:44:54 -08:00
|
|
|
if (sc == ZERO) sc = _edje_scale;
|
|
|
|
d = (Evas_Coord)MUL(FROM_INT(20), sc); // FIXME: maxing number!
|
2009-03-22 06:50:53 -07:00
|
|
|
d = d * d;
|
|
|
|
if (d1 < d2)
|
|
|
|
{
|
|
|
|
if (d1 <= d)
|
|
|
|
{
|
2009-06-17 04:10:32 -07:00
|
|
|
en->select_mod_start = EINA_TRUE;
|
|
|
|
en->selecting = EINA_TRUE;
|
2009-03-22 06:50:53 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (d2 <= d)
|
|
|
|
{
|
2009-06-17 04:10:32 -07:00
|
|
|
en->select_mod_end = EINA_TRUE;
|
|
|
|
en->selecting = EINA_TRUE;
|
2009-03-22 06:50:53 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-03-19 06:36:10 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-17 04:10:32 -07:00
|
|
|
en->selecting = EINA_TRUE;
|
2009-03-19 06:36:10 -07:00
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
_sel_start(en->cursor, rp->object, en);
|
|
|
|
}
|
2009-03-19 06:36:10 -07:00
|
|
|
}
|
|
|
|
}
|
2008-10-16 02:17:44 -07:00
|
|
|
if (evas_textblock_cursor_compare(tc, en->cursor))
|
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-16 02:17:44 -07:00
|
|
|
evas_textblock_cursor_free(tc);
|
2008-10-13 02:19:04 -07:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_part_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
|
|
|
Edje_Real_Part *rp = data;
|
|
|
|
Evas_Event_Mouse_Up *ev = event_info;
|
2008-10-13 04:57:32 -07:00
|
|
|
Entry *en;
|
2008-10-13 02:19:04 -07:00
|
|
|
Evas_Coord x, y, w, h;
|
2008-10-16 02:17:44 -07:00
|
|
|
Evas_Textblock_Cursor *tc;
|
2008-10-16 23:40:46 -07:00
|
|
|
if (ev->button != 1) return;
|
2008-10-13 04:57:32 -07:00
|
|
|
if (!rp) return;
|
2009-04-23 05:42:53 -07:00
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2008-10-13 04:57:32 -07:00
|
|
|
en = rp->entry_data;
|
|
|
|
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
|
2008-10-15 02:58:25 -07:00
|
|
|
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
|
2008-10-13 02:19:04 -07:00
|
|
|
return;
|
2008-10-16 02:17:44 -07:00
|
|
|
tc = evas_object_textblock_cursor_new(rp->object);
|
|
|
|
evas_textblock_cursor_copy(en->cursor, tc);
|
2008-10-13 02:19:04 -07:00
|
|
|
evas_object_geometry_get(rp->object, &x, &y, &w, &h);
|
|
|
|
en->cx = ev->canvas.x - x;
|
|
|
|
en->cy = ev->canvas.y - y;
|
|
|
|
if (!evas_textblock_cursor_char_coord_set(en->cursor, en->cx, en->cy))
|
|
|
|
{
|
2009-03-19 06:36:10 -07:00
|
|
|
Evas_Coord lx, ly, lw, lh;
|
|
|
|
|
|
|
|
evas_textblock_cursor_line_coord_set(en->cursor, en->cy);
|
|
|
|
evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
|
|
|
|
if (en->cx <= lx)
|
|
|
|
_curs_lin_start(en->cursor, rp->object, en);
|
|
|
|
else
|
|
|
|
_curs_lin_end(en->cursor, rp->object, en);
|
|
|
|
}
|
|
|
|
if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)
|
|
|
|
{
|
|
|
|
if (en->select_allow)
|
2009-03-22 06:50:53 -07:00
|
|
|
{
|
|
|
|
if (en->had_sel)
|
|
|
|
{
|
|
|
|
if (en->select_mod_end)
|
|
|
|
_sel_extend(en->cursor, rp->object, en);
|
|
|
|
else if (en->select_mod_start)
|
|
|
|
_sel_preextend(en->cursor, rp->object, en);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_sel_extend(en->cursor, rp->object, en);
|
|
|
|
// evas_textblock_cursor_copy(en->cursor, en->sel_end);
|
|
|
|
}
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
2009-03-19 06:36:10 -07:00
|
|
|
else
|
|
|
|
evas_textblock_cursor_copy(en->cursor, en->sel_end);
|
2009-03-22 06:50:53 -07:00
|
|
|
if (en->selecting)
|
|
|
|
{
|
|
|
|
if (en->have_selection)
|
2009-06-17 04:10:32 -07:00
|
|
|
en->had_sel = EINA_TRUE;
|
|
|
|
en->selecting = EINA_FALSE;
|
2009-03-22 06:50:53 -07:00
|
|
|
}
|
2008-10-16 02:17:44 -07:00
|
|
|
if (evas_textblock_cursor_compare(tc, en->cursor))
|
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
|
|
|
evas_textblock_cursor_free(tc);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-13 02:19:04 -07:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_part_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
|
|
|
Edje_Real_Part *rp = data;
|
|
|
|
Evas_Event_Mouse_Move *ev = event_info;
|
2008-10-13 04:57:32 -07:00
|
|
|
Entry *en;
|
2008-10-13 02:19:04 -07:00
|
|
|
Evas_Coord x, y, w, h;
|
2008-10-16 02:17:44 -07:00
|
|
|
Evas_Textblock_Cursor *tc;
|
2009-03-19 06:36:10 -07:00
|
|
|
if (!rp) return;
|
2008-10-13 04:57:32 -07:00
|
|
|
en = rp->entry_data;
|
|
|
|
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
|
2008-10-15 02:58:25 -07:00
|
|
|
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
|
2008-10-13 02:19:04 -07:00
|
|
|
return;
|
2009-03-19 06:36:10 -07:00
|
|
|
if (en->selecting)
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
2009-03-19 06:36:10 -07:00
|
|
|
tc = evas_object_textblock_cursor_new(rp->object);
|
|
|
|
evas_textblock_cursor_copy(en->cursor, tc);
|
|
|
|
evas_object_geometry_get(rp->object, &x, &y, &w, &h);
|
|
|
|
en->cx = ev->cur.canvas.x - x;
|
|
|
|
en->cy = ev->cur.canvas.y - y;
|
|
|
|
if (!evas_textblock_cursor_char_coord_set(en->cursor, en->cx, en->cy))
|
|
|
|
{
|
|
|
|
Evas_Coord lx, ly, lw, lh;
|
|
|
|
|
|
|
|
evas_textblock_cursor_line_coord_set(en->cursor, en->cy);
|
|
|
|
evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
|
|
|
|
if (en->cx <= lx)
|
|
|
|
_curs_lin_start(en->cursor, rp->object, en);
|
|
|
|
else
|
|
|
|
_curs_lin_end(en->cursor, rp->object, en);
|
|
|
|
}
|
2009-03-22 06:50:53 -07:00
|
|
|
if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)
|
2009-03-19 06:36:10 -07:00
|
|
|
{
|
2009-03-22 06:50:53 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (en->had_sel)
|
|
|
|
{
|
|
|
|
if (en->select_mod_end)
|
|
|
|
_sel_extend(en->cursor, rp->object, en);
|
|
|
|
else if (en->select_mod_start)
|
|
|
|
_sel_preextend(en->cursor, rp->object, en);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_sel_extend(en->cursor, rp->object, en);
|
|
|
|
}
|
2009-03-19 06:36:10 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_sel_extend(en->cursor, rp->object, en);
|
|
|
|
}
|
2010-03-25 21:42:39 -07:00
|
|
|
if (en->select_allow)
|
|
|
|
{
|
|
|
|
if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) != 0)
|
|
|
|
_sel_enable(en->cursor, rp->object, en);
|
|
|
|
if (en->have_selection)
|
|
|
|
_sel_update(en->cursor, rp->object, en);
|
|
|
|
}
|
2009-03-19 06:36:10 -07:00
|
|
|
if (evas_textblock_cursor_compare(tc, en->cursor))
|
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
|
|
|
evas_textblock_cursor_free(tc);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-03-19 06:36:10 -07:00
|
|
|
_edje_entry_real_part_configure(rp);
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-10 07:12:35 -08:00
|
|
|
static void
|
2010-02-16 05:43:44 -08:00
|
|
|
_evas_focus_in_cb(void *data, Evas *e, void *event_info)
|
2010-02-10 07:12:35 -08:00
|
|
|
{
|
|
|
|
Edje *ed = (Edje *)data;
|
|
|
|
|
|
|
|
if (evas_focus_get(e) == ed->obj) {
|
|
|
|
_edje_focus_in_cb(data, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-02-16 05:43:44 -08:00
|
|
|
_evas_focus_out_cb(void *data, Evas *e, void *event_info)
|
2010-02-10 07:12:35 -08:00
|
|
|
{
|
|
|
|
Edje *ed = (Edje *)data;
|
|
|
|
|
|
|
|
if (evas_focus_get(e) == ed->obj) {
|
|
|
|
_edje_focus_out_cb(data, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-13 02:19:04 -07:00
|
|
|
/***************************************************************/
|
|
|
|
void
|
|
|
|
_edje_entry_init(Edje *ed)
|
|
|
|
{
|
2010-02-17 15:43:31 -08:00
|
|
|
if (!ed->has_entries)
|
|
|
|
return;
|
|
|
|
if (ed->entries_inited)
|
|
|
|
return;
|
|
|
|
ed->entries_inited = EINA_TRUE;
|
|
|
|
|
2008-10-13 02:19:04 -07:00
|
|
|
evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb, ed);
|
|
|
|
evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb, ed);
|
|
|
|
evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb, ed);
|
|
|
|
evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb, ed);
|
2010-02-10 07:12:35 -08:00
|
|
|
evas_event_callback_add(ed->evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed);
|
|
|
|
evas_event_callback_add(ed->evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed);
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_shutdown(Edje *ed)
|
|
|
|
{
|
2010-02-17 15:43:31 -08:00
|
|
|
if (!ed->has_entries)
|
|
|
|
return;
|
|
|
|
if (!ed->entries_inited)
|
|
|
|
return;
|
|
|
|
ed->entries_inited = EINA_FALSE;
|
|
|
|
|
2009-06-18 07:01:26 -07:00
|
|
|
evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb);
|
|
|
|
evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb);
|
|
|
|
evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb);
|
|
|
|
evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb);
|
2010-02-17 15:43:31 -08:00
|
|
|
if (evas_event_callback_del_full(ed->evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed) != ed)
|
|
|
|
ERR("could not unregister EVAS_CALLBACK_FOCUS_IN");
|
|
|
|
if (evas_event_callback_del_full(ed->evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed) != ed)
|
|
|
|
ERR("could not unregister EVAS_CALLBACK_FOCUS_OUT");
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_real_part_init(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en;
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
const char *ctx_id;
|
|
|
|
const Ecore_IMF_Context_Info *ctx_info;
|
|
|
|
#endif
|
2008-10-13 02:19:04 -07:00
|
|
|
|
|
|
|
en = calloc(1, sizeof(Entry));
|
|
|
|
if (!en) return;
|
|
|
|
rp->entry_data = en;
|
2008-10-15 08:15:06 -07:00
|
|
|
en->rp = rp;
|
2008-10-13 02:19:04 -07:00
|
|
|
|
|
|
|
evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_DOWN, _edje_part_mouse_down_cb, rp);
|
|
|
|
evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_UP, _edje_part_mouse_up_cb, rp);
|
|
|
|
evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_MOVE, _edje_part_mouse_move_cb, rp);
|
2008-10-22 01:57:49 -07:00
|
|
|
|
2010-04-29 12:56:59 -07:00
|
|
|
if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
|
|
|
|
en->select_allow = 1;
|
|
|
|
|
2008-10-24 00:08:08 -07:00
|
|
|
if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
|
2008-10-22 22:38:06 -07:00
|
|
|
{
|
2010-03-25 21:42:39 -07:00
|
|
|
en->select_allow = 0;
|
2008-10-22 22:38:06 -07:00
|
|
|
if ((rp->chosen_description) &&
|
|
|
|
(rp->chosen_description->text.repch))
|
|
|
|
evas_object_textblock_replace_char_set(rp->object, rp->chosen_description->text.repch);
|
|
|
|
else
|
|
|
|
evas_object_textblock_replace_char_set(rp->object, "*");
|
|
|
|
}
|
2008-10-13 02:19:04 -07:00
|
|
|
|
2008-10-15 08:15:06 -07:00
|
|
|
en->cursor_bg = edje_object_add(rp->edje->evas);
|
|
|
|
edje_object_file_set(en->cursor_bg, rp->edje->path, rp->part->source3);
|
2008-10-13 02:19:04 -07:00
|
|
|
evas_object_smart_member_add(en->cursor_bg, rp->edje->obj);
|
|
|
|
evas_object_stack_below(en->cursor_bg, rp->object);
|
|
|
|
evas_object_clip_set(en->cursor_bg, evas_object_clip_get(rp->object));
|
|
|
|
evas_object_pass_events_set(en->cursor_bg, 1);
|
2008-11-16 21:54:01 -08:00
|
|
|
rp->edje->subobjs = eina_list_append(rp->edje->subobjs, en->cursor_bg);
|
2008-10-15 08:15:06 -07:00
|
|
|
|
|
|
|
en->cursor_fg = edje_object_add(rp->edje->evas);
|
|
|
|
edje_object_file_set(en->cursor_fg, rp->edje->path, rp->part->source4);
|
|
|
|
evas_object_smart_member_add(en->cursor_fg, rp->edje->obj);
|
|
|
|
evas_object_stack_above(en->cursor_fg, rp->object);
|
|
|
|
evas_object_clip_set(en->cursor_fg, evas_object_clip_get(rp->object));
|
|
|
|
evas_object_pass_events_set(en->cursor_fg, 1);
|
2008-11-16 21:54:01 -08:00
|
|
|
rp->edje->subobjs = eina_list_append(rp->edje->subobjs, en->cursor_fg);
|
|
|
|
|
2008-10-15 02:58:25 -07:00
|
|
|
if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
|
2008-10-15 08:15:06 -07:00
|
|
|
{
|
|
|
|
evas_object_show(en->cursor_bg);
|
|
|
|
evas_object_show(en->cursor_fg);
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
ecore_imf_init();
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-05-14 05:53:56 -07:00
|
|
|
edje_object_signal_callback_add(rp->edje->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb, rp);
|
|
|
|
edje_object_signal_callback_add(rp->edje->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb, rp);
|
|
|
|
|
|
|
|
ctx_id = ecore_imf_context_default_id_get();
|
|
|
|
if (ctx_id)
|
2009-05-13 06:29:30 -07:00
|
|
|
{
|
2009-05-14 05:53:56 -07:00
|
|
|
ctx_info = ecore_imf_context_info_by_id_get(ctx_id);
|
|
|
|
if (!ctx_info->canvas_type ||
|
|
|
|
strcmp(ctx_info->canvas_type, "evas") == 0)
|
2009-05-13 06:29:30 -07:00
|
|
|
{
|
|
|
|
en->imf_context = ecore_imf_context_add(ctx_id);
|
|
|
|
}
|
2009-05-14 05:53:56 -07:00
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ctx_id = ecore_imf_context_default_id_by_canvas_type_get("evas");
|
|
|
|
if (ctx_id)
|
|
|
|
{
|
|
|
|
en->imf_context = ecore_imf_context_add(ctx_id);
|
|
|
|
}
|
|
|
|
}
|
2009-05-13 06:29:30 -07:00
|
|
|
}
|
2009-05-14 05:53:56 -07:00
|
|
|
else
|
|
|
|
en->imf_context = NULL;
|
|
|
|
|
|
|
|
if (!en->imf_context) goto done;
|
|
|
|
|
|
|
|
ecore_imf_context_client_window_set(en->imf_context, rp->object);
|
|
|
|
ecore_imf_context_client_canvas_set(en->imf_context, rp->edje->evas);
|
|
|
|
|
|
|
|
ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context, _edje_entry_imf_retrieve_surrounding_cb, rp);
|
|
|
|
en->imf_ee_handler_commit = ecore_event_handler_add(ECORE_IMF_EVENT_COMMIT, _edje_entry_imf_event_commit_cb, rp->edje);
|
|
|
|
en->imf_ee_handler_delete = ecore_event_handler_add(ECORE_IMF_EVENT_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb, rp);
|
|
|
|
en->imf_ee_handler_changed = ecore_event_handler_add(ECORE_IMF_EVENT_PREEDIT_CHANGED, _edje_entry_imf_event_changed_cb, rp->edje);
|
|
|
|
ecore_imf_context_input_mode_set(en->imf_context,
|
|
|
|
rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD ?
|
|
|
|
ECORE_IMF_INPUT_MODE_INVISIBLE : ECORE_IMF_INPUT_MODE_FULL);
|
2009-05-13 06:29:30 -07:00
|
|
|
#endif
|
2009-05-14 05:53:56 -07:00
|
|
|
}
|
|
|
|
done:
|
2009-12-01 03:02:46 -08:00
|
|
|
en->cursor = (Evas_Textblock_Cursor *)evas_object_textblock_cursor_get(rp->object);
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_real_part_shutdown(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (!en) return;
|
|
|
|
rp->entry_data = NULL;
|
2008-10-15 08:15:06 -07:00
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
2008-10-16 23:40:46 -07:00
|
|
|
_anchors_clear(en->cursor, rp->object, en);
|
2008-11-16 21:54:01 -08:00
|
|
|
rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->cursor_bg);
|
|
|
|
rp->edje->subobjs = eina_list_remove(rp->edje->subobjs, en->cursor_fg);
|
2008-10-15 08:15:06 -07:00
|
|
|
evas_object_del(en->cursor_bg);
|
|
|
|
evas_object_del(en->cursor_fg);
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
|
2009-05-13 06:29:30 -07:00
|
|
|
{
|
2009-05-14 05:53:56 -07:00
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
if (en->imf_ee_handler_commit)
|
|
|
|
{
|
|
|
|
ecore_event_handler_del(en->imf_ee_handler_commit);
|
|
|
|
en->imf_ee_handler_commit = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (en->imf_ee_handler_delete)
|
|
|
|
{
|
|
|
|
ecore_event_handler_del(en->imf_ee_handler_delete);
|
|
|
|
en->imf_ee_handler_delete = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (en->imf_ee_handler_changed)
|
|
|
|
{
|
|
|
|
ecore_event_handler_del(en->imf_ee_handler_changed);
|
|
|
|
en->imf_ee_handler_changed = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ecore_imf_context_del(en->imf_context);
|
|
|
|
en->imf_context = NULL;
|
|
|
|
}
|
2009-05-22 14:12:32 -07:00
|
|
|
|
|
|
|
edje_object_signal_callback_del(rp->edje->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb);
|
|
|
|
edje_object_signal_callback_del(rp->edje->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb);
|
2009-05-14 05:53:56 -07:00
|
|
|
ecore_imf_shutdown();
|
2009-05-13 06:29:30 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-13 02:19:04 -07:00
|
|
|
free(en);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_real_part_configure(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Evas_Coord x, y, w, h, xx, yy, ww, hh;
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (!en) return;
|
2008-10-15 02:58:25 -07:00
|
|
|
|
|
|
|
_sel_update(en->cursor, rp->object, en);
|
2008-10-16 23:40:46 -07:00
|
|
|
_anchors_update(en->cursor, rp->object, en);
|
2008-10-15 02:58:25 -07:00
|
|
|
x = y = w = h = -1;
|
|
|
|
xx = yy = ww = hh = -1;
|
2008-10-13 02:19:04 -07:00
|
|
|
evas_object_geometry_get(rp->object, &x, &y, &w, &h);
|
2008-10-16 17:20:52 -07:00
|
|
|
evas_textblock_cursor_char_geometry_get(en->cursor, &xx, &yy, &ww, &hh);
|
2008-10-13 02:19:04 -07:00
|
|
|
if (ww < 1) ww = 1;
|
|
|
|
if (hh < 1) ww = 1;
|
2008-10-15 02:58:25 -07:00
|
|
|
if (en->cursor_bg)
|
|
|
|
{
|
|
|
|
evas_object_move(en->cursor_bg, x + xx, y + yy);
|
|
|
|
evas_object_resize(en->cursor_bg, ww, hh);
|
|
|
|
}
|
|
|
|
if (en->cursor_fg)
|
|
|
|
{
|
|
|
|
evas_object_move(en->cursor_fg, x + xx, y + yy);
|
|
|
|
evas_object_resize(en->cursor_fg, ww, hh);
|
|
|
|
}
|
2008-10-13 02:19:04 -07:00
|
|
|
}
|
|
|
|
|
2008-10-16 02:17:44 -07:00
|
|
|
const char *
|
2008-10-15 02:58:25 -07:00
|
|
|
_edje_entry_selection_get(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
2008-10-16 02:17:44 -07:00
|
|
|
if (!en) return NULL;
|
2008-10-15 02:58:25 -07:00
|
|
|
// get selection - convert to markup
|
2008-10-16 02:17:44 -07:00
|
|
|
if ((!en->selection) && (en->have_selection))
|
|
|
|
en->selection = evas_textblock_cursor_range_text_get
|
|
|
|
(en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
|
|
|
|
return en->selection;
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
_edje_entry_text_get(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
2008-10-16 02:17:44 -07:00
|
|
|
if (!en) return NULL;
|
2008-10-15 02:58:25 -07:00
|
|
|
// get text - convert to markup
|
|
|
|
return evas_object_textblock_text_markup_get(rp->object);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (!en) return;
|
|
|
|
// set text as markup
|
2008-10-16 07:22:19 -07:00
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
2008-10-15 08:15:06 -07:00
|
|
|
evas_object_textblock_text_markup_set(rp->object, text);
|
2010-03-11 00:07:55 -08:00
|
|
|
/*
|
2008-10-16 02:17:44 -07:00
|
|
|
evas_textblock_cursor_node_last(en->cursor);
|
2008-10-21 21:00:05 -07:00
|
|
|
if (!evas_textblock_cursor_node_format_get(en->cursor))
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_format_append(en->cursor, "\n");
|
|
|
|
}
|
|
|
|
else if (!((!strcmp(evas_textblock_cursor_node_format_get(en->cursor), "\n")) ||
|
|
|
|
(!strcmp(evas_textblock_cursor_node_format_get(en->cursor), "\\n"))))
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_format_append(en->cursor, "\n");
|
|
|
|
}
|
2010-03-11 00:07:55 -08:00
|
|
|
*/
|
2008-10-16 23:40:46 -07:00
|
|
|
_anchors_get(en->cursor, rp->object, en);
|
2008-10-15 08:15:06 -07:00
|
|
|
_edje_emit(rp->edje, "entry,changed", rp->part->name);
|
2008-10-15 19:11:02 -07:00
|
|
|
_edje_entry_set_cursor_start(rp);
|
2008-10-15 02:58:25 -07:00
|
|
|
}
|
|
|
|
|
2008-10-16 02:17:44 -07:00
|
|
|
void
|
|
|
|
_edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (!en) return;
|
|
|
|
// prepend markup @ cursor pos
|
2008-10-16 07:22:19 -07:00
|
|
|
if (en->have_selection)
|
2010-03-25 21:22:30 -07:00
|
|
|
_range_del(en->cursor, rp->object, en);
|
2008-10-16 07:22:19 -07:00
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
2010-03-25 21:22:30 -07:00
|
|
|
evas_object_textblock_text_markup_prepend(en->cursor, text);
|
2008-10-16 02:17:44 -07:00
|
|
|
_curs_update_from_curs(en->cursor, rp->object, en);
|
2008-10-16 23:40:46 -07:00
|
|
|
_anchors_get(en->cursor, rp->object, en);
|
2008-10-16 02:17:44 -07:00
|
|
|
_edje_emit(rp->edje, "entry,changed", rp->part->name);
|
2010-03-14 20:02:14 -07:00
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
2010-03-25 21:22:30 -07:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
_edje_entry_real_part_configure(rp);
|
2008-10-16 02:17:44 -07:00
|
|
|
}
|
|
|
|
|
2008-10-15 02:58:25 -07:00
|
|
|
void
|
|
|
|
_edje_entry_set_cursor_start(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (!en) return;
|
|
|
|
_curs_start(en->cursor, rp->object, en);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_set_cursor_end(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (!en) return;
|
|
|
|
_curs_end(en->cursor, rp->object, en);
|
|
|
|
}
|
|
|
|
|
2008-11-18 00:45:27 -08:00
|
|
|
void
|
|
|
|
_edje_entry_select_none(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (!en) return;
|
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_select_all(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (!en) return;
|
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
|
|
|
_curs_start(en->cursor, rp->object, en);
|
|
|
|
_sel_enable(en->cursor, rp->object, en);
|
|
|
|
_sel_start(en->cursor, rp->object, en);
|
|
|
|
_curs_end(en->cursor, rp->object, en);
|
|
|
|
_sel_extend(en->cursor, rp->object, en);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-10 05:32:49 -08:00
|
|
|
_edje_entry_real_part_configure(rp);
|
2008-11-18 00:45:27 -08:00
|
|
|
}
|
|
|
|
|
2010-03-10 22:34:20 -08:00
|
|
|
void
|
|
|
|
_edje_entry_select_begin(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (!en) return;
|
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
|
|
|
_sel_enable(en->cursor, rp->object, en);
|
|
|
|
_sel_start(en->cursor, rp->object, en);
|
|
|
|
_sel_extend(en->cursor, rp->object, en);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-10 22:34:20 -08:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_select_extend(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (!en) return;
|
|
|
|
_sel_extend(en->cursor, rp->object, en);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-10 22:34:20 -08:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
}
|
|
|
|
|
2008-10-23 17:44:26 -07:00
|
|
|
const Eina_List *
|
|
|
|
_edje_entry_anchor_geometry_get(Edje_Real_Part *rp, const char *anchor)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
Eina_List *l;
|
|
|
|
Anchor *an;
|
|
|
|
|
2008-10-26 04:04:53 -07:00
|
|
|
if (!en) return NULL;
|
2008-10-23 17:44:26 -07:00
|
|
|
EINA_LIST_FOREACH(en->anchors, l, an)
|
|
|
|
{
|
2010-04-25 06:57:41 -07:00
|
|
|
if (an->item) continue;
|
2008-10-23 17:44:26 -07:00
|
|
|
if (!strcmp(anchor, an->name))
|
|
|
|
return an->sel;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
const Eina_List *
|
2008-10-16 23:40:46 -07:00
|
|
|
_edje_entry_anchors_list(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l, *anchors = NULL;
|
|
|
|
Anchor *an;
|
|
|
|
|
2008-10-16 23:40:46 -07:00
|
|
|
if (!en) return NULL;
|
|
|
|
if (!en->anchorlist)
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(en->anchors, l, an)
|
2008-10-16 23:40:46 -07:00
|
|
|
{
|
2008-10-23 17:44:26 -07:00
|
|
|
const char *n = an->name;
|
2010-04-25 06:57:41 -07:00
|
|
|
if (an->item) continue;
|
2008-10-16 23:40:46 -07:00
|
|
|
if (!n) n = "";
|
2008-10-22 04:34:42 -07:00
|
|
|
anchors = eina_list_append(anchors, strdup(n));
|
2008-10-16 23:40:46 -07:00
|
|
|
}
|
|
|
|
en->anchorlist = anchors;
|
|
|
|
}
|
|
|
|
return en->anchorlist;
|
|
|
|
}
|
|
|
|
|
2010-04-26 07:55:45 -07:00
|
|
|
Eina_Bool
|
|
|
|
_edje_entry_item_geometry_get(Edje_Real_Part *rp, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
Eina_List *l;
|
|
|
|
Anchor *an;
|
|
|
|
|
|
|
|
if (!en) return 0;
|
|
|
|
EINA_LIST_FOREACH(en->anchors, l, an)
|
|
|
|
{
|
|
|
|
if (an->item) continue;
|
|
|
|
if (!strcmp(item, an->name))
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_format_item_geometry_get(an->start, cx, cy, cw, ch);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Eina_List *
|
|
|
|
_edje_entry_items_list(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
Eina_List *l, *items = NULL;
|
|
|
|
Anchor *an;
|
|
|
|
|
|
|
|
if (!en) return NULL;
|
|
|
|
if (!en->itemlist)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(en->anchors, l, an)
|
|
|
|
{
|
|
|
|
const char *n = an->name;
|
|
|
|
if (an->item) continue;
|
|
|
|
if (!n) n = "";
|
|
|
|
items = eina_list_append(items, strdup(n));
|
|
|
|
}
|
|
|
|
en->itemlist = items;
|
|
|
|
}
|
|
|
|
return en->itemlist;
|
|
|
|
}
|
|
|
|
|
2008-10-16 23:40:46 -07:00
|
|
|
void
|
|
|
|
_edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
|
|
|
|
{
|
|
|
|
Evas_Coord x, y, w, h, xx, yy, ww, hh;
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (!en) return;
|
|
|
|
|
|
|
|
x = y = w = h = -1;
|
|
|
|
xx = yy = ww = hh = -1;
|
|
|
|
evas_object_geometry_get(rp->object, &x, &y, &w, &h);
|
|
|
|
evas_textblock_cursor_char_geometry_get(en->cursor, &xx, &yy, &ww, &hh);
|
|
|
|
if (ww < 1) ww = 1;
|
|
|
|
if (hh < 1) ww = 1;
|
|
|
|
if (cx) *cx = x + xx;
|
|
|
|
if (cy) *cy = y + yy;
|
|
|
|
if (cw) *cw = ww;
|
|
|
|
if (ch) *ch = hh;
|
|
|
|
}
|
2009-03-19 06:36:10 -07:00
|
|
|
|
|
|
|
void
|
2009-06-17 04:10:32 -07:00
|
|
|
_edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow)
|
2009-03-19 06:36:10 -07:00
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
2010-04-29 12:56:59 -07:00
|
|
|
if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
|
|
|
|
return;
|
2009-03-19 06:36:10 -07:00
|
|
|
en->select_allow = allow;
|
|
|
|
}
|
2009-03-20 08:07:39 -07:00
|
|
|
|
2010-03-26 18:26:10 -07:00
|
|
|
Eina_Bool
|
|
|
|
_edje_entry_select_allow_get(const Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
const Entry *en = rp->entry_data;
|
|
|
|
return en->select_allow;
|
|
|
|
}
|
|
|
|
|
2009-03-20 08:07:39 -07:00
|
|
|
void
|
|
|
|
_edje_entry_select_abort(Edje_Real_Part *rp)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (en->selecting)
|
|
|
|
{
|
2009-06-17 04:10:32 -07:00
|
|
|
en->selecting = EINA_FALSE;
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-03-20 08:07:39 -07:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
}
|
|
|
|
}
|
2009-05-13 06:29:30 -07:00
|
|
|
|
2009-12-01 03:02:46 -08:00
|
|
|
static Evas_Textblock_Cursor *
|
|
|
|
_cursor_get(Edje_Real_Part *rp, Edje_Cursor cur)
|
|
|
|
{
|
|
|
|
Entry *en = rp->entry_data;
|
|
|
|
if (!en) return NULL;
|
|
|
|
switch (cur)
|
|
|
|
{
|
|
|
|
case EDJE_CURSOR_MAIN:
|
|
|
|
return en->cursor;
|
|
|
|
break;
|
|
|
|
case EDJE_CURSOR_SELECTION_BEGIN:
|
|
|
|
return en->sel_start;
|
|
|
|
break;
|
|
|
|
case EDJE_CURSOR_SELECTION_END:
|
|
|
|
return en->sel_end;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
_edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur)
|
|
|
|
{
|
2010-03-11 02:16:32 -08:00
|
|
|
Entry *en = rp->entry_data;
|
2009-12-01 03:02:46 -08:00
|
|
|
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
|
|
|
|
if (!c) return 0;
|
|
|
|
if (!evas_textblock_cursor_char_next(c))
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_eol_set(c, 0);
|
|
|
|
if (evas_textblock_cursor_node_next(c)) goto ok;
|
|
|
|
else return 0;
|
|
|
|
}
|
|
|
|
ok:
|
|
|
|
_curs_update_from_curs(c, rp->object, rp->entry_data);
|
|
|
|
_sel_update(c, rp->object, rp->entry_data);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-14 20:02:14 -07:00
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
2009-12-01 03:02:46 -08:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
_edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur)
|
|
|
|
{
|
2010-03-11 02:16:32 -08:00
|
|
|
Entry *en = rp->entry_data;
|
2009-12-01 03:02:46 -08:00
|
|
|
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
|
|
|
|
if (!c) return 0;
|
|
|
|
if (!evas_textblock_cursor_char_prev(c))
|
|
|
|
{
|
|
|
|
if (evas_textblock_cursor_node_prev(c)) goto ok;
|
|
|
|
else return 0;
|
|
|
|
}
|
|
|
|
ok:
|
|
|
|
_curs_update_from_curs(c, rp->object, rp->entry_data);
|
|
|
|
_sel_update(c, rp->object, rp->entry_data);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-14 20:02:14 -07:00
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
2009-12-01 03:02:46 -08:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
_edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur)
|
|
|
|
{
|
2010-03-11 02:16:32 -08:00
|
|
|
Entry *en = rp->entry_data;
|
2009-12-01 03:02:46 -08:00
|
|
|
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
|
|
|
|
Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
|
|
|
|
int ln;
|
|
|
|
if (!c) return 0;
|
|
|
|
ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
|
|
|
|
ln--;
|
|
|
|
if (ln < 0) return 0;
|
|
|
|
if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
|
|
|
|
&lx, &ly, &lw, &lh))
|
|
|
|
return 0;
|
|
|
|
evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
|
|
|
|
if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
|
|
|
|
{
|
|
|
|
if (cx < (lx +(lw / 2)))
|
|
|
|
evas_textblock_cursor_line_first(c);
|
|
|
|
else
|
|
|
|
evas_textblock_cursor_line_last(c);
|
|
|
|
}
|
|
|
|
_curs_update_from_curs(c, rp->object, rp->entry_data);
|
|
|
|
_sel_update(c, rp->object, rp->entry_data);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-14 20:02:14 -07:00
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
2009-12-01 03:02:46 -08:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
_edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur)
|
|
|
|
{
|
2010-03-11 02:16:32 -08:00
|
|
|
Entry *en = rp->entry_data;
|
2009-12-01 03:02:46 -08:00
|
|
|
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
|
|
|
|
Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
|
2009-12-21 08:24:39 -08:00
|
|
|
int ln;
|
2009-12-01 03:02:46 -08:00
|
|
|
if (!c) return 0;
|
|
|
|
ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
|
|
|
|
ln++;
|
|
|
|
if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
|
|
|
|
&lx, &ly, &lw, &lh))
|
|
|
|
return 0;
|
|
|
|
evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
|
|
|
|
if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
|
|
|
|
{
|
|
|
|
if (cx < (lx +(lw / 2)))
|
|
|
|
evas_textblock_cursor_line_first(c);
|
|
|
|
else
|
|
|
|
evas_textblock_cursor_line_last(c);
|
|
|
|
}
|
|
|
|
_curs_update_from_curs(c, rp->object, rp->entry_data);
|
|
|
|
_sel_update(c, rp->object, rp->entry_data);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-14 20:02:14 -07:00
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
2009-12-01 03:02:46 -08:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur)
|
|
|
|
{
|
2010-03-11 02:16:32 -08:00
|
|
|
Entry *en = rp->entry_data;
|
2009-12-01 03:02:46 -08:00
|
|
|
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
|
|
|
|
if (!c) return;
|
|
|
|
evas_textblock_cursor_node_first(c);
|
|
|
|
_curs_update_from_curs(c, rp->object, rp->entry_data);
|
|
|
|
_sel_update(c, rp->object, rp->entry_data);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-14 20:02:14 -07:00
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
2009-12-01 03:02:46 -08:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur)
|
|
|
|
{
|
2010-03-11 02:16:32 -08:00
|
|
|
Entry *en = rp->entry_data;
|
2009-12-01 03:02:46 -08:00
|
|
|
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
|
|
|
|
if (!c) return;
|
2010-05-27 15:18:37 -07:00
|
|
|
_curs_end(c, rp->object, rp->entry_data);
|
2009-12-01 03:02:46 -08:00
|
|
|
_sel_update(c, rp->object, rp->entry_data);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-14 20:02:14 -07:00
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
2009-12-01 03:02:46 -08:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst)
|
|
|
|
{
|
2010-03-11 02:16:32 -08:00
|
|
|
Entry *en = rp->entry_data;
|
2009-12-01 03:02:46 -08:00
|
|
|
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
|
|
|
|
if (!c) return;
|
|
|
|
Evas_Textblock_Cursor *d = _cursor_get(rp, dst);
|
|
|
|
if (!d) return;
|
|
|
|
evas_textblock_cursor_copy(c, d);
|
|
|
|
_curs_update_from_curs(c, rp->object, rp->entry_data);
|
|
|
|
_sel_update(c, rp->object, rp->entry_data);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-14 20:02:14 -07:00
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
2009-12-01 03:02:46 -08:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur)
|
|
|
|
{
|
2010-03-11 02:16:32 -08:00
|
|
|
Entry *en = rp->entry_data;
|
2009-12-01 03:02:46 -08:00
|
|
|
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
|
|
|
|
if (!c) return;
|
|
|
|
evas_textblock_cursor_line_first(c);
|
|
|
|
_curs_update_from_curs(c, rp->object, rp->entry_data);
|
|
|
|
_sel_update(c, rp->object, rp->entry_data);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-14 20:02:14 -07:00
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
2009-12-01 03:02:46 -08:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur)
|
|
|
|
{
|
2010-03-11 02:16:32 -08:00
|
|
|
Entry *en = rp->entry_data;
|
2009-12-01 03:02:46 -08:00
|
|
|
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
|
|
|
|
if (!c) return;
|
|
|
|
evas_textblock_cursor_line_last(c);
|
|
|
|
_curs_update_from_curs(c, rp->object, rp->entry_data);
|
|
|
|
_sel_update(c, rp->object, rp->entry_data);
|
2010-03-11 02:16:32 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ECORE_IMF
|
|
|
|
if (en->imf_context)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(en->imf_context);
|
|
|
|
ecore_imf_context_cursor_position_set(en->imf_context,
|
|
|
|
evas_textblock_cursor_pos_get(en->cursor));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-14 20:02:14 -07:00
|
|
|
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
|
2009-12-01 03:02:46 -08:00
|
|
|
_edje_entry_real_part_configure(rp);
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
_edje_entry_cursor_is_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
|
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
|
|
|
|
if (!c) return 0;
|
2009-12-08 21:46:02 -08:00
|
|
|
if (evas_textblock_cursor_node_format_get(c)) return 1;
|
|
|
|
return 0;
|
2009-12-01 03:02:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
_edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
|
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
|
|
|
|
if (!c) return 0;
|
|
|
|
return evas_textblock_cursor_node_format_is_visible_get(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
_edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur)
|
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
|
|
|
|
const char *s;
|
2009-12-08 21:46:02 -08:00
|
|
|
static char buf[16];
|
2009-12-01 03:02:46 -08:00
|
|
|
int pos, pos2, ch;
|
|
|
|
if (!c) return NULL;
|
|
|
|
s = evas_textblock_cursor_node_format_get(c);
|
|
|
|
if (s) return s;
|
|
|
|
s = evas_textblock_cursor_node_text_get(c);
|
|
|
|
if (!s) return NULL;
|
|
|
|
pos = evas_textblock_cursor_pos_get(c);
|
|
|
|
pos2 = evas_string_char_next_get(s, pos, &ch);
|
|
|
|
strncpy(buf, s + pos, pos2 - pos);
|
|
|
|
buf[pos2 - pos] = 0;
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2009-05-14 05:53:56 -07:00
|
|
|
#ifdef HAVE_ECORE_IMF
|
2009-05-13 06:29:30 -07:00
|
|
|
static int
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, char **text, int *cursor_pos)
|
2009-05-13 06:29:30 -07:00
|
|
|
{
|
|
|
|
Edje_Real_Part *rp = data;
|
|
|
|
Entry *en;
|
|
|
|
const char *str;
|
|
|
|
|
|
|
|
if (!rp) return 0;
|
|
|
|
en = rp->entry_data;
|
|
|
|
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
|
|
|
|
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (text)
|
|
|
|
{
|
|
|
|
str = _edje_entry_text_get(rp);
|
|
|
|
*text = str ? strdup(str) : strdup("");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor_pos)
|
|
|
|
{
|
|
|
|
*cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_entry_imf_event_commit_cb(void *data, int type __UNUSED__, void *event)
|
2009-05-13 06:29:30 -07:00
|
|
|
{
|
|
|
|
Edje* ed = data;
|
|
|
|
Edje_Real_Part *rp = ed->focused_part;
|
|
|
|
Entry *en;
|
|
|
|
Ecore_IMF_Event_Commit *ev = event;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!rp) return 1;
|
|
|
|
|
|
|
|
en = rp->entry_data;
|
|
|
|
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
|
|
|
|
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (en->imf_context != ev->ctx) return 1;
|
2009-05-14 05:53:56 -07:00
|
|
|
|
|
|
|
if (en->have_composition)
|
2009-05-13 06:29:30 -07:00
|
|
|
{
|
|
|
|
for (i = 0; i < en->comp_len; i++)
|
|
|
|
_backspace(en->cursor, rp->object, en);
|
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
2009-06-17 04:10:32 -07:00
|
|
|
en->have_composition = EINA_FALSE;
|
2009-05-13 06:29:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
evas_textblock_cursor_text_prepend(en->cursor, ev->str);
|
|
|
|
|
|
|
|
_curs_update_from_curs(en->cursor, rp->object, en);
|
|
|
|
_anchors_get(en->cursor, rp->object, en);
|
|
|
|
_edje_emit(rp->edje, "entry,changed", rp->part->name);
|
|
|
|
_edje_emit(ed, "cursor,changed", rp->part->name);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_entry_imf_event_changed_cb(void *data, int type __UNUSED__, void *event)
|
2009-05-13 06:29:30 -07:00
|
|
|
{
|
|
|
|
Edje* ed = data;
|
|
|
|
Edje_Real_Part *rp = ed->focused_part;
|
|
|
|
Entry *en;
|
2009-08-24 09:40:42 -07:00
|
|
|
int length;
|
2009-05-13 06:29:30 -07:00
|
|
|
Ecore_IMF_Event_Commit *ev = event;
|
|
|
|
int i;
|
|
|
|
char *preedit_string;
|
|
|
|
|
|
|
|
if (!rp) return 1;
|
|
|
|
|
|
|
|
en = rp->entry_data;
|
|
|
|
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
|
|
|
|
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (!en->imf_context) return 1;
|
|
|
|
|
|
|
|
if (en->imf_context != ev->ctx) return 1;
|
|
|
|
|
|
|
|
ecore_imf_context_preedit_string_get(en->imf_context, &preedit_string, &length);
|
|
|
|
|
|
|
|
// FIXME : check the maximum length of evas_textblock
|
|
|
|
if ( 0 /* check the maximum length of evas_textblock */ )
|
|
|
|
return 1;
|
|
|
|
|
2009-05-14 05:53:56 -07:00
|
|
|
if (en->have_composition)
|
2009-05-13 06:29:30 -07:00
|
|
|
{
|
|
|
|
// delete the composing characters
|
|
|
|
for (i = 0;i < en->comp_len; i++)
|
|
|
|
_backspace(en->cursor, rp->object, en);
|
|
|
|
}
|
|
|
|
|
|
|
|
en->comp_len = length;
|
|
|
|
|
|
|
|
_sel_clear(en->cursor, rp->object, en);
|
|
|
|
_sel_enable(en->cursor, rp->object, en);
|
|
|
|
_sel_start(en->cursor, rp->object, en);
|
|
|
|
|
2009-06-17 04:10:32 -07:00
|
|
|
en->have_composition = EINA_TRUE;
|
2009-05-14 05:53:56 -07:00
|
|
|
|
2010-01-11 17:50:00 -08:00
|
|
|
evas_object_textblock_text_markup_prepend (en->cursor, preedit_string);
|
|
|
|
|
2009-05-13 06:29:30 -07:00
|
|
|
_sel_extend(en->cursor, rp->object, en);
|
|
|
|
|
|
|
|
_curs_update_from_curs(en->cursor, rp->object, en);
|
|
|
|
_anchors_get(en->cursor, rp->object, en);
|
|
|
|
_edje_emit(rp->edje, "entry,changed", rp->part->name);
|
|
|
|
_edje_emit(ed, "cursor,changed", rp->part->name);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-08-24 09:40:42 -07:00
|
|
|
_edje_entry_imf_event_delete_surrounding_cb(void *data, int type __UNUSED__, void *event)
|
2009-05-13 06:29:30 -07:00
|
|
|
{
|
|
|
|
Edje *ed = data;
|
|
|
|
Edje_Real_Part *rp = ed->focused_part;
|
|
|
|
Entry *en;
|
|
|
|
Ecore_IMF_Event_Delete_Surrounding *ev = event;
|
|
|
|
|
|
|
|
if (!rp) return 1;
|
|
|
|
en = rp->entry_data;
|
|
|
|
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
|
|
|
|
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (en->imf_context != ev->ctx) return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|