aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/edje/src/lib/edje_entry.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-23 23:30:42 +1000
committerDavid Walter Seikel2012-01-23 23:30:42 +1000
commit825a3d837a33f226c879cd02ad15c3fba57e8b2c (patch)
tree75f57bd9c4253508d338dc79ba8e57a7abc42255 /libraries/edje/src/lib/edje_entry.c
parentAdd ability to disable the test harness, or the Lua compile test. (diff)
downloadSledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.zip
SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.gz
SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.bz2
SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.xz
Update the EFL to what I'm actually using, coz I'm using some stuff not yet released.
Diffstat (limited to 'libraries/edje/src/lib/edje_entry.c')
-rw-r--r--libraries/edje/src/lib/edje_entry.c350
1 files changed, 194 insertions, 156 deletions
diff --git a/libraries/edje/src/lib/edje_entry.c b/libraries/edje/src/lib/edje_entry.c
index e25397a..563497d 100644
--- a/libraries/edje/src/lib/edje_entry.c
+++ b/libraries/edje/src/lib/edje_entry.c
@@ -2,9 +2,9 @@
2 2
3#ifdef HAVE_ECORE_IMF 3#ifdef HAVE_ECORE_IMF
4static Eina_Bool _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos); 4static Eina_Bool _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos);
5static Eina_Bool _edje_entry_imf_event_commit_cb(void *data, int type, void *event); 5static void _edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx, void *event_info);
6static Eina_Bool _edje_entry_imf_event_preedit_changed_cb(void *data, int type, void *event); 6static void _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx, void *event_info);
7static Eina_Bool _edje_entry_imf_event_delete_surrounding_cb(void *data, int type, void *event); 7static void _edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx, void *event);
8#endif 8#endif
9 9
10typedef struct _Entry Entry; 10typedef struct _Entry Entry;
@@ -39,10 +39,6 @@ struct _Entry
39#ifdef HAVE_ECORE_IMF 39#ifdef HAVE_ECORE_IMF
40 Eina_Bool have_preedit : 1; 40 Eina_Bool have_preedit : 1;
41 Ecore_IMF_Context *imf_context; 41 Ecore_IMF_Context *imf_context;
42
43 Ecore_Event_Handler *imf_ee_handler_commit;
44 Ecore_Event_Handler *imf_ee_handler_delete;
45 Ecore_Event_Handler *imf_ee_handler_changed;
46#endif 42#endif
47}; 43};
48 44
@@ -272,20 +268,6 @@ _curs_update_from_curs(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entr
272 *cy += (ch / 2); 268 *cy += (ch / 2);
273} 269}
274 270
275static void
276_curs_back(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
277 Entry *en __UNUSED__)
278{
279 evas_textblock_cursor_char_prev(c);
280}
281
282static void
283_curs_next(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
284 Entry *en __UNUSED__)
285{
286 evas_textblock_cursor_char_next(c);
287}
288
289static int 271static int
290_curs_line_last_get(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en __UNUSED__) 272_curs_line_last_get(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en __UNUSED__)
291{ 273{
@@ -415,6 +397,7 @@ static void
415_sel_extend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en) 397_sel_extend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
416{ 398{
417 if (!en->sel_end) return; 399 if (!en->sel_end) return;
400 _edje_entry_imf_context_reset(en);
418 _sel_enable(c, o, en); 401 _sel_enable(c, o, en);
419 if (!evas_textblock_cursor_compare(c, en->sel_end)) return; 402 if (!evas_textblock_cursor_compare(c, en->sel_end)) return;
420 evas_textblock_cursor_copy(c, en->sel_end); 403 evas_textblock_cursor_copy(c, en->sel_end);
@@ -424,13 +407,13 @@ _sel_extend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
424 en->selection = NULL; 407 en->selection = NULL;
425 } 408 }
426 _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name); 409 _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
427 _edje_entry_imf_context_reset(en);
428} 410}
429 411
430static void 412static void
431_sel_preextend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en) 413_sel_preextend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
432{ 414{
433 if (!en->sel_end) return; 415 if (!en->sel_end) return;
416 _edje_entry_imf_context_reset(en);
434 _sel_enable(c, o, en); 417 _sel_enable(c, o, en);
435 if (!evas_textblock_cursor_compare(c, en->sel_start)) return; 418 if (!evas_textblock_cursor_compare(c, en->sel_start)) return;
436 evas_textblock_cursor_copy(c, en->sel_start); 419 evas_textblock_cursor_copy(c, en->sel_start);
@@ -440,7 +423,6 @@ _sel_preextend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
440 en->selection = NULL; 423 en->selection = NULL;
441 } 424 }
442 _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name); 425 _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
443 _edje_entry_imf_context_reset(en);
444} 426}
445 427
446static void 428static void
@@ -1107,6 +1089,10 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1107 } 1089 }
1108#endif 1090#endif
1109 1091
1092 if ((!strcmp(ev->key, "Escape")) ||
1093 (!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter")))
1094 _edje_entry_imf_context_reset(en);
1095
1110 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor); 1096 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
1111 1097
1112 control = evas_key_modifier_is_set(ev->modifiers, "Control"); 1098 control = evas_key_modifier_is_set(ev->modifiers, "Control");
@@ -1138,6 +1124,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1138 } 1124 }
1139 _sel_clear(en->cursor, rp->object, en); 1125 _sel_clear(en->cursor, rp->object, en);
1140 _edje_emit(ed, "entry,key,up", rp->part->name); 1126 _edje_emit(ed, "entry,key,up", rp->part->name);
1127 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1141 } 1128 }
1142 else if (!strcmp(ev->key, "Down") || !strcmp(ev->key, "KP_Down")) 1129 else if (!strcmp(ev->key, "Down") || !strcmp(ev->key, "KP_Down"))
1143 { 1130 {
@@ -1157,6 +1144,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1157 } 1144 }
1158 _sel_clear(en->cursor, rp->object, en); 1145 _sel_clear(en->cursor, rp->object, en);
1159 _edje_emit(ed, "entry,key,down", rp->part->name); 1146 _edje_emit(ed, "entry,key,down", rp->part->name);
1147 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1160 } 1148 }
1161 else if (!strcmp(ev->key, "Left") || !strcmp(ev->key, "KP_Left")) 1149 else if (!strcmp(ev->key, "Left") || !strcmp(ev->key, "KP_Left"))
1162 { 1150 {
@@ -1165,13 +1153,16 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1165 if (shift) _sel_start(en->cursor, rp->object, en); 1153 if (shift) _sel_start(en->cursor, rp->object, en);
1166 else _sel_clear(en->cursor, rp->object, en); 1154 else _sel_clear(en->cursor, rp->object, en);
1167 } 1155 }
1168 _curs_back(en->cursor, rp->object, en); 1156 evas_textblock_cursor_char_prev(en->cursor);
1157 /* If control is pressed, go to the start of the word */
1158 if (control) evas_textblock_cursor_word_start(en->cursor);
1169 if (en->select_allow) 1159 if (en->select_allow)
1170 { 1160 {
1171 if (shift) _sel_extend(en->cursor, rp->object, en); 1161 if (shift) _sel_extend(en->cursor, rp->object, en);
1172 } 1162 }
1173 _sel_clear(en->cursor, rp->object, en); 1163 _sel_clear(en->cursor, rp->object, en);
1174 _edje_emit(ed, "entry,key,left", rp->part->name); 1164 _edje_emit(ed, "entry,key,left", rp->part->name);
1165 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1175 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1166 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1176 } 1167 }
1177 else if (!strcmp(ev->key, "Right") || !strcmp(ev->key, "KP_Right")) 1168 else if (!strcmp(ev->key, "Right") || !strcmp(ev->key, "KP_Right"))
@@ -1181,20 +1172,31 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1181 if (shift) _sel_start(en->cursor, rp->object, en); 1172 if (shift) _sel_start(en->cursor, rp->object, en);
1182 else _sel_clear(en->cursor, rp->object, en); 1173 else _sel_clear(en->cursor, rp->object, en);
1183 } 1174 }
1184 _curs_next(en->cursor, rp->object, en); 1175 /* If control is pressed, go to the start of the word */
1176 if (control) evas_textblock_cursor_word_end(en->cursor);
1177 evas_textblock_cursor_char_next(en->cursor);
1185 if (en->select_allow) 1178 if (en->select_allow)
1186 { 1179 {
1187 if (shift) _sel_extend(en->cursor, rp->object, en); 1180 if (shift) _sel_extend(en->cursor, rp->object, en);
1188 } 1181 }
1189 _sel_clear(en->cursor, rp->object, en); 1182 _sel_clear(en->cursor, rp->object, en);
1190 _edje_emit(ed, "entry,key,right", rp->part->name); 1183 _edje_emit(ed, "entry,key,right", rp->part->name);
1184 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1191 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1185 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1192 } 1186 }
1193 else if (!strcmp(ev->key, "BackSpace")) 1187 else if (!strcmp(ev->key, "BackSpace"))
1194 { 1188 {
1195 if (control) 1189 if (control && !en->have_selection)
1196 { 1190 {
1197 // del to start of previous word 1191 // del to start of previous word
1192 _sel_start(en->cursor, rp->object, en);
1193
1194 evas_textblock_cursor_char_prev(en->cursor);
1195 evas_textblock_cursor_word_start(en->cursor);
1196
1197 _sel_extend(en->cursor, rp->object, en);
1198
1199 _range_del_emit(ed, en->cursor, rp->object, en);
1198 } 1200 }
1199 else if ((alt) && (shift)) 1201 else if ((alt) && (shift))
1200 { 1202 {
@@ -1224,6 +1226,14 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1224 if (control) 1226 if (control)
1225 { 1227 {
1226 // del to end of next word 1228 // del to end of next word
1229 _sel_start(en->cursor, rp->object, en);
1230
1231 evas_textblock_cursor_word_end(en->cursor);
1232 evas_textblock_cursor_char_next(en->cursor);
1233
1234 _sel_extend(en->cursor, rp->object, en);
1235
1236 _range_del_emit(ed, en->cursor, rp->object, en);
1227 } 1237 }
1228 else if (shift) 1238 else if (shift)
1229 { 1239 {
@@ -1281,10 +1291,6 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1281 _edje_emit(ed, "entry,key,end", rp->part->name); 1291 _edje_emit(ed, "entry,key,end", rp->part->name);
1282 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1292 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1283 } 1293 }
1284 else if (!strcmp(ev->key, "Shift_L") || !strcmp(ev->key, "Shift_R"))
1285 {
1286 return;
1287 }
1288 else if ((control) && (!strcmp(ev->key, "v"))) 1294 else if ((control) && (!strcmp(ev->key, "v")))
1289 { 1295 {
1290 _edje_emit(ed, "entry,paste,request", rp->part->name); 1296 _edje_emit(ed, "entry,paste,request", rp->part->name);
@@ -1303,13 +1309,11 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1303 } 1309 }
1304 else if ((control) && ((!strcmp(ev->key, "c") || (!strcmp(ev->key, "Insert"))))) 1310 else if ((control) && ((!strcmp(ev->key, "c") || (!strcmp(ev->key, "Insert")))))
1305 { 1311 {
1306 // FIXME: copy - save selection
1307 _edje_emit(ed, "entry,copy,notify", rp->part->name); 1312 _edje_emit(ed, "entry,copy,notify", rp->part->name);
1308 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1313 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1309 } 1314 }
1310 else if ((control) && ((!strcmp(ev->key, "x") || (!strcmp(ev->key, "m"))))) 1315 else if ((control) && ((!strcmp(ev->key, "x") || (!strcmp(ev->key, "m")))))
1311 { 1316 {
1312 // FIXME: cut - save selection, delete seletion
1313 _edje_emit(ed, "entry,cut,notify", rp->part->name); 1317 _edje_emit(ed, "entry,cut,notify", rp->part->name);
1314 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1318 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1315 } 1319 }
@@ -1336,7 +1340,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1336 else if ((control) && (!strcmp(ev->key, "w"))) 1340 else if ((control) && (!strcmp(ev->key, "w")))
1337 { 1341 {
1338 _sel_clear(en->cursor, rp->object, en); 1342 _sel_clear(en->cursor, rp->object, en);
1339 // select current word 1343 // select current word?
1340 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1344 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1341 } 1345 }
1342 else if (!strcmp(ev->key, "Tab")) 1346 else if (!strcmp(ev->key, "Tab"))
@@ -1361,10 +1365,10 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1361 _sel_clear(en->cursor, rp->object, en); 1365 _sel_clear(en->cursor, rp->object, en);
1362 info->change.insert.pos = 1366 info->change.insert.pos =
1363 evas_textblock_cursor_pos_get(en->cursor); 1367 evas_textblock_cursor_pos_get(en->cursor);
1364 info->change.insert.content = eina_stringshare_add("<\t>"); 1368 info->change.insert.content = eina_stringshare_add("<tab/>");
1365 //yy 1369 //yy
1366// evas_textblock_cursor_format_prepend(en->cursor, "\t"); 1370// evas_textblock_cursor_format_prepend(en->cursor, "tab");
1367 _text_filter_format_prepend(en, en->cursor, "\t"); 1371 _text_filter_format_prepend(en, en->cursor, "tab");
1368 _anchors_get(en->cursor, rp->object, en); 1372 _anchors_get(en->cursor, rp->object, en);
1369 _edje_emit(ed, "entry,changed", rp->part->name); 1373 _edje_emit(ed, "entry,changed", rp->part->name);
1370 _edje_emit_full(ed, "entry,changed,user", rp->part->name, 1374 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
@@ -1427,19 +1431,20 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1427 1431
1428 info->change.insert.pos = 1432 info->change.insert.pos =
1429 evas_textblock_cursor_pos_get(en->cursor); 1433 evas_textblock_cursor_pos_get(en->cursor);
1430 if (shift) 1434 if (shift ||
1435 evas_object_textblock_legacy_newline_get(rp->object))
1431 { 1436 {
1432 //yy 1437 //yy
1433// evas_textblock_cursor_format_prepend(en->cursor, "\n"); 1438// evas_textblock_cursor_format_prepend(en->cursor, "br");
1434 _text_filter_format_prepend(en, en->cursor, "\n"); 1439 _text_filter_format_prepend(en, en->cursor, "br");
1435 info->change.insert.content = eina_stringshare_add("<\n>"); 1440 info->change.insert.content = eina_stringshare_add("<br/>");
1436 } 1441 }
1437 else 1442 else
1438 { 1443 {
1439 //yy 1444 //yy
1440// evas_textblock_cursor_format_prepend(en->cursor, "ps"); 1445// evas_textblock_cursor_format_prepend(en->cursor, "ps");
1441 _text_filter_format_prepend(en, en->cursor, "ps"); 1446 _text_filter_format_prepend(en, en->cursor, "ps");
1442 info->change.insert.content = eina_stringshare_add("<ps>"); 1447 info->change.insert.content = eina_stringshare_add("<ps/>");
1443 } 1448 }
1444 _anchors_get(en->cursor, rp->object, en); 1449 _anchors_get(en->cursor, rp->object, en);
1445 _edje_emit(ed, "entry,changed", rp->part->name); 1450 _edje_emit(ed, "entry,changed", rp->part->name);
@@ -1499,7 +1504,6 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1499 if (!cursor_changed && (old_cur_pos != evas_textblock_cursor_pos_get(en->cursor))) 1504 if (!cursor_changed && (old_cur_pos != evas_textblock_cursor_pos_get(en->cursor)))
1500 _edje_emit(ed, "cursor,changed", rp->part->name); 1505 _edje_emit(ed, "cursor,changed", rp->part->name);
1501 1506
1502 _edje_entry_imf_context_reset(en);
1503 _edje_entry_imf_cursor_info_set(en); 1507 _edje_entry_imf_cursor_info_set(en);
1504 _edje_entry_real_part_configure(rp); 1508 _edje_entry_real_part_configure(rp);
1505} 1509}
@@ -1576,6 +1580,8 @@ _edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUS
1576 } 1580 }
1577#endif 1581#endif
1578 1582
1583 _edje_entry_imf_context_reset(en);
1584
1579 en->select_mod_start = EINA_FALSE; 1585 en->select_mod_start = EINA_FALSE;
1580 en->select_mod_end = EINA_FALSE; 1586 en->select_mod_end = EINA_FALSE;
1581 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT) 1587 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
@@ -1690,10 +1696,12 @@ _edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUS
1690 } 1696 }
1691 } 1697 }
1692 if (evas_textblock_cursor_compare(tc, en->cursor)) 1698 if (evas_textblock_cursor_compare(tc, en->cursor))
1693 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 1699 {
1700 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
1701 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1702 }
1694 evas_textblock_cursor_free(tc); 1703 evas_textblock_cursor_free(tc);
1695 1704
1696 _edje_entry_imf_context_reset(en);
1697 _edje_entry_imf_cursor_info_set(en); 1705 _edje_entry_imf_cursor_info_set(en);
1698 1706
1699 _edje_entry_real_part_configure(rp); 1707 _edje_entry_real_part_configure(rp);
@@ -1733,6 +1741,8 @@ _edje_part_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED
1733 } 1741 }
1734#endif 1742#endif
1735 1743
1744 _edje_entry_imf_context_reset(en);
1745
1736 tc = evas_object_textblock_cursor_new(rp->object); 1746 tc = evas_object_textblock_cursor_new(rp->object);
1737 evas_textblock_cursor_copy(en->cursor, tc); 1747 evas_textblock_cursor_copy(en->cursor, tc);
1738 evas_object_geometry_get(rp->object, &x, &y, &w, &h); 1748 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
@@ -1799,10 +1809,12 @@ _edje_part_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED
1799 en->selecting = EINA_FALSE; 1809 en->selecting = EINA_FALSE;
1800 } 1810 }
1801 if (evas_textblock_cursor_compare(tc, en->cursor)) 1811 if (evas_textblock_cursor_compare(tc, en->cursor))
1802 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 1812 {
1813 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
1814 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1815 }
1803 evas_textblock_cursor_free(tc); 1816 evas_textblock_cursor_free(tc);
1804 1817
1805 _edje_entry_imf_context_reset(en);
1806 _edje_entry_imf_cursor_info_set(en); 1818 _edje_entry_imf_cursor_info_set(en);
1807 _edje_entry_real_part_configure(rp); 1819 _edje_entry_real_part_configure(rp);
1808} 1820}
@@ -1893,7 +1905,10 @@ _edje_part_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUS
1893 _sel_update(en->cursor, rp->object, en); 1905 _sel_update(en->cursor, rp->object, en);
1894 } 1906 }
1895 if (evas_textblock_cursor_compare(tc, en->cursor)) 1907 if (evas_textblock_cursor_compare(tc, en->cursor))
1896 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 1908 {
1909 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
1910 _edje_emit(rp->edje, "cursor,changed,manual", rp->part->name);
1911 }
1897 evas_textblock_cursor_free(tc); 1912 evas_textblock_cursor_free(tc);
1898 1913
1899 _edje_entry_imf_context_reset(en); 1914 _edje_entry_imf_context_reset(en);
@@ -2014,6 +2029,8 @@ _edje_entry_real_part_init(Edje_Real_Part *rp)
2014 evas_object_pass_events_set(en->cursor_fg, EINA_TRUE); 2029 evas_object_pass_events_set(en->cursor_fg, EINA_TRUE);
2015 _edje_subobj_register(en->rp->edje, en->cursor_fg); 2030 _edje_subobj_register(en->rp->edje, en->cursor_fg);
2016 2031
2032 evas_object_textblock_legacy_newline_set(rp->object, EINA_TRUE);
2033
2017 if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE) 2034 if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
2018 { 2035 {
2019 evas_object_show(en->cursor_bg); 2036 evas_object_show(en->cursor_bg);
@@ -2055,9 +2072,9 @@ _edje_entry_real_part_init(Edje_Real_Part *rp)
2055 2072
2056 ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context, 2073 ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context,
2057 _edje_entry_imf_retrieve_surrounding_cb, rp->edje); 2074 _edje_entry_imf_retrieve_surrounding_cb, rp->edje);
2058 en->imf_ee_handler_commit = ecore_event_handler_add(ECORE_IMF_EVENT_COMMIT, _edje_entry_imf_event_commit_cb, rp->edje); 2075 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb, rp->edje);
2059 en->imf_ee_handler_delete = ecore_event_handler_add(ECORE_IMF_EVENT_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb, rp->edje); 2076 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb, rp->edje);
2060 en->imf_ee_handler_changed = ecore_event_handler_add(ECORE_IMF_EVENT_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb, rp->edje); 2077 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb, rp->edje);
2061 ecore_imf_context_input_mode_set(en->imf_context, 2078 ecore_imf_context_input_mode_set(en->imf_context,
2062 rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD ? 2079 rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD ?
2063 ECORE_IMF_INPUT_MODE_INVISIBLE : ECORE_IMF_INPUT_MODE_FULL); 2080 ECORE_IMF_INPUT_MODE_INVISIBLE : ECORE_IMF_INPUT_MODE_FULL);
@@ -2094,23 +2111,9 @@ _edje_entry_real_part_shutdown(Edje_Real_Part *rp)
2094 { 2111 {
2095 if (en->imf_context) 2112 if (en->imf_context)
2096 { 2113 {
2097 if (en->imf_ee_handler_commit) 2114 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb);
2098 { 2115 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb);
2099 ecore_event_handler_del(en->imf_ee_handler_commit); 2116 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb);
2100 en->imf_ee_handler_commit = NULL;
2101 }
2102
2103 if (en->imf_ee_handler_delete)
2104 {
2105 ecore_event_handler_del(en->imf_ee_handler_delete);
2106 en->imf_ee_handler_delete = NULL;
2107 }
2108
2109 if (en->imf_ee_handler_changed)
2110 {
2111 ecore_event_handler_del(en->imf_ee_handler_changed);
2112 en->imf_ee_handler_changed = NULL;
2113 }
2114 2117
2115 ecore_imf_context_del(en->imf_context); 2118 ecore_imf_context_del(en->imf_context);
2116 en->imf_context = NULL; 2119 en->imf_context = NULL;
@@ -2189,7 +2192,7 @@ _edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text)
2189{ 2192{
2190 Entry *en = rp->entry_data; 2193 Entry *en = rp->entry_data;
2191 if (!en) return; 2194 if (!en) return;
2192 2195 _edje_entry_imf_context_reset(en);
2193 // set text as markup 2196 // set text as markup
2194 _sel_clear(en->cursor, rp->object, en); 2197 _sel_clear(en->cursor, rp->object, en);
2195 evas_object_textblock_text_markup_set(rp->object, text); 2198 evas_object_textblock_text_markup_set(rp->object, text);
@@ -2228,6 +2231,8 @@ _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text)
2228{ 2231{
2229 Entry *en = rp->entry_data; 2232 Entry *en = rp->entry_data;
2230 if (!en) return; 2233 if (!en) return;
2234 _edje_entry_imf_context_reset(en);
2235
2231 // prepend markup @ cursor pos 2236 // prepend markup @ cursor pos
2232 if (en->have_selection) 2237 if (en->have_selection)
2233 _range_del(en->cursor, rp->object, en); 2238 _range_del(en->cursor, rp->object, en);
@@ -2239,9 +2244,7 @@ _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text)
2239 _edje_emit(rp->edje, "entry,changed", rp->part->name); 2244 _edje_emit(rp->edje, "entry,changed", rp->part->name);
2240 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 2245 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2241 2246
2242 _edje_entry_imf_context_reset(en);
2243 _edje_entry_imf_cursor_info_set(en); 2247 _edje_entry_imf_cursor_info_set(en);
2244
2245 _edje_entry_real_part_configure(rp); 2248 _edje_entry_real_part_configure(rp);
2246} 2249}
2247 2250
@@ -2278,6 +2281,9 @@ _edje_entry_select_all(Edje_Real_Part *rp)
2278{ 2281{
2279 Entry *en = rp->entry_data; 2282 Entry *en = rp->entry_data;
2280 if (!en) return; 2283 if (!en) return;
2284
2285 _edje_entry_imf_context_reset(en);
2286
2281 _sel_clear(en->cursor, rp->object, en); 2287 _sel_clear(en->cursor, rp->object, en);
2282 _curs_start(en->cursor, rp->object, en); 2288 _curs_start(en->cursor, rp->object, en);
2283 _sel_enable(en->cursor, rp->object, en); 2289 _sel_enable(en->cursor, rp->object, en);
@@ -2285,7 +2291,6 @@ _edje_entry_select_all(Edje_Real_Part *rp)
2285 _curs_end(en->cursor, rp->object, en); 2291 _curs_end(en->cursor, rp->object, en);
2286 _sel_extend(en->cursor, rp->object, en); 2292 _sel_extend(en->cursor, rp->object, en);
2287 2293
2288 _edje_entry_imf_context_reset(en);
2289 _edje_entry_imf_cursor_info_set(en); 2294 _edje_entry_imf_cursor_info_set(en);
2290 _edje_entry_real_part_configure(rp); 2295 _edje_entry_real_part_configure(rp);
2291} 2296}
@@ -2295,12 +2300,14 @@ _edje_entry_select_begin(Edje_Real_Part *rp)
2295{ 2300{
2296 Entry *en = rp->entry_data; 2301 Entry *en = rp->entry_data;
2297 if (!en) return; 2302 if (!en) return;
2303
2304 _edje_entry_imf_context_reset(en);
2305
2298 _sel_clear(en->cursor, rp->object, en); 2306 _sel_clear(en->cursor, rp->object, en);
2299 _sel_enable(en->cursor, rp->object, en); 2307 _sel_enable(en->cursor, rp->object, en);
2300 _sel_start(en->cursor, rp->object, en); 2308 _sel_start(en->cursor, rp->object, en);
2301 _sel_extend(en->cursor, rp->object, en); 2309 _sel_extend(en->cursor, rp->object, en);
2302 2310
2303 _edje_entry_imf_context_reset(en);
2304 _edje_entry_imf_cursor_info_set(en); 2311 _edje_entry_imf_cursor_info_set(en);
2305 2312
2306 _edje_entry_real_part_configure(rp); 2313 _edje_entry_real_part_configure(rp);
@@ -2311,9 +2318,9 @@ _edje_entry_select_extend(Edje_Real_Part *rp)
2311{ 2318{
2312 Entry *en = rp->entry_data; 2319 Entry *en = rp->entry_data;
2313 if (!en) return; 2320 if (!en) return;
2321 _edje_entry_imf_context_reset(en);
2314 _sel_extend(en->cursor, rp->object, en); 2322 _sel_extend(en->cursor, rp->object, en);
2315 2323
2316 _edje_entry_imf_context_reset(en);
2317 _edje_entry_imf_cursor_info_set(en); 2324 _edje_entry_imf_cursor_info_set(en);
2318 2325
2319 _edje_entry_real_part_configure(rp); 2326 _edje_entry_real_part_configure(rp);
@@ -2560,13 +2567,14 @@ _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur)
2560 Entry *en = rp->entry_data; 2567 Entry *en = rp->entry_data;
2561 Evas_Textblock_Cursor *c = _cursor_get(rp, cur); 2568 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2562 if (!c) return EINA_FALSE; 2569 if (!c) return EINA_FALSE;
2570
2571 _edje_entry_imf_context_reset(en);
2572
2563 if (!evas_textblock_cursor_char_next(c)) 2573 if (!evas_textblock_cursor_char_next(c))
2564 { 2574 {
2565 return EINA_FALSE; 2575 return EINA_FALSE;
2566 } 2576 }
2567 _sel_update(c, rp->object, rp->entry_data); 2577 _sel_update(c, rp->object, rp->entry_data);
2568
2569 _edje_entry_imf_context_reset(en);
2570 _edje_entry_imf_cursor_info_set(en); 2578 _edje_entry_imf_cursor_info_set(en);
2571 2579
2572 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 2580 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
@@ -2580,6 +2588,9 @@ _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur)
2580 Entry *en = rp->entry_data; 2588 Entry *en = rp->entry_data;
2581 Evas_Textblock_Cursor *c = _cursor_get(rp, cur); 2589 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2582 if (!c) return EINA_FALSE; 2590 if (!c) return EINA_FALSE;
2591
2592 _edje_entry_imf_context_reset(en);
2593
2583 if (!evas_textblock_cursor_char_prev(c)) 2594 if (!evas_textblock_cursor_char_prev(c))
2584 { 2595 {
2585 if (evas_textblock_cursor_paragraph_prev(c)) goto ok; 2596 if (evas_textblock_cursor_paragraph_prev(c)) goto ok;
@@ -2588,7 +2599,6 @@ _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur)
2588ok: 2599ok:
2589 _sel_update(c, rp->object, rp->entry_data); 2600 _sel_update(c, rp->object, rp->entry_data);
2590 2601
2591 _edje_entry_imf_context_reset(en);
2592 _edje_entry_imf_cursor_info_set(en); 2602 _edje_entry_imf_cursor_info_set(en);
2593 2603
2594 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 2604 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
@@ -2604,6 +2614,9 @@ _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur)
2604 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch; 2614 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
2605 int ln; 2615 int ln;
2606 if (!c) return EINA_FALSE; 2616 if (!c) return EINA_FALSE;
2617
2618 _edje_entry_imf_context_reset(en);
2619
2607 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL); 2620 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
2608 ln--; 2621 ln--;
2609 if (ln < 0) return EINA_FALSE; 2622 if (ln < 0) return EINA_FALSE;
@@ -2620,7 +2633,6 @@ _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur)
2620 } 2633 }
2621 _sel_update(c, rp->object, rp->entry_data); 2634 _sel_update(c, rp->object, rp->entry_data);
2622 2635
2623 _edje_entry_imf_context_reset(en);
2624 _edje_entry_imf_cursor_info_set(en); 2636 _edje_entry_imf_cursor_info_set(en);
2625 2637
2626 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 2638 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
@@ -2636,6 +2648,9 @@ _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur)
2636 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch; 2648 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
2637 int ln; 2649 int ln;
2638 if (!c) return EINA_FALSE; 2650 if (!c) return EINA_FALSE;
2651
2652 _edje_entry_imf_context_reset(en);
2653
2639 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL); 2654 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
2640 ln++; 2655 ln++;
2641 if (!evas_object_textblock_line_number_geometry_get(rp->object, ln, 2656 if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
@@ -2651,7 +2666,6 @@ _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur)
2651 } 2666 }
2652 _sel_update(c, rp->object, rp->entry_data); 2667 _sel_update(c, rp->object, rp->entry_data);
2653 2668
2654 _edje_entry_imf_context_reset(en);
2655 _edje_entry_imf_cursor_info_set(en); 2669 _edje_entry_imf_cursor_info_set(en);
2656 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 2670 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2657 _edje_entry_real_part_configure(rp); 2671 _edje_entry_real_part_configure(rp);
@@ -2664,10 +2678,12 @@ _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur)
2664 Entry *en = rp->entry_data; 2678 Entry *en = rp->entry_data;
2665 Evas_Textblock_Cursor *c = _cursor_get(rp, cur); 2679 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2666 if (!c) return; 2680 if (!c) return;
2681
2682 _edje_entry_imf_context_reset(en);
2683
2667 evas_textblock_cursor_paragraph_first(c); 2684 evas_textblock_cursor_paragraph_first(c);
2668 _sel_update(c, rp->object, rp->entry_data); 2685 _sel_update(c, rp->object, rp->entry_data);
2669 2686
2670 _edje_entry_imf_context_reset(en);
2671 _edje_entry_imf_cursor_info_set(en); 2687 _edje_entry_imf_cursor_info_set(en);
2672 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 2688 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2673 _edje_entry_real_part_configure(rp); 2689 _edje_entry_real_part_configure(rp);
@@ -2679,10 +2695,12 @@ _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur)
2679 Entry *en = rp->entry_data; 2695 Entry *en = rp->entry_data;
2680 Evas_Textblock_Cursor *c = _cursor_get(rp, cur); 2696 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2681 if (!c) return; 2697 if (!c) return;
2698
2699 _edje_entry_imf_context_reset(en);
2700
2682 _curs_end(c, rp->object, rp->entry_data); 2701 _curs_end(c, rp->object, rp->entry_data);
2683 _sel_update(c, rp->object, rp->entry_data); 2702 _sel_update(c, rp->object, rp->entry_data);
2684 2703
2685 _edje_entry_imf_context_reset(en);
2686 _edje_entry_imf_cursor_info_set(en); 2704 _edje_entry_imf_cursor_info_set(en);
2687 2705
2688 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 2706 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
@@ -2715,10 +2733,11 @@ _edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur)
2715 Entry *en = rp->entry_data; 2733 Entry *en = rp->entry_data;
2716 Evas_Textblock_Cursor *c = _cursor_get(rp, cur); 2734 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2717 if (!c) return; 2735 if (!c) return;
2736 _edje_entry_imf_context_reset(en);
2737
2718 evas_textblock_cursor_line_char_first(c); 2738 evas_textblock_cursor_line_char_first(c);
2719 _sel_update(c, rp->object, rp->entry_data); 2739 _sel_update(c, rp->object, rp->entry_data);
2720 2740
2721 _edje_entry_imf_context_reset(en);
2722 _edje_entry_imf_cursor_info_set(en); 2741 _edje_entry_imf_cursor_info_set(en);
2723 2742
2724 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 2743 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
@@ -2731,10 +2750,10 @@ _edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur)
2731 Entry *en = rp->entry_data; 2750 Entry *en = rp->entry_data;
2732 Evas_Textblock_Cursor *c = _cursor_get(rp, cur); 2751 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2733 if (!c) return; 2752 if (!c) return;
2753 _edje_entry_imf_context_reset(en);
2734 evas_textblock_cursor_line_char_last(c); 2754 evas_textblock_cursor_line_char_last(c);
2735 _sel_update(c, rp->object, rp->entry_data); 2755 _sel_update(c, rp->object, rp->entry_data);
2736 2756
2737 _edje_entry_imf_context_reset(en);
2738 _edje_entry_imf_cursor_info_set(en); 2757 _edje_entry_imf_cursor_info_set(en);
2739 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 2758 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2740 _edje_entry_real_part_configure(rp); 2759 _edje_entry_real_part_configure(rp);
@@ -2766,7 +2785,7 @@ _edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
2766 return evas_textblock_cursor_format_is_visible_get(c); 2785 return evas_textblock_cursor_format_is_visible_get(c);
2767} 2786}
2768 2787
2769const char * 2788char *
2770_edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur) 2789_edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur)
2771{ 2790{
2772 static char *s = NULL; 2791 static char *s = NULL;
@@ -2793,10 +2812,10 @@ _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos)
2793 if (evas_textblock_cursor_pos_get(c) == pos) 2812 if (evas_textblock_cursor_pos_get(c) == pos)
2794 return; 2813 return;
2795 2814
2815 _edje_entry_imf_context_reset(en);
2796 evas_textblock_cursor_pos_set(c, pos); 2816 evas_textblock_cursor_pos_set(c, pos);
2797 _sel_update(c, rp->object, rp->entry_data); 2817 _sel_update(c, rp->object, rp->entry_data);
2798 2818
2799 _edje_entry_imf_context_reset(en);
2800 _edje_entry_imf_cursor_info_set(en); 2819 _edje_entry_imf_cursor_info_set(en);
2801 _edje_emit(rp->edje, "cursor,changed", rp->part->name); 2820 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2802 _edje_entry_real_part_configure(rp); 2821 _edje_entry_real_part_configure(rp);
@@ -2891,43 +2910,33 @@ _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNU
2891 return EINA_TRUE; 2910 return EINA_TRUE;
2892} 2911}
2893 2912
2894static Eina_Bool 2913static void
2895_edje_entry_imf_event_commit_cb(void *data, int type __UNUSED__, void *event) 2914_edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info)
2896{ 2915{
2897 Edje *ed = data; 2916 Edje *ed = data;
2898 Edje_Real_Part *rp = ed->focused_part; 2917 Edje_Real_Part *rp = ed->focused_part;
2899 Entry *en; 2918 Entry *en;
2900 Ecore_IMF_Event_Commit *ev = event; 2919 char *commit_str = event_info;
2901 Evas_Textblock_Cursor *tc; 2920 int start_pos;
2902 Eina_Bool cursor_move = EINA_FALSE;
2903 2921
2904 if ((!rp) || (!ev) || (!ev->str)) return ECORE_CALLBACK_PASS_ON; 2922 if ((!rp)) return;
2905 2923
2906 en = rp->entry_data; 2924 en = rp->entry_data;
2907 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || 2925 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2908 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) 2926 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2909 return ECORE_CALLBACK_PASS_ON; 2927 return;
2910
2911 if (!en->imf_context) return ECORE_CALLBACK_PASS_ON;
2912 if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON;
2913 2928
2914 if (en->have_selection) 2929 if (en->have_selection)
2915 { 2930 {
2916 if (strcmp(ev->str, "")) 2931 if (strcmp(commit_str, ""))
2917 { 2932 {
2918 /* delete selected characters */ 2933 /* delete selected characters */
2919 _range_del(en->cursor, rp->object, en); 2934 _range_del_emit(ed, en->cursor, rp->object, en);
2920 _sel_clear(en->cursor, rp->object, en); 2935 _sel_clear(en->cursor, rp->object, en);
2921 } 2936 }
2922 } 2937 }
2923 2938
2924 tc = evas_object_textblock_cursor_new(rp->object); 2939 start_pos = evas_textblock_cursor_pos_get(en->cursor);
2925
2926 /* calculate the cursor position to insert commit string */
2927 if (en->preedit_start)
2928 evas_textblock_cursor_copy(en->preedit_start, tc);
2929 else
2930 evas_textblock_cursor_copy(en->cursor, tc);
2931 2940
2932#ifdef HAVE_ECORE_IMF 2941#ifdef HAVE_ECORE_IMF
2933 /* delete preedit characters */ 2942 /* delete preedit characters */
@@ -2935,17 +2944,16 @@ _edje_entry_imf_event_commit_cb(void *data, int type __UNUSED__, void *event)
2935 _preedit_clear(en); 2944 _preedit_clear(en);
2936#endif 2945#endif
2937 2946
2938 if (evas_textblock_cursor_compare(en->cursor, tc))
2939 cursor_move = EINA_TRUE;
2940 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) && 2947 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
2941 _edje_password_show_last) 2948 _edje_password_show_last)
2942 _edje_entry_hide_visible_password(en->rp); 2949 _edje_entry_hide_visible_password(en->rp);
2943 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) && 2950 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
2944 _edje_password_show_last && (!en->preedit_start)) 2951 _edje_password_show_last && (!en->preedit_start))
2945 { 2952 {
2946 _text_filter_format_prepend(en, tc, "+ password=off"); 2953 _text_filter_format_prepend(en, en->cursor, "+ password=off");
2947 _text_filter_markup_prepend(en, tc, ev->str); 2954 _text_filter_text_prepend(en, en->cursor, commit_str);
2948 _text_filter_format_prepend(en, tc, "- password"); 2955 _text_filter_format_prepend(en, en->cursor, "- password");
2956
2949 if (en->pw_timer) 2957 if (en->pw_timer)
2950 { 2958 {
2951 ecore_timer_del(en->pw_timer); 2959 ecore_timer_del(en->pw_timer);
@@ -2955,51 +2963,54 @@ _edje_entry_imf_event_commit_cb(void *data, int type __UNUSED__, void *event)
2955 _password_timer_cb, en); 2963 _password_timer_cb, en);
2956 } 2964 }
2957 else 2965 else
2958 _text_filter_text_prepend(en, tc, ev->str); 2966 _text_filter_text_prepend(en, en->cursor, commit_str);
2959
2960 if (!cursor_move)
2961 {
2962 /* move cursor to the end of commit string */
2963 evas_textblock_cursor_copy(tc, en->cursor);
2964 }
2965 2967
2966 evas_textblock_cursor_free(tc);
2967 2968
2968 _edje_entry_imf_cursor_info_set(en); 2969 _edje_entry_imf_cursor_info_set(en);
2969 _anchors_get(en->cursor, rp->object, en); 2970 _anchors_get(en->cursor, rp->object, en);
2970 _edje_emit(rp->edje, "entry,changed", rp->part->name); 2971 _edje_emit(rp->edje, "entry,changed", rp->part->name);
2971 _edje_emit(ed, "entry,changed,user", rp->part->name);
2972 _edje_emit(ed, "cursor,changed", rp->part->name);
2973 2972
2974 return ECORE_CALLBACK_DONE; 2973 {
2974 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
2975 info->insert = EINA_TRUE;
2976 info->change.insert.pos = start_pos;
2977 info->change.insert.content = eina_stringshare_add(commit_str);
2978 info->change.insert.plain_length =
2979 eina_unicode_utf8_get_len(info->change.insert.content);
2980 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
2981 info, _free_entry_change_info);
2982 _edje_emit(ed, "cursor,changed", rp->part->name);
2983 }
2975} 2984}
2976 2985
2977static Eina_Bool 2986static void
2978_edje_entry_imf_event_preedit_changed_cb(void *data, int type __UNUSED__, void *event) 2987_edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info __UNUSED__)
2979{ 2988{
2980 Edje *ed = data; 2989 Edje *ed = data;
2981 Edje_Real_Part *rp = ed->focused_part; 2990 Edje_Real_Part *rp = ed->focused_part;
2982 Entry *en; 2991 Entry *en;
2983 Ecore_IMF_Event_Preedit_Changed *ev = event;
2984 int cursor_pos; 2992 int cursor_pos;
2985 int preedit_start_pos, preedit_end_pos; 2993 int preedit_start_pos, preedit_end_pos;
2986 char *preedit_string; 2994 char *preedit_string;
2987 int i; 2995 int i;
2988 Eina_Bool preedit_end_state = EINA_FALSE; 2996 Eina_Bool preedit_end_state = EINA_FALSE;
2997 Eina_List *attrs = NULL, *l = NULL;
2998 Ecore_IMF_Preedit_Attr *attr;
2999 Eina_Strbuf *buf;
2989 3000
2990 if ((!rp) || (!ev)) return ECORE_CALLBACK_PASS_ON; 3001 if ((!rp)) return;
2991 3002
2992 en = rp->entry_data; 3003 en = rp->entry_data;
2993 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || 3004 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2994 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) 3005 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2995 return ECORE_CALLBACK_PASS_ON; 3006 return;
2996
2997 if (!en->imf_context) return ECORE_CALLBACK_PASS_ON;
2998 3007
2999 if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON; 3008 if (!en->imf_context) return;
3000 3009
3001 ecore_imf_context_preedit_string_get(en->imf_context, &preedit_string, &cursor_pos); 3010 ecore_imf_context_preedit_string_with_attributes_get(en->imf_context,
3002 if (!preedit_string) return ECORE_CALLBACK_PASS_ON; 3011 &preedit_string,
3012 &attrs, &cursor_pos);
3013 if (!preedit_string) return;
3003 3014
3004 if (!strcmp(preedit_string, "")) 3015 if (!strcmp(preedit_string, ""))
3005 preedit_end_state = EINA_TRUE; 3016 preedit_end_state = EINA_TRUE;
@@ -3007,7 +3018,7 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, int type __UNUSED__, void *
3007 if (en->have_selection && !preedit_end_state) 3018 if (en->have_selection && !preedit_end_state)
3008 { 3019 {
3009 /* delete selected characters */ 3020 /* delete selected characters */
3010 _range_del(en->cursor, rp->object, en); 3021 _range_del_emit(ed, en->cursor, rp->object, en);
3011 _sel_clear(en->cursor, rp->object, en); 3022 _sel_clear(en->cursor, rp->object, en);
3012 } 3023 }
3013 3024
@@ -3017,23 +3028,51 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, int type __UNUSED__, void *
3017 preedit_start_pos = evas_textblock_cursor_pos_get(en->cursor); 3028 preedit_start_pos = evas_textblock_cursor_pos_get(en->cursor);
3018 3029
3019 /* insert preedit character(s) */ 3030 /* insert preedit character(s) */
3020 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) && 3031 if (strlen(preedit_string) > 0)
3021 _edje_password_show_last)
3022 { 3032 {
3023 _text_filter_format_prepend(en, en->cursor, "+ password=off"); 3033 buf = eina_strbuf_new();
3024 _text_filter_markup_prepend(en, en->cursor, preedit_string); 3034 if (attrs)
3025 _text_filter_format_prepend(en, en->cursor, "- password");
3026 if (en->pw_timer)
3027 { 3035 {
3028 ecore_timer_del(en->pw_timer); 3036 EINA_LIST_FOREACH(attrs, l, attr)
3029 en->pw_timer = NULL; 3037 {
3038 if (attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB1)
3039 {
3040 eina_strbuf_append(buf, "<preedit>");
3041 eina_strbuf_append_n(buf, preedit_string + attr->start_index,
3042 attr->end_index - attr->start_index);
3043 eina_strbuf_append(buf, "</preedit>");
3044 }
3045
3046 else if (attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB2 ||
3047 attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3)
3048 {
3049 eina_strbuf_append(buf, "<preedit_sel>");
3050 eina_strbuf_append_n(buf, preedit_string + attr->start_index,
3051 attr->end_index - attr->start_index);
3052 eina_strbuf_append(buf, "</preedit_sel>");
3053 }
3054 }
3030 } 3055 }
3031 en->pw_timer = ecore_timer_add(_edje_password_show_last_timeout, 3056 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
3032 _password_timer_cb, en); 3057 _edje_password_show_last)
3033 } 3058 {
3034 else 3059 _edje_entry_hide_visible_password(en->rp);
3035 { 3060 _text_filter_format_prepend(en, en->cursor, "+ password=off");
3036 _text_filter_markup_prepend(en, en->cursor, preedit_string); 3061 _text_filter_markup_prepend(en, en->cursor, eina_strbuf_string_get(buf));
3062 _text_filter_format_prepend(en, en->cursor, "- password");
3063 if (en->pw_timer)
3064 {
3065 ecore_timer_del(en->pw_timer);
3066 en->pw_timer = NULL;
3067 }
3068 en->pw_timer = ecore_timer_add(_edje_password_show_last_timeout,
3069 _password_timer_cb, en);
3070 }
3071 else
3072 {
3073 _text_filter_markup_prepend(en, en->cursor, eina_strbuf_string_get(buf));
3074 }
3075 eina_strbuf_free(buf);
3037 } 3076 }
3038 3077
3039 if (!preedit_end_state) 3078 if (!preedit_end_state)
@@ -3066,29 +3105,30 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, int type __UNUSED__, void *
3066 _edje_emit(rp->edje, "preedit,changed", rp->part->name); 3105 _edje_emit(rp->edje, "preedit,changed", rp->part->name);
3067 _edje_emit(ed, "cursor,changed", rp->part->name); 3106 _edje_emit(ed, "cursor,changed", rp->part->name);
3068 3107
3069 free(preedit_string); 3108 /* delete attribute list */
3109 if (attrs)
3110 {
3111 EINA_LIST_FREE(attrs, attr) free(attr);
3112 }
3070 3113
3071 return ECORE_CALLBACK_DONE; 3114 free(preedit_string);
3072} 3115}
3073 3116
3074static Eina_Bool 3117static void
3075_edje_entry_imf_event_delete_surrounding_cb(void *data, int type __UNUSED__, void *event) 3118_edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info)
3076{ 3119{
3077 Edje *ed = data; 3120 Edje *ed = data;
3078 Edje_Real_Part *rp = ed->focused_part; 3121 Edje_Real_Part *rp = ed->focused_part;
3079 Entry *en; 3122 Entry *en;
3080 Ecore_IMF_Event_Delete_Surrounding *ev = event; 3123 Ecore_IMF_Event_Delete_Surrounding *ev = event_info;
3081 Evas_Textblock_Cursor *del_start, *del_end; 3124 Evas_Textblock_Cursor *del_start, *del_end;
3082 int cursor_pos; 3125 int cursor_pos;
3083 3126
3084 if ((!rp) || (!ev)) return ECORE_CALLBACK_PASS_ON; 3127 if ((!rp) || (!ev)) return;
3085 en = rp->entry_data; 3128 en = rp->entry_data;
3086 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || 3129 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
3087 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) 3130 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
3088 return ECORE_CALLBACK_PASS_ON; 3131 return;
3089
3090 if (!en->imf_context) return ECORE_CALLBACK_PASS_ON;
3091 if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON;
3092 3132
3093 cursor_pos = evas_textblock_cursor_pos_get(en->cursor); 3133 cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
3094 3134
@@ -3102,8 +3142,6 @@ _edje_entry_imf_event_delete_surrounding_cb(void *data, int type __UNUSED__, voi
3102 3142
3103 evas_textblock_cursor_free(del_start); 3143 evas_textblock_cursor_free(del_start);
3104 evas_textblock_cursor_free(del_end); 3144 evas_textblock_cursor_free(del_end);
3105
3106 return ECORE_CALLBACK_DONE;
3107} 3145}
3108#endif 3146#endif
3109 3147