#ifdef HAVE_ECORE_IMF
static Eina_Bool _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos);
-static Eina_Bool _edje_entry_imf_event_commit_cb(void *data, int type, void *event);
-static Eina_Bool _edje_entry_imf_event_preedit_changed_cb(void *data, int type, void *event);
-static Eina_Bool _edje_entry_imf_event_delete_surrounding_cb(void *data, int type, void *event);
+static void _edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx, void *event_info);
+static void _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx, void *event_info);
+static void _edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx, void *event);
#endif
static void _edje_entry_top_handler_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
#ifdef HAVE_ECORE_IMF
Eina_Bool have_preedit : 1;
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
Ecore_Timer *longpress_timer;
_sel_extend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
{
if (!en->sel_end) return;
+ _edje_entry_imf_context_reset(en);
_sel_enable(c, o, en);
if (!evas_textblock_cursor_compare(c, en->sel_end)) return;
en->selection = NULL;
}
_edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
- _edje_entry_imf_context_reset(en);
}
static void
_sel_preextend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
{
if (!en->sel_end) return;
+ _edje_entry_imf_context_reset(en);
_sel_enable(c, o, en);
if (!evas_textblock_cursor_compare(c, en->sel_start)) return;
en->selection = NULL;
}
_edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
- _edje_entry_imf_context_reset(en);
}
static void
}
#endif
+ if ((!strcmp(ev->key, "Escape")) ||
+ (!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter")))
+ _edje_entry_imf_context_reset(en);
+
old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
control = evas_key_modifier_is_set(ev->modifiers, "Control");
_edje_emit(ed, "entry,key,end", rp->part->name);
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
}
- else if (!strcmp(ev->key, "Shift_L") || !strcmp(ev->key, "Shift_R"))
- {
- return;
- }
else if ((control) && (!strcmp(ev->key, "v")))
{
_edje_emit(ed, "entry,paste,request", rp->part->name);
if (!cursor_changed && (old_cur_pos != evas_textblock_cursor_pos_get(en->cursor)))
_edje_emit(ed, "cursor,changed", rp->part->name);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_entry_real_part_configure(rp);
}
}
#endif
+ _edje_entry_imf_context_reset(en);
+
en->select_mod_start = EINA_FALSE;
en->select_mod_end = EINA_FALSE;
if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
_edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
}
evas_textblock_cursor_free(tc);
-
- _edje_entry_imf_context_reset(en);
+
_edje_entry_imf_cursor_info_set(en);
if (en->rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_BLOCK_HANDLE)
}
#endif
+ _edje_entry_imf_context_reset(en);
+
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);
}
evas_textblock_cursor_free(tc);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_entry_real_part_configure(rp);
}
ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context,
_edje_entry_imf_retrieve_surrounding_cb, rp->edje);
- 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->edje);
- en->imf_ee_handler_changed = ecore_event_handler_add(ECORE_IMF_EVENT_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb, rp->edje);
+ ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb, rp->edje);
+ ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb, rp->edje);
+ ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_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);
{
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_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb);
+ ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb);
+ ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb);
ecore_imf_context_del(en->imf_context);
en->imf_context = NULL;
{
Entry *en = rp->entry_data;
if (!en) return;
-#ifdef HAVE_ECORE_IMF
- if ((en->have_preedit) && (en->imf_context))
- {
- ecore_imf_context_reset(en->imf_context);
- ecore_main_loop_iterate();
- }
-#endif
+ _edje_entry_imf_context_reset(en);
// set text as markup
_sel_clear(en->cursor, rp->object, en);
evas_object_textblock_text_markup_set(rp->object, text);
{
Entry *en = rp->entry_data;
if (!en) return;
+ _edje_entry_imf_context_reset(en);
+
// prepend markup @ cursor pos
if (en->have_selection)
_range_del(en->cursor, rp->object, en);
_edje_emit(rp->edje, "entry,changed", rp->part->name);
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
-
_edje_entry_real_part_configure(rp);
}
{
Entry *en = rp->entry_data;
if (!en) return;
+
+ _edje_entry_imf_context_reset(en);
+
_sel_clear(en->cursor, rp->object, en);
_curs_start(en->cursor, rp->object, en);
_sel_enable(en->cursor, rp->object, en);
_curs_end(en->cursor, rp->object, en);
_sel_extend(en->cursor, rp->object, en);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_entry_real_part_configure(rp);
{
Entry *en = rp->entry_data;
if (!en) return;
+
+ _edje_entry_imf_context_reset(en);
+
_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);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_entry_real_part_configure(rp);
{
Entry *en = rp->entry_data;
if (!en) return;
+ _edje_entry_imf_context_reset(en);
_sel_extend(en->cursor, rp->object, en);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_entry_real_part_configure(rp);
Entry *en = rp->entry_data;
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
if (!c) return EINA_FALSE;
+
+ _edje_entry_imf_context_reset(en);
+
if (!evas_textblock_cursor_char_next(c))
{
return EINA_FALSE;
}
_sel_update(c, rp->object, rp->entry_data);
-
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
Entry *en = rp->entry_data;
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
if (!c) return EINA_FALSE;
+
+ _edje_entry_imf_context_reset(en);
+
if (!evas_textblock_cursor_char_prev(c))
{
if (evas_textblock_cursor_paragraph_prev(c)) goto ok;
ok:
_sel_update(c, rp->object, rp->entry_data);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
int ln;
if (!c) return EINA_FALSE;
+
+ _edje_entry_imf_context_reset(en);
+
ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
ln--;
if (ln < 0) return EINA_FALSE;
}
_sel_update(c, rp->object, rp->entry_data);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
int ln;
if (!c) return EINA_FALSE;
+
+ _edje_entry_imf_context_reset(en);
+
ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
ln++;
if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
}
_sel_update(c, rp->object, rp->entry_data);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
_edje_entry_real_part_configure(rp);
Entry *en = rp->entry_data;
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
if (!c) return;
+
+ _edje_entry_imf_context_reset(en);
+
evas_textblock_cursor_paragraph_first(c);
_sel_update(c, rp->object, rp->entry_data);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
_edje_entry_real_part_configure(rp);
Entry *en = rp->entry_data;
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
if (!c) return;
+
+ _edje_entry_imf_context_reset(en);
+
_curs_end(c, rp->object, rp->entry_data);
_sel_update(c, rp->object, rp->entry_data);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
Entry *en = rp->entry_data;
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
if (!c) return;
+ _edje_entry_imf_context_reset(en);
+
evas_textblock_cursor_line_char_first(c);
_sel_update(c, rp->object, rp->entry_data);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
Entry *en = rp->entry_data;
Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
if (!c) return;
+ _edje_entry_imf_context_reset(en);
evas_textblock_cursor_line_char_last(c);
_sel_update(c, rp->object, rp->entry_data);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
_edje_entry_real_part_configure(rp);
if (evas_textblock_cursor_pos_get(c) == pos)
return;
+ _edje_entry_imf_context_reset(en);
evas_textblock_cursor_pos_set(c, pos);
_sel_update(c, rp->object, rp->entry_data);
- _edje_entry_imf_context_reset(en);
_edje_entry_imf_cursor_info_set(en);
_edje_emit(rp->edje, "cursor,changed", rp->part->name);
_edje_entry_real_part_configure(rp);
return EINA_TRUE;
}
-static Eina_Bool
-_edje_entry_imf_event_commit_cb(void *data, int type __UNUSED__, void *event)
+static void
+_edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx, void *event_info)
{
Edje *ed = data;
Edje_Real_Part *rp = ed->focused_part;
Entry *en;
- Ecore_IMF_Event_Commit *ev = event;
- Evas_Textblock_Cursor *tc;
- Eina_Bool cursor_move = EINA_FALSE;
+ char *commit_str = event_info;
int start_pos;
- if ((!rp) || (!ev) || (!ev->str)) return ECORE_CALLBACK_PASS_ON;
+ if ((!rp)) return;
en = rp->entry_data;
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
- return ECORE_CALLBACK_PASS_ON;
-
- if (!en->imf_context) return ECORE_CALLBACK_PASS_ON;
- if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON;
+ return;
if (en->have_selection)
{
- if (strcmp(ev->str, ""))
+ if (strcmp(commit_str, ""))
{
/* delete selected characters */
_range_del_emit(ed, en->cursor, rp->object, en);
}
}
- tc = evas_object_textblock_cursor_new(rp->object);
-
- /* calculate the cursor position to insert commit string */
- if (en->preedit_start)
- evas_textblock_cursor_copy(en->preedit_start, tc);
- else
- evas_textblock_cursor_copy(en->cursor, tc);
-
- start_pos = evas_textblock_cursor_pos_get(tc);
-
+ start_pos = evas_textblock_cursor_pos_get(en->cursor);
#ifdef HAVE_ECORE_IMF
/* delete preedit characters */
_preedit_clear(en);
#endif
- if (evas_textblock_cursor_compare(en->cursor, tc))
- cursor_move = EINA_TRUE;
if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
_edje_password_show_last)
_edje_entry_hide_visible_password(en->rp);
if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
_edje_password_show_last && (!en->preedit_start))
{
- _text_filter_format_prepend(en, tc, "+ password=off");
- _text_filter_text_prepend(en, tc, ev->str);
- _text_filter_format_prepend(en, tc, "- password");
+ _text_filter_format_prepend(en, en->cursor, "+ password=off");
+ _text_filter_text_prepend(en, en->cursor, commit_str);
+ _text_filter_format_prepend(en, en->cursor, "- password");
+
if (en->pw_timer)
{
ecore_timer_del(en->pw_timer);
_password_timer_cb, en);
}
else
- _text_filter_text_prepend(en, tc, ev->str);
-
- if (!cursor_move)
- {
- /* move cursor to the end of commit string */
- evas_textblock_cursor_copy(tc, en->cursor);
- }
+ _text_filter_text_prepend(en, en->cursor, commit_str);
- evas_textblock_cursor_free(tc);
_edje_entry_imf_cursor_info_set(en);
_anchors_get(en->cursor, rp->object, en);
Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
info->insert = EINA_TRUE;
info->change.insert.pos = start_pos;
- info->change.insert.content = eina_stringshare_add(ev->str);
+ info->change.insert.content = eina_stringshare_add(commit_str);
info->change.insert.plain_length =
eina_unicode_utf8_get_len(info->change.insert.content);
_edje_emit_full(ed, "entry,changed,user", rp->part->name,
info, _free_entry_change_info);
_edje_emit(ed, "cursor,changed", rp->part->name);
}
-
- return ECORE_CALLBACK_DONE;
}
-static Eina_Bool
-_edje_entry_imf_event_preedit_changed_cb(void *data, int type __UNUSED__, void *event)
+static void
+_edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx, void *event_info)
{
Edje *ed = data;
Edje_Real_Part *rp = ed->focused_part;
Entry *en;
- Ecore_IMF_Event_Preedit_Changed *ev = event;
+ char *str = event_info;
int cursor_pos;
int preedit_start_pos, preedit_end_pos;
char *preedit_string;
char *preedit_tag_index;
char *pretag = NULL;
- if ((!rp) || (!ev)) return ECORE_CALLBACK_PASS_ON;
+ if ((!rp)) return;
en = rp->entry_data;
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
- return ECORE_CALLBACK_PASS_ON;
-
- if (!en->imf_context) return ECORE_CALLBACK_PASS_ON;
+ return;
- if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON;
+ if (!en->imf_context) return;
ecore_imf_context_preedit_string_with_attributes_get(en->imf_context,
&preedit_string,
&attrs, &cursor_pos);
- if (!preedit_string) return ECORE_CALLBACK_PASS_ON;
+ if (!preedit_string) return;
if (!strcmp(preedit_string, ""))
preedit_end_state = EINA_TRUE;
}
free(preedit_string);
-
- return ECORE_CALLBACK_DONE;
}
-static Eina_Bool
-_edje_entry_imf_event_delete_surrounding_cb(void *data, int type __UNUSED__, void *event)
+static void
+_edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx, void *event_info)
{
Edje *ed = data;
Edje_Real_Part *rp = ed->focused_part;
Entry *en;
- Ecore_IMF_Event_Delete_Surrounding *ev = event;
+ Ecore_IMF_Event_Delete_Surrounding *ev = event_info;
Evas_Textblock_Cursor *del_start, *del_end;
int cursor_pos;
- if ((!rp) || (!ev)) return ECORE_CALLBACK_PASS_ON;
+ if ((!rp) || (!ev)) return;
en = rp->entry_data;
if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
(rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
- return ECORE_CALLBACK_PASS_ON;
-
- if (!en->imf_context) return ECORE_CALLBACK_PASS_ON;
- if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON;
+ return;
cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
evas_textblock_cursor_free(del_start);
evas_textblock_cursor_free(del_end);
-
- return ECORE_CALLBACK_DONE;
}
#endif