summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Edje.am2
-rw-r--r--src/lib/edje/edje_legacy.c64
-rw-r--r--src/tests/edje/data/test_text_cursor.edc22
-rw-r--r--src/tests/edje/edje_test_edje.c81
4 files changed, 157 insertions, 12 deletions
diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am
index 1179d5e..87d67b5 100644
--- a/src/Makefile_Edje.am
+++ b/src/Makefile_Edje.am
@@ -299,6 +299,7 @@ tests/edje/data/test_combine_keywords.edc \
299tests/edje/data/test_messages.edc \ 299tests/edje/data/test_messages.edc \
300tests/edje/data/test_signals.edc \ 300tests/edje/data/test_signals.edc \
301tests/edje/data/test_signal_callback_del_full.edc \ 301tests/edje/data/test_signal_callback_del_full.edc \
302tests/edje/data/test_text_cursor.edc \
302tests/edje/data/filter.lua 303tests/edje/data/filter.lua
303 304
304 305
@@ -342,6 +343,7 @@ EDJE_TEST_FILES = tests/edje/data/test_layout.edj \
342 tests/edje/data/test_messages.edj \ 343 tests/edje/data/test_messages.edj \
343 tests/edje/data/test_signals.edj \ 344 tests/edje/data/test_signals.edj \
344 tests/edje/data/test_signal_callback_del_full.edj \ 345 tests/edje/data/test_signal_callback_del_full.edj \
346 tests/edje/data/test_text_cursor.edj \
345 $(NULL) 347 $(NULL)
346 348
347CLEANFILES += $(EDJE_TEST_FILES) 349CLEANFILES += $(EDJE_TEST_FILES)
diff --git a/src/lib/edje/edje_legacy.c b/src/lib/edje/edje_legacy.c
index 3549eee..a0c5174 100644
--- a/src/lib/edje/edje_legacy.c
+++ b/src/lib/edje/edje_legacy.c
@@ -325,33 +325,73 @@ edje_object_part_text_cursor_line_end_set(Edje_Object *obj, const char *part, Ed
325EAPI Eina_Bool 325EAPI Eina_Bool
326edje_object_part_text_cursor_prev(Edje_Object *obj, const char *part, Edje_Cursor cur) 326edje_object_part_text_cursor_prev(Edje_Object *obj, const char *part, Edje_Cursor cur)
327{ 327{
328 efl_text_cursor_char_prev(efl_part(obj, part), 328 Efl_Text_Cursor_Cursor *c;
329 efl_text_cursor_get(efl_part(obj, part), (int) cur)); 329 int old_pos, new_pos;
330 return EINA_TRUE; 330
331 c = efl_text_cursor_get(efl_part(obj, part), (int) cur);
332
333 old_pos = efl_text_cursor_position_get(efl_part(obj, part), c);
334 efl_text_cursor_char_prev(efl_part(obj, part), c);
335 new_pos = efl_text_cursor_position_get(efl_part(obj, part), c);
336
337 if (old_pos != new_pos)
338 return EINA_TRUE;
339
340 return EINA_FALSE;
331} 341}
332 342
333EAPI Eina_Bool 343EAPI Eina_Bool
334edje_object_part_text_cursor_next(Edje_Object *obj, const char *part, Edje_Cursor cur) 344edje_object_part_text_cursor_next(Edje_Object *obj, const char *part, Edje_Cursor cur)
335{ 345{
336 efl_text_cursor_char_next(efl_part(obj, part), 346 Efl_Text_Cursor_Cursor *c;
337 efl_text_cursor_get(efl_part(obj, part), (int) cur)); 347 int old_pos, new_pos;
338 return EINA_TRUE; 348
349 c = efl_text_cursor_get(efl_part(obj, part), (int) cur);
350
351 old_pos = efl_text_cursor_position_get(efl_part(obj, part), c);
352 efl_text_cursor_char_next(efl_part(obj, part), c);
353 new_pos = efl_text_cursor_position_get(efl_part(obj, part), c);
354
355 if (old_pos != new_pos)
356 return EINA_TRUE;
357
358 return EINA_FALSE;
339} 359}
340 360
341EAPI Eina_Bool 361EAPI Eina_Bool
342edje_object_part_text_cursor_down(Edje_Object *obj, const char *part, Edje_Cursor cur) 362edje_object_part_text_cursor_down(Edje_Object *obj, const char *part, Edje_Cursor cur)
343{ 363{
344 efl_text_cursor_line_jump_by(efl_part(obj, part), 364 Efl_Text_Cursor_Cursor *c;
345 efl_text_cursor_get(efl_part(obj, part), (int) cur), 1); 365 int old_pos, new_pos;
346 return EINA_TRUE; 366
367 c = efl_text_cursor_get(efl_part(obj, part), (int) cur);
368
369 old_pos = efl_text_cursor_position_get(efl_part(obj, part), c);
370 efl_text_cursor_line_jump_by(efl_part(obj, part), c, 1);
371 new_pos = efl_text_cursor_position_get(efl_part(obj, part), c);
372
373 if (old_pos != new_pos)
374 return EINA_TRUE;
375
376 return EINA_FALSE;
347} 377}
348 378
349EAPI Eina_Bool 379EAPI Eina_Bool
350edje_object_part_text_cursor_up(Edje_Object *obj, const char *part, Edje_Cursor cur) 380edje_object_part_text_cursor_up(Edje_Object *obj, const char *part, Edje_Cursor cur)
351{ 381{
352 efl_text_cursor_line_jump_by(efl_part(obj, part), 382 Efl_Text_Cursor_Cursor *c;
353 efl_text_cursor_get(efl_part(obj, part), (int) cur), -1); 383 int old_pos, new_pos;
354 return EINA_TRUE; 384
385 c = efl_text_cursor_get(efl_part(obj, part), (int) cur);
386
387 old_pos = efl_text_cursor_position_get(efl_part(obj, part), c);
388 efl_text_cursor_line_jump_by(efl_part(obj, part), c, -1);
389 new_pos = efl_text_cursor_position_get(efl_part(obj, part), c);
390
391 if (old_pos != new_pos)
392 return EINA_TRUE;
393
394 return EINA_FALSE;
355} 395}
356 396
357EAPI void 397EAPI void
diff --git a/src/tests/edje/data/test_text_cursor.edc b/src/tests/edje/data/test_text_cursor.edc
new file mode 100644
index 0000000..7392e54
--- /dev/null
+++ b/src/tests/edje/data/test_text_cursor.edc
@@ -0,0 +1,22 @@
1collections {
2 styles {
3 style { name: "tb_style";
4 base: "font=Sans font_size=20 color=#fff";
5 }
6 }
7 group { name: "test_text_cursor";
8 parts {
9 part { name: "text";
10 type: TEXTBLOCK;
11 entry_mode: EDITABLE;
12 cursor_mode: BEFORE;
13 description { state: "default" 0.0;
14 min: 300 300;
15 text {
16 style: "tb_style";
17 }
18 }
19 }
20 }
21 }
22}
diff --git a/src/tests/edje/edje_test_edje.c b/src/tests/edje/edje_test_edje.c
index 11f1df6..6ce93a4 100644
--- a/src/tests/edje/edje_test_edje.c
+++ b/src/tests/edje/edje_test_edje.c
@@ -943,6 +943,86 @@ EFL_START_TEST(edje_test_signal_callback_del_full)
943} 943}
944EFL_END_TEST 944EFL_END_TEST
945 945
946EFL_START_TEST(edje_test_text_cursor)
947{
948 Evas *evas;
949 Evas_Object *obj;
950 const char *buf = "ABC<br/>DEF";
951 const char *txt;
952 int i, old_pos, new_pos;
953
954 evas = EDJE_TEST_INIT_EVAS();
955
956 obj = edje_object_add(evas);
957 fail_unless(edje_object_file_set(obj, test_layout_get("test_text_cursor.edj"), "test_text_cursor"));
958 edje_object_part_text_set(obj, "text", buf);
959 txt = edje_object_part_text_get(obj, "text");
960 fail_if(!txt || strcmp(txt, buf));
961
962 edje_object_part_text_cursor_pos_set(obj, "text", EDJE_CURSOR_MAIN, 0);
963 ck_assert_int_eq(edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN), 0);
964 edje_object_part_text_cursor_pos_set(obj, "text", EDJE_CURSOR_MAIN, 1);
965 ck_assert_int_eq(edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN), 1);
966
967 /* Move cursor to the 0 pos from 1 pos */
968 old_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
969 ck_assert(edje_object_part_text_cursor_prev(obj, "text", EDJE_CURSOR_MAIN));
970 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
971 ck_assert_int_ne(old_pos, new_pos);
972
973 /* Move cursor to the -1 pos from 0 pos. It has to fail. */
974 old_pos = new_pos;
975 ck_assert(!edje_object_part_text_cursor_prev(obj, "text", EDJE_CURSOR_MAIN));
976 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
977 ck_assert_int_eq(old_pos, new_pos);
978
979 /* Jump to 2nd line from 1st line.
980 * It has to return EINA_TRUE which means success. */
981 old_pos = new_pos;
982 ck_assert(edje_object_part_text_cursor_down(obj, "text", EDJE_CURSOR_MAIN));
983 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
984 ck_assert_int_ne(old_pos, new_pos);
985
986 /* Try to jump to 3rd line from 2nd line. But, 3rd line does not exist.
987 * So, it has to return EINA_FALSE which means failure. */
988 old_pos = new_pos;
989 ck_assert(!edje_object_part_text_cursor_down(obj, "text", EDJE_CURSOR_MAIN));
990 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
991 ck_assert_int_eq(old_pos, new_pos);
992
993 /* Move cursor to the end of 2nd line. */
994 for (i = 0; i < 3; i++)
995 {
996 old_pos = new_pos;
997 ck_assert(edje_object_part_text_cursor_next(obj, "text", EDJE_CURSOR_MAIN));
998 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
999 ck_assert_int_ne(old_pos, new_pos);
1000 }
1001
1002 /* Move cursor to the next of the end of 2nd line which does not exist. */
1003 old_pos = new_pos;
1004 ck_assert(!edje_object_part_text_cursor_next(obj, "text", EDJE_CURSOR_MAIN));
1005 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1006 ck_assert_int_eq(old_pos, new_pos);
1007
1008 /* Jump to 1st line from 2nd line.
1009 * It has to return EINA_TRUE which means success. */
1010 old_pos = new_pos;
1011 ck_assert(edje_object_part_text_cursor_up(obj, "text", EDJE_CURSOR_MAIN));
1012 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1013 ck_assert_int_ne(old_pos, new_pos);
1014
1015 /* Try to jump to the above of 1st line from 1st line. But, there is no such line.
1016 * So, it has to return EINA_FALSE which means failure. */
1017 old_pos = new_pos;
1018 ck_assert(!edje_object_part_text_cursor_up(obj, "text", EDJE_CURSOR_MAIN));
1019 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1020 ck_assert_int_eq(old_pos, new_pos);
1021
1022 EDJE_TEST_FREE_EVAS();
1023}
1024EFL_END_TEST
1025
946void edje_test_edje(TCase *tc) 1026void edje_test_edje(TCase *tc)
947{ 1027{
948 tcase_add_test(tc, edje_test_edje_init); 1028 tcase_add_test(tc, edje_test_edje_init);
@@ -968,4 +1048,5 @@ void edje_test_edje(TCase *tc)
968 tcase_add_test(tc, edje_test_message_send_eo); 1048 tcase_add_test(tc, edje_test_message_send_eo);
969 tcase_add_test(tc, edje_test_signals); 1049 tcase_add_test(tc, edje_test_signals);
970 tcase_add_test(tc, edje_test_signal_callback_del_full); 1050 tcase_add_test(tc, edje_test_signal_callback_del_full);
1051 tcase_add_test(tc, edje_test_text_cursor);
971} 1052}