summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2011-10-03 12:30:40 +0000
committerTom Hacohen <tom@stosb.com>2011-10-03 12:30:40 +0000
commit27292485669949d0080b1185f5323fa40ae2dd89 (patch)
tree3f9c921c99c06648b180149510843b534fb4ad34 /legacy
parent2477b1a048ecf33858deb69983147aa331412bef (diff)
Edje entry: Emit signals on range del and add info to changed,user.
Info added includes: cursor position of the action, content related to the action, and the action that happened (added/removed). Also fixed tab insertion to delete the current selection. SVN revision: 63773
Diffstat (limited to 'legacy')
-rw-r--r--legacy/edje/ChangeLog4
-rw-r--r--legacy/edje/src/lib/Edje.h23
-rw-r--r--legacy/edje/src/lib/edje_entry.c144
3 files changed, 147 insertions, 24 deletions
diff --git a/legacy/edje/ChangeLog b/legacy/edje/ChangeLog
index 816810b775..18bdf0ea24 100644
--- a/legacy/edje/ChangeLog
+++ b/legacy/edje/ChangeLog
@@ -171,3 +171,7 @@
1712011-10-02 Boris Faure (billiob) 1712011-10-02 Boris Faure (billiob)
172 172
173 * Fix edje_cc to accept -1 in description.max 173 * Fix edje_cc to accept -1 in description.max
174
1752011-10-03 Tom Hacohen (TAsn)
176
177 * Entry: Added change information to entry,changed,user
diff --git a/legacy/edje/src/lib/Edje.h b/legacy/edje/src/lib/Edje.h
index 84c1427c72..e7b0451e0e 100644
--- a/legacy/edje/src/lib/Edje.h
+++ b/legacy/edje/src/lib/Edje.h
@@ -646,6 +646,29 @@ typedef enum _Edje_Cursor
646 // more later 646 // more later
647} Edje_Cursor; 647} Edje_Cursor;
648 648
649struct _Edje_Entry_Change_Info
650{
651 union {
652 struct {
653 const char *content;
654 size_t pos;
655 size_t plain_length; /* Number of cursor positions represented
656 in content. */
657 } insert;
658 struct {
659 const char *content;
660 size_t start, end;
661 } del;
662 } change;
663 Eina_Bool insert : 1; /**< True if the "change" union's "insert" is valid */
664 Eina_Bool merge : 1; /**< True if can be merged with the previous one. Used for example with insertion when something is already selected. */
665};
666
667/**
668 * @since 1.1.0
669 */
670typedef struct _Edje_Entry_Change_Info Edje_Entry_Change_Info;
671
649typedef struct _Edje_Message_String Edje_Message_String; 672typedef struct _Edje_Message_String Edje_Message_String;
650typedef struct _Edje_Message_Int Edje_Message_Int; 673typedef struct _Edje_Message_Int Edje_Message_Int;
651typedef struct _Edje_Message_Float Edje_Message_Float; 674typedef struct _Edje_Message_Float Edje_Message_Float;
diff --git a/legacy/edje/src/lib/edje_entry.c b/legacy/edje/src/lib/edje_entry.c
index 0cf5739d31..d64280837b 100644
--- a/legacy/edje/src/lib/edje_entry.c
+++ b/legacy/edje/src/lib/edje_entry.c
@@ -982,6 +982,41 @@ _anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
982 } 982 }
983} 983}
984 984
985static void
986_free_entry_change_info(void *_info)
987{
988 Edje_Entry_Change_Info *info = (Edje_Entry_Change_Info *) _info;
989 if (info->insert)
990 {
991 eina_stringshare_del(info->change.insert.content);
992 }
993 else
994 {
995 eina_stringshare_del(info->change.del.content);
996 }
997 free(info);
998}
999
1000static void
1001_range_del_emit(Edje *ed, Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
1002{
1003 size_t start, end;
1004 char *tmp;
1005 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1006 info->insert = EINA_FALSE;
1007 start = evas_textblock_cursor_pos_get(en->sel_start);
1008 end = evas_textblock_cursor_pos_get(en->sel_end);
1009 info->change.del.start = start;
1010 info->change.del.end = end;
1011
1012 tmp = evas_textblock_cursor_range_text_get(en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
1013 info->change.del.content = eina_stringshare_add(tmp);
1014 if (tmp) free(tmp);
1015 evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
1016 _edje_emit(ed, "entry,changed", en->rp->part->name);
1017 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name, info,
1018 _free_entry_change_info);
1019}
985 1020
986static void 1021static void
987_range_del(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en) 1022_range_del(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
@@ -989,22 +1024,38 @@ _range_del(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry
989 evas_textblock_cursor_range_delete(en->sel_start, en->sel_end); 1024 evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
990} 1025}
991 1026
992/* Return true if changed something */ 1027static void
993static Eina_Bool 1028_delete_emit(Edje *ed, Evas_Textblock_Cursor *c, Entry *en, size_t pos,
994_backspace(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en __UNUSED__) 1029 Eina_Bool backspace)
995{ 1030{
996 if (evas_textblock_cursor_char_prev(c)) 1031 if (!evas_textblock_cursor_char_next(c))
997 { 1032 {
998 evas_textblock_cursor_char_delete(c); 1033 return;
999 return EINA_TRUE;
1000 } 1034 }
1001 return EINA_FALSE; 1035 evas_textblock_cursor_char_prev(c);
1002} 1036
1037 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1038 char *tmp = evas_textblock_cursor_content_get(c);
1039
1040 info->insert = EINA_FALSE;
1041 if (backspace)
1042 {
1043 info->change.del.start = pos - 1;
1044 info->change.del.end = pos;
1045 }
1046 else
1047 {
1048 info->change.del.start = pos + 1;
1049 info->change.del.end = pos;
1050 }
1051
1052 info->change.del.content = eina_stringshare_add(tmp);
1053 if (tmp) free(tmp);
1003 1054
1004static void
1005_delete(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en __UNUSED__)
1006{
1007 evas_textblock_cursor_char_delete(c); 1055 evas_textblock_cursor_char_delete(c);
1056 _edje_emit(ed, "entry,changed", en->rp->part->name);
1057 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name,
1058 info, _free_entry_change_info);
1008} 1059}
1009 1060
1010static void 1061static void
@@ -1097,6 +1148,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1097 } 1148 }
1098 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1149 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1099 } 1150 }
1151 _sel_clear(en->cursor, rp->object, en);
1100 _edje_emit(ed, "entry,key,up", rp->part->name); 1152 _edje_emit(ed, "entry,key,up", rp->part->name);
1101 } 1153 }
1102 else if (!strcmp(ev->key, "Down") || !strcmp(ev->key, "KP_Down")) 1154 else if (!strcmp(ev->key, "Down") || !strcmp(ev->key, "KP_Down"))
@@ -1115,6 +1167,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1115 } 1167 }
1116 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1168 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1117 } 1169 }
1170 _sel_clear(en->cursor, rp->object, en);
1118 _edje_emit(ed, "entry,key,down", rp->part->name); 1171 _edje_emit(ed, "entry,key,down", rp->part->name);
1119 } 1172 }
1120 else if (!strcmp(ev->key, "Left") || !strcmp(ev->key, "KP_Left")) 1173 else if (!strcmp(ev->key, "Left") || !strcmp(ev->key, "KP_Left"))
@@ -1129,6 +1182,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1129 { 1182 {
1130 if (shift) _sel_extend(en->cursor, rp->object, en); 1183 if (shift) _sel_extend(en->cursor, rp->object, en);
1131 } 1184 }
1185 _sel_clear(en->cursor, rp->object, en);
1132 _edje_emit(ed, "entry,key,left", rp->part->name); 1186 _edje_emit(ed, "entry,key,left", rp->part->name);
1133 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1187 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1134 } 1188 }
@@ -1144,6 +1198,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1144 { 1198 {
1145 if (shift) _sel_extend(en->cursor, rp->object, en); 1199 if (shift) _sel_extend(en->cursor, rp->object, en);
1146 } 1200 }
1201 _sel_clear(en->cursor, rp->object, en);
1147 _edje_emit(ed, "entry,key,right", rp->part->name); 1202 _edje_emit(ed, "entry,key,right", rp->part->name);
1148 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1203 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1149 } 1204 }
@@ -1161,14 +1216,13 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1161 { 1216 {
1162 if (en->have_selection) 1217 if (en->have_selection)
1163 { 1218 {
1164 _range_del(en->cursor, rp->object, en); 1219 _range_del_emit(ed, en->cursor, rp->object, en);
1165 } 1220 }
1166 else 1221 else
1167 { 1222 {
1168 if (_backspace(en->cursor, rp->object, en)) 1223 if (evas_textblock_cursor_char_prev(en->cursor))
1169 { 1224 {
1170 _edje_emit(ed, "entry,changed", rp->part->name); 1225 _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_TRUE);
1171 _edje_emit(ed, "entry,changed,user", rp->part->name);
1172 } 1226 }
1173 } 1227 }
1174 } 1228 }
@@ -1190,14 +1244,16 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1190 else 1244 else
1191 { 1245 {
1192 if (en->have_selection) 1246 if (en->have_selection)
1193 _range_del(en->cursor, rp->object, en); 1247 {
1248 _range_del_emit(ed, en->cursor, rp->object, en);
1249 }
1194 else 1250 else
1195 _delete(en->cursor, rp->object, en); 1251 {
1252 _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_FALSE);
1253 }
1196 } 1254 }
1197 _sel_clear(en->cursor, rp->object, en); 1255 _sel_clear(en->cursor, rp->object, en);
1198 _anchors_get(en->cursor, rp->object, en); 1256 _anchors_get(en->cursor, rp->object, en);
1199 _edje_emit(ed, "entry,changed", rp->part->name);
1200 _edje_emit(ed, "entry,changed,user", rp->part->name);
1201 _edje_emit(ed, "entry,key,delete", rp->part->name); 1257 _edje_emit(ed, "entry,key,delete", rp->part->name);
1202 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1258 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1203 } 1259 }
@@ -1305,12 +1361,26 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1305 } 1361 }
1306 else 1362 else
1307 { 1363 {
1364 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1365 info->insert = EINA_TRUE;
1366 info->change.insert.plain_length = 1;
1367
1368 if (en->have_selection)
1369 {
1370 _range_del_emit(ed, en->cursor, rp->object, en);
1371 info->merge = EINA_TRUE;
1372 }
1373 _sel_clear(en->cursor, rp->object, en);
1374 info->change.insert.pos =
1375 evas_textblock_cursor_pos_get(en->cursor);
1376 info->change.insert.content = eina_stringshare_add("<\t>");
1308 //yy 1377 //yy
1309// evas_textblock_cursor_format_prepend(en->cursor, "\t"); 1378// evas_textblock_cursor_format_prepend(en->cursor, "\t");
1310 _text_filter_format_prepend(en, en->cursor, "\t"); 1379 _text_filter_format_prepend(en, en->cursor, "\t");
1311 _anchors_get(en->cursor, rp->object, en); 1380 _anchors_get(en->cursor, rp->object, en);
1312 _edje_emit(ed, "entry,changed", rp->part->name); 1381 _edje_emit(ed, "entry,changed", rp->part->name);
1313 _edje_emit(ed, "entry,changed,user", rp->part->name); 1382 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1383 info, _free_entry_change_info);
1314 } 1384 }
1315 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1385 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1316 } 1386 }
@@ -1333,6 +1403,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1333 { 1403 {
1334 if (shift) _sel_extend(en->cursor, rp->object, en); 1404 if (shift) _sel_extend(en->cursor, rp->object, en);
1335 } 1405 }
1406 _sel_clear(en->cursor, rp->object, en);
1336 _edje_emit(ed, "entry,key,pgup", rp->part->name); 1407 _edje_emit(ed, "entry,key,pgup", rp->part->name);
1337 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1408 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1338 } 1409 }
@@ -1348,6 +1419,7 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1348 { 1419 {
1349 if (shift) _sel_extend(en->cursor, rp->object, en); 1420 if (shift) _sel_extend(en->cursor, rp->object, en);
1350 } 1421 }
1422 _sel_clear(en->cursor, rp->object, en);
1351 _edje_emit(ed, "entry,key,pgdn", rp->part->name); 1423 _edje_emit(ed, "entry,key,pgdn", rp->part->name);
1352 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1424 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1353 } 1425 }
@@ -1355,24 +1427,36 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1355 { 1427 {
1356 if (multiline) 1428 if (multiline)
1357 { 1429 {
1430 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1431 info->insert = EINA_TRUE;
1432 info->change.insert.plain_length = 1;
1358 if (en->have_selection) 1433 if (en->have_selection)
1359 _range_del(en->cursor, rp->object, en); 1434 {
1435 _range_del_emit(ed, en->cursor, rp->object, en);
1436 info->merge = EINA_TRUE;
1437 }
1360 _sel_clear(en->cursor, rp->object, en); 1438 _sel_clear(en->cursor, rp->object, en);
1439
1440 info->change.insert.pos =
1441 evas_textblock_cursor_pos_get(en->cursor);
1361 if (shift) 1442 if (shift)
1362 { 1443 {
1363 //yy 1444 //yy
1364// evas_textblock_cursor_format_prepend(en->cursor, "\n"); 1445// evas_textblock_cursor_format_prepend(en->cursor, "\n");
1365 _text_filter_format_prepend(en, en->cursor, "\n"); 1446 _text_filter_format_prepend(en, en->cursor, "\n");
1447 info->change.insert.content = eina_stringshare_add("<\n>");
1366 } 1448 }
1367 else 1449 else
1368 { 1450 {
1369 //yy 1451 //yy
1370// evas_textblock_cursor_format_prepend(en->cursor, "ps"); 1452// evas_textblock_cursor_format_prepend(en->cursor, "ps");
1371 _text_filter_format_prepend(en, en->cursor, "ps"); 1453 _text_filter_format_prepend(en, en->cursor, "ps");
1454 info->change.insert.content = eina_stringshare_add("<ps>");
1372 } 1455 }
1373 _anchors_get(en->cursor, rp->object, en); 1456 _anchors_get(en->cursor, rp->object, en);
1374 _edje_emit(ed, "entry,changed", rp->part->name); 1457 _edje_emit(ed, "entry,changed", rp->part->name);
1375 _edje_emit(ed, "entry,changed,user", rp->part->name); 1458 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1459 info, _free_entry_change_info);
1376 _edje_emit(ed, "cursor,changed", rp->part->name); 1460 _edje_emit(ed, "cursor,changed", rp->part->name);
1377 cursor_changed = EINA_TRUE; 1461 cursor_changed = EINA_TRUE;
1378 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1462 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
@@ -1383,9 +1467,20 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1383 { 1467 {
1384 if (ev->string) 1468 if (ev->string)
1385 { 1469 {
1470 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1471 info->insert = EINA_TRUE;
1472 info->change.insert.plain_length = 1;
1473 info->change.insert.content = eina_stringshare_add(ev->string);
1474
1386 if (en->have_selection) 1475 if (en->have_selection)
1387 _range_del(en->cursor, rp->object, en); 1476 {
1477 _range_del_emit(ed, en->cursor, rp->object, en);
1478 info->merge = EINA_TRUE;
1479 }
1388 _sel_clear(en->cursor, rp->object, en); 1480 _sel_clear(en->cursor, rp->object, en);
1481
1482 info->change.insert.pos =
1483 evas_textblock_cursor_pos_get(en->cursor);
1389 // if PASSWORD_SHOW_LAST mode, appending text with password=off tag 1484 // if PASSWORD_SHOW_LAST mode, appending text with password=off tag
1390 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) && 1485 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
1391 _edje_password_show_last) 1486 _edje_password_show_last)
@@ -1406,7 +1501,8 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
1406 _text_filter_text_prepend(en, en->cursor, ev->string); 1501 _text_filter_text_prepend(en, en->cursor, ev->string);
1407 _anchors_get(en->cursor, rp->object, en); 1502 _anchors_get(en->cursor, rp->object, en);
1408 _edje_emit(ed, "entry,changed", rp->part->name); 1503 _edje_emit(ed, "entry,changed", rp->part->name);
1409 _edje_emit(ed, "entry,changed,user", rp->part->name); 1504 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1505 info, _free_entry_change_info);
1410 _edje_emit(ed, "cursor,changed", rp->part->name); 1506 _edje_emit(ed, "cursor,changed", rp->part->name);
1411 cursor_changed = EINA_TRUE; 1507 cursor_changed = EINA_TRUE;
1412 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1508 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;