2013-02-25 06:58:22 -08:00
/*
* TODO :
evas_object_textblock: add support for variation sequences
Summary: update font processing to handle variation sequences unicodes to select proper glypg in respect to variation seqences
Test Plan:
```
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
#include <Efl.h>
#include <Elementary.h>
EAPI_MAIN int
elm_main(int argc, char **argv)
{
Evas_Object *win, *textblock;
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_util_standard_add("Main", "");
elm_win_autodel_set(win, EINA_TRUE);
textblock = evas_object_textblock_add(win);
efl_canvas_text_style_set(textblock,NULL,"DEFAULT='font=DejaVuSans font_fallbacks=SamsungColorEmoji color=#000 font_size=20'");
evas_object_textblock_text_markup_set(textblock, "8️⃣☪️AAA☪︎1234567️⃣");
evas_object_size_hint_weight_set(textblock, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(textblock, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(textblock);
evas_object_move(textblock, 0, 0);
evas_object_resize(textblock, 320, 320);
evas_object_resize(win, 320, 320);
evas_object_show(win);
elm_run();
return 0;
}
ELM_MAIN()
```
Reviewers: woohyun, bowonryu, segfaultxavi, cedric, bu5hm4n
Reviewed By: woohyun, cedric
Subscribers: raster, bu5hm4n, subodh6129, herdsman, segfaultxavi, zmike, cedric, #committers, #reviewers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D9053
2019-12-11 23:22:12 -08:00
* * Test different font loading mechanisms .
2013-02-25 06:58:22 -08:00
*/
2012-11-14 12:12:53 -08:00
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include <stdio.h>
2016-02-04 06:11:52 -08:00
# include <locale.h>
2012-11-14 12:12:53 -08:00
# include <Eina.h>
2016-02-04 06:11:52 -08:00
# include <Evas.h>
2012-11-14 12:12:53 -08:00
# include "evas_suite.h"
# include "evas_tests_helpers.h"
evas_object_textblock: add support for variation sequences
Summary: update font processing to handle variation sequences unicodes to select proper glypg in respect to variation seqences
Test Plan:
```
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
#include <Efl.h>
#include <Elementary.h>
EAPI_MAIN int
elm_main(int argc, char **argv)
{
Evas_Object *win, *textblock;
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_util_standard_add("Main", "");
elm_win_autodel_set(win, EINA_TRUE);
textblock = evas_object_textblock_add(win);
efl_canvas_text_style_set(textblock,NULL,"DEFAULT='font=DejaVuSans font_fallbacks=SamsungColorEmoji color=#000 font_size=20'");
evas_object_textblock_text_markup_set(textblock, "8️⃣☪️AAA☪︎1234567️⃣");
evas_object_size_hint_weight_set(textblock, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(textblock, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(textblock);
evas_object_move(textblock, 0, 0);
evas_object_resize(textblock, 320, 320);
evas_object_resize(win, 320, 320);
evas_object_show(win);
elm_run();
return 0;
}
ELM_MAIN()
```
Reviewers: woohyun, bowonryu, segfaultxavi, cedric, bu5hm4n
Reviewed By: woohyun, cedric
Subscribers: raster, bu5hm4n, subodh6129, herdsman, segfaultxavi, zmike, cedric, #committers, #reviewers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D9053
2019-12-11 23:22:12 -08:00
# include "evas_buffer_helper.h"
2012-11-14 12:12:53 -08:00
Evas textblock: fix wrong hyphenation issues with non UTF8 encoded dictionary
Summary:
hnj_hyphen_hyphenate2() needs properly encoded text based on the given
dictionary. Each dictionary contains its encoding information at the head
of file. So, text will be converted to proper encoding before calling
the function. It fixes T3221.
@fix
Test Plan: Included in Evas test suite.
Reviewers: z-wony, tasn, woohyun, herdsman, Blackmole, minudf
Subscribers: zmike, stefan_schmidt, raster, cedric, jpeg
Tags: #efl
Maniphest Tasks: T3221
Differential Revision: https://phab.enlightenment.org/D3863
2018-05-06 00:24:58 -07:00
# define TESTS_DIC_DIR TESTS_SRC_DIR" / dicts"
2012-11-14 12:12:53 -08:00
/* Functions defined in evas_object_textblock.c */
EAPI Eina_Bool
_evas_textblock_check_item_node_link ( Evas_Object * obj ) ;
EAPI int
_evas_textblock_format_offset_get ( const Evas_Object_Textblock_Node_Format * n ) ;
/* end of functions defined in evas_object_textblock.c */
2017-07-11 00:02:59 -07:00
# define TEST_FONT "font=DejaVuSans,UnDotum,malayalam font_source=" TESTS_SRC_DIR " / fonts / TestFont.eet"
2012-11-14 12:12:53 -08:00
static const char * style_buf =
2013-04-11 08:00:24 -07:00
" DEFAULT=' " TEST_FONT " font_size=10 color=#000 text_class=entry' "
2012-11-14 12:12:53 -08:00
" newline='br' "
2013-05-13 07:13:25 -07:00
" b='+ font_weight=bold' " ;
2012-11-14 12:12:53 -08:00
# define START_TB_TEST() \
Evas * evas ; \
Evas_Object * tb ; \
Evas_Textblock_Style * st ; \
Evas_Textblock_Cursor * cur ; \
2020-04-07 04:11:13 -07:00
Efl_Text_Cursor_Object * cur_obj ; \
2012-11-14 12:12:53 -08:00
evas = EVAS_TEST_INIT_EVAS ( ) ; \
evas_font_hinting_set ( evas , EVAS_FONT_HINTING_AUTO ) ; \
tb = evas_object_textblock_add ( evas ) ; \
fail_if ( ! tb ) ; \
evas_object_textblock_legacy_newline_set ( tb , EINA_FALSE ) ; \
st = evas_textblock_style_new ( ) ; \
fail_if ( ! st ) ; \
evas_textblock_style_set ( st , style_buf ) ; \
fail_if ( strcmp ( style_buf , evas_textblock_style_get ( st ) ) ) ; \
evas_object_textblock_style_set ( tb , st ) ; \
cur = evas_object_textblock_cursor_new ( tb ) ; \
2019-12-10 00:39:59 -08:00
cur_obj = efl_canvas_textblock_cursor_create ( tb ) ; \
Efl.Text.Attribute_Factory
Summary:
Implementation of new Efl.Text.Attribute_Factory class which replace the annotation interface.
Currently, we have two public methods:
```
void efl_text_attribute_factory_attribute_insert(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end, const char *format)
unsigned int efl_text_attribute_factory_attribute_clear(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end);
```
Other methods will be internal methods, for the time being, we will redesign internal methods
Reviewers: woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Subscribers: zmike, q66, cedric, segfaultxavi, bu5hm4n, a.srour, #committers, #reviewers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10646
2019-11-26 20:04:31 -08:00
( void ) cur_obj ; \
( void ) cur ; \
2012-11-14 12:12:53 -08:00
do \
{ \
} \
while ( 0 )
# define END_TB_TEST() \
do \
{ \
evas_textblock_cursor_free ( cur ) ; \
Efl.Text.Attribute_Factory
Summary:
Implementation of new Efl.Text.Attribute_Factory class which replace the annotation interface.
Currently, we have two public methods:
```
void efl_text_attribute_factory_attribute_insert(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end, const char *format)
unsigned int efl_text_attribute_factory_attribute_clear(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end);
```
Other methods will be internal methods, for the time being, we will redesign internal methods
Reviewers: woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Subscribers: zmike, q66, cedric, segfaultxavi, bu5hm4n, a.srour, #committers, #reviewers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10646
2019-11-26 20:04:31 -08:00
efl_del ( cur_obj ) ; \
2020-03-23 13:53:54 -07:00
evas_object_del ( tb ) ; \
2012-11-14 12:12:53 -08:00
evas_textblock_style_free ( st ) ; \
evas_free ( evas ) ; \
} \
while ( 0 )
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_simple )
2012-11-14 12:12:53 -08:00
{
START_TB_TEST ( ) ;
const char * buf = " Th<i>i</i>s is a <br/> te<b>s</b>t. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , buf ) ) ;
2016-03-24 01:14:50 -07:00
/* Set markup text(includes tag) without setting style */
Evas_Object * tb2 = evas_object_textblock_add ( evas ) ;
fail_if ( ! tb2 ) ;
evas_object_textblock_text_markup_set ( tb2 , buf ) ;
ck_assert ( " Crash Not occurred " ) ;
evas_object_del ( tb2 ) ;
2012-11-14 12:12:53 -08:00
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
# define _CHECK_CURSOR_COORDS() \
do \
{ \
Evas_Coord cx , cy , cw , ch ; \
int ret ; \
ret = evas_textblock_cursor_geometry_get ( cur , & cx , & cy , & cw , & ch , \
NULL , EVAS_TEXTBLOCK_CURSOR_UNDER ) ; \
fail_if ( ret = = - 1 ) ; \
ret = evas_textblock_cursor_geometry_get ( cur , & cx , & cy , & cw , & ch , \
NULL , EVAS_TEXTBLOCK_CURSOR_BEFORE ) ; \
fail_if ( ret = = - 1 ) ; \
ret = evas_textblock_cursor_char_geometry_get ( cur , \
& cx , & cy , & cw , & ch ) ; \
fail_if ( ret = = - 1 ) ; \
ret = evas_textblock_cursor_pen_geometry_get ( cur , & cx , & cy , & cw , & ch ) ; \
fail_if ( ret = = - 1 ) ; \
ret = evas_textblock_cursor_line_geometry_get ( cur , \
& cx , & cy , & cw , & ch ) ; \
fail_if ( ret = = - 1 ) ; \
} \
while ( 0 )
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_cursor )
2012-11-14 12:12:53 -08:00
{
START_TB_TEST ( ) ;
evas textblock: add/apply cursor cluster APIs based on grapheme cluster
Summary:
Add a feature for moving cursor over a grapheme cluster.
It is applied to edje_entry.c and elm_entry.c for improving
cursor handling just like other modern text editors. ex) gedit
The patch on Evas needs to update libunibreak library.
So, the patch will update libunibreak, too.
@feature
Test Plan:
1. Put "ഹലോ" in your entry.
2. Your cursor can reach at the end of text from the beginning
only in 2 right key event with this feature.
Reviewers: raster, cedric, jpeg, herdsman, zmike, devilhorns
Reviewed By: herdsman, zmike
Subscribers: #reviewers, #committers, zmike, bowonryu, woohyun
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D5490
2018-08-20 04:21:53 -07:00
Evas_Textblock_Cursor * cur2 ;
2012-11-14 12:12:53 -08:00
Evas_Coord x , y , w , h ;
evas textblock: add/apply cursor cluster APIs based on grapheme cluster
Summary:
Add a feature for moving cursor over a grapheme cluster.
It is applied to edje_entry.c and elm_entry.c for improving
cursor handling just like other modern text editors. ex) gedit
The patch on Evas needs to update libunibreak library.
So, the patch will update libunibreak, too.
@feature
Test Plan:
1. Put "ഹലോ" in your entry.
2. Your cursor can reach at the end of text from the beginning
only in 2 right key event with this feature.
Reviewers: raster, cedric, jpeg, herdsman, zmike, devilhorns
Reviewed By: herdsman, zmike
Subscribers: #reviewers, #committers, zmike, bowonryu, woohyun
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D5490
2018-08-20 04:21:53 -07:00
size_t i , j , len ;
2012-11-14 12:12:53 -08:00
Evas_Coord nw , nh ;
2019-01-29 08:03:09 -08:00
# ifdef HAVE_FRIBIDI
2014-10-02 00:36:35 -07:00
Evas_BiDi_Direction dir ;
2019-01-29 08:03:09 -08:00
# endif
2012-11-14 12:12:53 -08:00
const char * buf = " This is a<br/> test.<ps/>Lets see if this works.<ps/>עוד פסקה. " ;
/* Walk the textblock using cursor_char_next */
evas_object_textblock_text_markup_set ( tb , buf ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , buf ) ) ;
len = eina_unicode_utf8_get_len ( buf ) - 12 ; /* 12 because len(<br/>) == 1 and len(<ps/>) == 1 */
for ( i = 0 ; i < len ; i + + )
{
_CHECK_CURSOR_COORDS ( ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! = ( int ) i ) ;
fail_if ( ! evas_textblock_cursor_char_next ( cur ) & & ( i < len - 1 ) ) ;
}
fail_if ( evas_textblock_cursor_char_next ( cur ) ) ;
/* Jump to positions all aronud the textblock */
evas_textblock_cursor_pos_set ( cur , - 1 ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! = 0 ) ;
evas_textblock_cursor_pos_set ( cur , len + 5 ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! = ( int ) len ) ;
for ( i = 0 ; i < len ; i + + )
{
evas_textblock_cursor_pos_set ( cur , i ) ;
_CHECK_CURSOR_COORDS ( ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! = ( int ) i ) ;
}
/* Create another cursor and insert text, making sure everything
* is in sync . */
evas_object_textblock_clear ( tb ) ;
Evas_Textblock_Cursor * main_cur = evas_object_textblock_cursor_get ( tb ) ;
evas_textblock_cursor_copy ( main_cur , cur ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! =
evas_textblock_cursor_pos_get ( main_cur ) ) ;
evas_textblock_cursor_text_prepend ( main_cur , " a " ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) = =
evas_textblock_cursor_pos_get ( main_cur ) ) ;
evas_textblock_cursor_text_prepend ( main_cur , " a " ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) = =
evas_textblock_cursor_pos_get ( main_cur ) ) ;
/* Insert text to a non-empty textblock */
evas_object_textblock_clear ( tb ) ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_copy ( main_cur , cur ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! =
evas_textblock_cursor_pos_get ( main_cur ) ) ;
evas_textblock_cursor_text_prepend ( main_cur , " a " ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) = =
evas_textblock_cursor_pos_get ( main_cur ) ) ;
evas_textblock_cursor_text_prepend ( main_cur , " a " ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) = =
evas_textblock_cursor_pos_get ( main_cur ) ) ;
/* Make sure append works */
evas_textblock_cursor_copy ( main_cur , cur ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! =
evas_textblock_cursor_pos_get ( main_cur ) ) ;
evas_textblock_cursor_text_append ( main_cur , " a " ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! =
evas_textblock_cursor_pos_get ( main_cur ) ) ;
/* Cursor comparison */
evas_textblock_cursor_pos_set ( cur , 1 ) ;
evas_textblock_cursor_pos_set ( main_cur , 2 ) ;
fail_if ( evas_textblock_cursor_compare ( cur , main_cur ) ! = - 1 ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
evas_textblock_cursor_pos_set ( main_cur , 2 ) ;
fail_if ( evas_textblock_cursor_compare ( cur , main_cur ) ! = 0 ) ;
evas_textblock_cursor_pos_set ( cur , 3 ) ;
evas_textblock_cursor_pos_set ( main_cur , 2 ) ;
fail_if ( evas_textblock_cursor_compare ( cur , main_cur ) ! = 1 ) ;
/* Paragraph first */
evas_object_textblock_text_markup_set ( tb , buf ) ;
for ( i = 0 ; i < len ; i + + )
{
evas_textblock_cursor_pos_set ( cur , i ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! = 0 ) ;
}
/* Paragraph last */
for ( i = 0 ; i < len ; i + + )
{
evas_textblock_cursor_pos_set ( cur , i ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
2016-06-05 05:44:03 -07:00
ck_assert_int_eq ( evas_textblock_cursor_pos_get ( cur ) , ( int ) len ) ;
2012-11-14 12:12:53 -08:00
}
/* Paragraph next */
evas_textblock_cursor_paragraph_last ( cur ) ;
fail_if ( evas_textblock_cursor_paragraph_next ( cur ) ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
fail_if ( ! evas_textblock_cursor_paragraph_next ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_paragraph_next ( cur ) ) ;
/* Paragraph prev */
evas_textblock_cursor_paragraph_first ( cur ) ;
fail_if ( evas_textblock_cursor_paragraph_prev ( cur ) ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
fail_if ( ! evas_textblock_cursor_paragraph_prev ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_paragraph_prev ( cur ) ) ;
/* Cher next */
evas_textblock_cursor_paragraph_last ( cur ) ;
fail_if ( evas_textblock_cursor_char_next ( cur ) ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
fail_if ( ! evas_textblock_cursor_char_next ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_paragraph_next ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_char_next ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_paragraph_next ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_char_next ( cur ) ) ;
/* Cher prev */
evas_textblock_cursor_paragraph_first ( cur ) ;
fail_if ( evas_textblock_cursor_char_prev ( cur ) ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
fail_if ( ! evas_textblock_cursor_char_prev ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_paragraph_prev ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_char_prev ( cur ) ) ;
/* Paragraph char first */
evas_textblock_cursor_paragraph_first ( main_cur ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
fail_if ( ! evas_textblock_cursor_char_next ( cur ) ) ;
evas_textblock_cursor_paragraph_char_first ( cur ) ;
fail_if ( evas_textblock_cursor_compare ( cur , main_cur ) ) ;
/* Paragraph char last */
evas_textblock_cursor_paragraph_last ( main_cur ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
fail_if ( ! evas_textblock_cursor_char_prev ( cur ) ) ;
evas_textblock_cursor_paragraph_char_last ( cur ) ;
fail_if ( evas_textblock_cursor_compare ( cur , main_cur ) ) ;
/* Line char first */
evas_textblock_cursor_paragraph_first ( main_cur ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
fail_if ( ! evas_textblock_cursor_char_next ( cur ) ) ;
evas_textblock_cursor_line_char_first ( cur ) ;
fail_if ( evas_textblock_cursor_compare ( cur , main_cur ) ) ;
evas_textblock_cursor_pos_set ( cur , 12 ) ;
evas_textblock_cursor_line_char_first ( cur ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! = 10 ) ;
/* Line char first */
evas_textblock_cursor_paragraph_last ( main_cur ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
fail_if ( ! evas_textblock_cursor_char_prev ( cur ) ) ;
evas_textblock_cursor_line_char_last ( cur ) ;
fail_if ( evas_textblock_cursor_compare ( cur , main_cur ) ) ;
evas_textblock_cursor_pos_set ( cur , 12 ) ;
evas_textblock_cursor_line_char_last ( cur ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! = 16 ) ;
/* Line set */
evas_textblock_cursor_paragraph_first ( main_cur ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
fail_if ( ! evas_textblock_cursor_line_set ( cur , 0 ) ) ;
fail_if ( evas_textblock_cursor_compare ( cur , main_cur ) ) ;
fail_if ( ! evas_textblock_cursor_line_set ( cur , 1 ) ) ;
fail_if ( ! evas_textblock_cursor_line_set ( cur , 2 ) ) ;
fail_if ( ! evas_textblock_cursor_line_set ( cur , 3 ) ) ;
fail_if ( evas_textblock_cursor_line_set ( cur , - 1 ) ) ;
fail_if ( evas_textblock_cursor_line_set ( cur , 99 ) ) ;
/* Paragraph text get */
evas_textblock_cursor_paragraph_first ( cur ) ;
fail_if ( strcmp ( evas_textblock_cursor_paragraph_text_get ( cur ) ,
" This is a<br/> test. " ) ) ;
evas_textblock_cursor_paragraph_next ( cur ) ;
fail_if ( strcmp ( evas_textblock_cursor_paragraph_text_get ( cur ) ,
" Lets see if this works. " ) ) ;
evas_textblock_cursor_paragraph_next ( cur ) ;
fail_if ( strcmp ( evas_textblock_cursor_paragraph_text_get ( cur ) ,
" עוד פסקה. " ) ) ;
/* Paragraph length get */
evas_textblock_cursor_paragraph_first ( cur ) ;
/* -4 because len(<br/>) == 1 */
fail_if ( evas_textblock_cursor_paragraph_text_length_get ( cur ) ! =
eina_unicode_utf8_get_len ( " This is a<br/> test. " ) - 4 ) ;
evas_textblock_cursor_paragraph_next ( cur ) ;
fail_if ( evas_textblock_cursor_paragraph_text_length_get ( cur ) ! =
eina_unicode_utf8_get_len ( " Lets see if this works. " ) ) ;
evas_textblock_cursor_paragraph_next ( cur ) ;
fail_if ( evas_textblock_cursor_paragraph_text_length_get ( cur ) ! =
eina_unicode_utf8_get_len ( " עוד פסקה. " ) ) ;
/* Cursor content get */
evas_textblock_cursor_pos_set ( cur , 0 ) ;
fail_if ( strcmp ( evas_textblock_cursor_content_get ( cur ) , " T " ) ) ;
evas_textblock_cursor_pos_set ( cur , 9 ) ;
fail_if ( strcmp ( evas_textblock_cursor_content_get ( cur ) , " <br/> " ) ) ;
evas_textblock_cursor_pos_set ( cur , 43 ) ;
fail_if ( strcmp ( evas_textblock_cursor_content_get ( cur ) , " ד " ) ) ;
/* Eol get */
for ( i = 0 ; i < len ; i + + )
{
evas_textblock_cursor_pos_set ( cur , i ) ;
evas_textblock_cursor_copy ( cur , main_cur ) ;
evas_textblock_cursor_line_char_last ( main_cur ) ;
if ( ! evas_textblock_cursor_compare ( cur , main_cur ) )
{
fail_if ( ! evas_textblock_cursor_eol_get ( cur ) ) ;
}
else
{
fail_if ( evas_textblock_cursor_eol_get ( cur ) ) ;
}
}
/* Format positions */
const Evas_Object_Textblock_Node_Format * fnode ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
evas_textblock_cursor_at_format_set ( cur , fnode ) ;
evas_textblock_cursor_copy ( cur , main_cur ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! = 9 ) ;
fail_if ( evas_textblock_cursor_format_get ( cur ) ! = fnode ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
evas_textblock_cursor_at_format_set ( cur , fnode ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! = 16 ) ;
fail_if ( evas_textblock_cursor_format_get ( cur ) ! = fnode ) ;
evas_textblock_cursor_format_next ( main_cur ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
fnode = evas_textblock_node_format_prev_get ( fnode ) ;
fail_if ( ! fnode ) ;
evas_textblock_cursor_at_format_set ( cur , fnode ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! = 9 ) ;
fail_if ( evas_textblock_cursor_format_get ( cur ) ! = fnode ) ;
evas_textblock_cursor_format_prev ( main_cur ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
evas_textblock_cursor_format_prev ( main_cur ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
/* Check that pen geometry and getting char at coord are in sync. */
do
{
int cur_pos ;
/* Check if it's the last char, if it is, break, otherwise, go back
* to the current char because our test advanced the cursor . */
if ( ! evas_textblock_cursor_char_next ( cur ) )
break ;
else
evas_textblock_cursor_char_prev ( cur ) ;
cur_pos = evas_textblock_cursor_pos_get ( cur ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , & y , & w , & h ) ;
evas_textblock_cursor_char_coord_set ( cur , x + ( w / 2 ) , y + ( h / 2 ) ) ;
fail_if ( cur_pos ! = evas_textblock_cursor_pos_get ( cur ) ) ;
}
while ( evas_textblock_cursor_char_next ( cur ) ) ;
/* Try positions before the first paragraph, and after the last paragraph */
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_textblock_cursor_pos_set ( cur , 5 ) ;
evas_textblock_cursor_char_coord_set ( cur , nw / 2 ,
- 50 ) ;
evas_textblock_cursor_paragraph_first ( main_cur ) ;
fail_if ( evas_textblock_cursor_compare ( cur , main_cur ) ) ;
evas_textblock_cursor_pos_set ( cur , 5 ) ;
evas_textblock_cursor_char_coord_set ( cur , nw / 2 ,
nh + 50 ) ;
evas_textblock_cursor_paragraph_last ( main_cur ) ;
fail_if ( evas_textblock_cursor_compare ( cur , main_cur ) ) ;
2014-02-07 05:10:54 -08:00
/* Try positions between the first paragraph and the first line. */
evas_object_textblock_text_markup_set ( tb , buf ) ;
fail_if ( ! evas_textblock_cursor_char_coord_set ( cur , 5 , 1 ) ) ;
2012-11-14 12:12:53 -08:00
/* Try positions beyond the left/right limits of lines. */
for ( i = 0 ; i < 2 ; i + + )
{
evas_textblock_cursor_line_set ( cur , i ) ;
evas_textblock_cursor_line_geometry_get ( cur , & x , & y , & w , & h ) ;
evas_textblock_cursor_pos_set ( main_cur , 5 ) ;
evas_textblock_cursor_char_coord_set ( main_cur , x - 50 , y ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
evas_textblock_cursor_line_char_last ( cur ) ;
evas_textblock_cursor_pos_set ( main_cur , 5 ) ;
evas_textblock_cursor_char_coord_set ( main_cur , x + w + 50 , y ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
}
2015-11-19 03:37:07 -08:00
# ifdef HAVE_FRIBIDI
2014-10-02 00:36:35 -07:00
/* Check direction */
evas_object_textblock_text_markup_set ( tb , " test " ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , " test " ) ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , NULL , NULL , NULL , NULL , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_LTR ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , NULL , NULL , NULL , NULL , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_LTR ) ;
evas_object_textblock_text_markup_set ( tb , " עוד פסקה " ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , " עוד פסקה " ) ) ;
dir = EVAS_BIDI_DIRECTION_LTR ;
evas_textblock_cursor_geometry_get ( cur , NULL , NULL , NULL , NULL , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_RTL ) ;
dir = EVAS_BIDI_DIRECTION_LTR ;
evas_textblock_cursor_geometry_get ( cur , NULL , NULL , NULL , NULL , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_RTL ) ;
2015-11-19 03:37:07 -08:00
evas_object_textblock_text_markup_set ( tb , " 123 " ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , " 123 " ) ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , NULL , NULL , NULL , NULL , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_LTR ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , NULL , NULL , NULL , NULL , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_LTR ) ;
evas_object_textblock_text_markup_set ( tb , " %^& " ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , " %^& " ) ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , NULL , NULL , NULL , NULL , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_LTR ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , NULL , NULL , NULL , NULL , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_LTR ) ;
/* Check direction with evas_object_paragraph_direction_set API */
{
Evas_Coord xx , yy , ww , hh ;
/* LTR text case */
evas_object_textblock_text_markup_set ( tb , " test " ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , " test " ) ) ;
/* EVAS_TEXTBLOCK_CURSOR_UNDER */
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_NEUTRAL ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & x , & y , & w , & h , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_RTL ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x > = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_LTR ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x ! = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
/* EVAS_TEXTBLOCK_CURSOR_BEFORE */
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_NEUTRAL ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & x , & y , & w , & h , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_RTL ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x > = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_LTR ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x ! = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
/* RTL text case */
evas_object_textblock_text_markup_set ( tb , " עוד פסקה " ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , " עוד פסקה " ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_NEUTRAL ) ;
dir = EVAS_BIDI_DIRECTION_LTR ;
evas_textblock_cursor_geometry_get ( cur , & x , & y , & w , & h , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_RTL ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_LTR ) ;
dir = EVAS_BIDI_DIRECTION_LTR ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x < = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_RTL ) ;
dir = EVAS_BIDI_DIRECTION_LTR ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x ! = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_NEUTRAL ) ;
dir = EVAS_BIDI_DIRECTION_LTR ;
evas_textblock_cursor_geometry_get ( cur , & x , & y , & w , & h , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_RTL ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_LTR ) ;
dir = EVAS_BIDI_DIRECTION_LTR ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x < = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_RTL ) ;
dir = EVAS_BIDI_DIRECTION_LTR ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x ! = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
/* NEUTRAL(European Number) text case */
/* It doesn't change characters sequence. */
evas_object_textblock_text_markup_set ( tb , " 123 " ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , " 123 " ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_NEUTRAL ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & x , & y , & w , & h , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_RTL ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x > = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_LTR ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x ! = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_NEUTRAL ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & x , & y , & w , & h , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_RTL ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x > = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_LTR ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x ! = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
/* NEUTRAL(Other Neutrals) text case */
/* It changes characters sequence. */
evas_object_textblock_text_markup_set ( tb , " %^& " ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , " %^& " ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_NEUTRAL ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & x , & y , & w , & h , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_RTL ) ;
dir = EVAS_BIDI_DIRECTION_LTR ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x > = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_LTR ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x ! = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_NEUTRAL ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & x , & y , & w , & h , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_RTL ) ;
dir = EVAS_BIDI_DIRECTION_LTR ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir ! = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x > = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_LTR ) ;
dir = EVAS_BIDI_DIRECTION_RTL ;
evas_textblock_cursor_geometry_get ( cur , & xx , & yy , & ww , & hh , & dir ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
fail_if ( dir = = EVAS_BIDI_DIRECTION_RTL ) ;
fail_if ( ( x ! = xx ) | | ( y ! = yy ) | | ( w ! = ww ) | | ( h ! = hh ) ) ;
/* Reset paragraph direction */
evas_object_paragraph_direction_set ( tb , EVAS_BIDI_DIRECTION_NEUTRAL ) ;
}
2014-10-02 00:36:35 -07:00
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb ,
" testנס י ו ן testנס י ו ן <ps/> "
" נס י ו ן testנס י ו ן test<ps/> "
" testנס י ו ן test<ps/> "
" נס י ו ן testנס י ו ן <ps/> "
" testנס י ו ן <br/>נסיון<ps/> "
" נס י ו ן test<br/>test "
) ;
for ( i = 0 ; i < 8 ; i + + )
{
evas_textblock_cursor_line_set ( cur , i ) ;
evas_textblock_cursor_line_geometry_get ( cur , & x , & y , & w , & h ) ;
switch ( i )
{
case 0 :
case 2 :
case 4 :
case 5 :
/* Ltr paragraph */
evas_textblock_cursor_pos_set ( main_cur , 7 ) ;
evas_textblock_cursor_char_coord_set ( main_cur , x - 50 , y ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
evas_textblock_cursor_line_char_last ( cur ) ;
evas_textblock_cursor_pos_set ( main_cur , 7 ) ;
evas_textblock_cursor_char_coord_set ( main_cur , x + w + 50 , y ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
break ;
case 1 :
case 3 :
case 6 :
case 7 :
/* Rtl paragraph */
evas_textblock_cursor_line_char_last ( cur ) ;
evas_textblock_cursor_pos_set ( main_cur , 7 ) ;
evas_textblock_cursor_char_coord_set ( main_cur , x - 50 , y ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
evas_textblock_cursor_line_char_first ( cur ) ;
evas_textblock_cursor_pos_set ( main_cur , 7 ) ;
evas_textblock_cursor_char_coord_set ( main_cur , x + w + 50 , y ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
break ;
}
}
# endif
evas_object_textblock_text_markup_set ( tb , buf ) ;
/* Testing line geometry.*/
{
Evas_Coord lx , ly , lw , lh ;
Evas_Coord plx , ply , plw , plh ;
evas_textblock_cursor_line_set ( cur , 0 ) ;
evas_textblock_cursor_copy ( cur , main_cur ) ;
evas_textblock_cursor_line_char_last ( main_cur ) ;
evas_textblock_cursor_line_geometry_get ( cur , & plx , & ply , & plw , & plh ) ;
while ( evas_textblock_cursor_compare ( cur , main_cur ) < = 0 )
{
evas_textblock_cursor_pen_geometry_get ( cur , & x , & y , & w , & h ) ;
fail_if ( 0 ! = evas_textblock_cursor_line_geometry_get (
cur , & lx , & ly , & lw , & lh ) ) ;
2014-02-27 02:39:52 -08:00
fail_if ( ( x < lx ) | |
2012-11-14 12:12:53 -08:00
( y < ly ) | | ( y + h > ly + lh ) ) ;
fail_if ( ( lx ! = plx ) | | ( ly ! = ply ) | | ( lw ! = plw ) | | ( lh ! = plh ) ) ;
plx = lx ;
ply = ly ;
plw = lw ;
plh = lh ;
evas_textblock_cursor_char_next ( cur ) ;
}
evas_textblock_cursor_line_set ( cur , 1 ) ;
evas_textblock_cursor_copy ( cur , main_cur ) ;
evas_textblock_cursor_line_char_last ( main_cur ) ;
evas_textblock_cursor_line_geometry_get ( cur , & plx , & ply , & plw , & plh ) ;
while ( evas_textblock_cursor_compare ( cur , main_cur ) < = 0 )
{
evas_textblock_cursor_pen_geometry_get ( cur , & x , & y , & w , & h ) ;
fail_if ( 1 ! = evas_textblock_cursor_line_geometry_get (
cur , & lx , & ly , & lw , & lh ) ) ;
2014-02-27 02:39:52 -08:00
fail_if ( ( x < lx ) | |
2012-11-14 12:12:53 -08:00
( y < ly ) | | ( y + h > ly + lh ) ) ;
fail_if ( ( lx ! = plx ) | | ( ly ! = ply ) | | ( lw ! = plw ) | | ( lh ! = plh ) ) ;
plx = lx ;
ply = ly ;
plw = lw ;
plh = lh ;
evas_textblock_cursor_char_next ( cur ) ;
}
evas_textblock_cursor_paragraph_last ( cur ) ;
evas_textblock_cursor_line_set ( cur , 0 ) ;
evas_textblock_cursor_line_geometry_get ( cur , & plx , & ply , & plw , & plh ) ;
evas_object_textblock_line_number_geometry_get ( tb , 0 ,
& lx , & ly , & lw , & lh ) ;
fail_if ( ( lx ! = plx ) | | ( ly ! = ply ) | | ( lw ! = plw ) | | ( lh ! = plh ) ) ;
fail_if ( 0 ! = evas_textblock_cursor_line_coord_set ( cur , ly + ( lh / 2 ) ) ) ;
evas_textblock_cursor_line_set ( cur , 1 ) ;
evas_textblock_cursor_line_geometry_get ( cur , & plx , & ply , & plw , & plh ) ;
evas_object_textblock_line_number_geometry_get ( tb , 1 ,
& lx , & ly , & lw , & lh ) ;
fail_if ( ( lx ! = plx ) | | ( ly ! = ply ) | | ( lw ! = plw ) | | ( lh ! = plh ) ) ;
fail_if ( 1 ! = evas_textblock_cursor_line_coord_set ( cur , ly + ( lh / 2 ) ) ) ;
/* Before the start of the textblock */
fail_if ( 0 ! = evas_textblock_cursor_line_coord_set ( cur , - 50 ) ) ;
fail_if ( 3 ! = evas_textblock_cursor_line_coord_set ( cur , 100000 ) ) ;
/* And now with a valigned textblock. */
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , 2 * nw , 2 * nh ) ;
evas_object_textblock_valign_set ( tb , 0.5 ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , & y , & w , & h ) ;
fail_if ( y < = 0 ) ;
evas_textblock_cursor_paragraph_last ( main_cur ) ;
evas_textblock_cursor_char_coord_set ( main_cur , x + w , y / 2 ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
evas_textblock_cursor_paragraph_last ( main_cur ) ;
evas_textblock_cursor_line_coord_set ( main_cur , y / 2 ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
/* Fail if they are equal, i.e if it for some reason thinks it should
* go to the end . */
evas_textblock_cursor_paragraph_first ( main_cur ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
evas_textblock_cursor_char_coord_set ( main_cur , x + w , nh + 1 ) ;
fail_if ( ! evas_textblock_cursor_compare ( main_cur , cur ) ) ;
evas_textblock_cursor_paragraph_first ( main_cur ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
evas_textblock_cursor_line_coord_set ( main_cur , nh + 1 ) ;
fail_if ( ! evas_textblock_cursor_compare ( main_cur , cur ) ) ;
/* Fail if it doesn't go to the end. */
evas_textblock_cursor_paragraph_last ( cur ) ;
evas_textblock_cursor_paragraph_first ( main_cur ) ;
evas_textblock_cursor_char_coord_set ( main_cur , x + w , ( 2 * nh ) - 1 ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
evas_textblock_cursor_paragraph_first ( main_cur ) ;
evas_textblock_cursor_line_coord_set ( main_cur , ( 2 * nh ) - 1 ) ;
fail_if ( evas_textblock_cursor_compare ( main_cur , cur ) ) ;
2015-06-26 06:50:22 -07:00
evas_object_textblock_text_markup_set ( tb , " 123<br/>456<br/>789 " ) ;
evas_object_textblock_valign_set ( tb , 0.0 ) ;
evas_textblock_cursor_pos_set ( cur , 6 ) ;
2015-06-26 07:24:56 -07:00
ck_assert_int_eq ( evas_textblock_cursor_line_coord_set ( cur , 0 ) , 0 ) ;
2012-11-14 12:12:53 -08:00
}
{
const char * buf_wb = " a This is_a t:e.s't a " ;
evas_object_textblock_text_markup_set ( tb , buf_wb ) ;
/* Word start/end */
evas_textblock_cursor_pos_set ( cur , 3 ) ;
evas_textblock_cursor_word_start ( cur ) ;
fail_if ( 2 ! = evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_word_end ( cur ) ;
fail_if ( 5 ! = evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_pos_set ( cur , 13 ) ;
evas_textblock_cursor_word_end ( cur ) ;
fail_if ( 18 ! = evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_word_start ( cur ) ;
fail_if ( 12 ! = evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_word_start ( cur ) ;
fail_if ( 12 ! = evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_word_start ( cur ) ;
fail_if ( 12 ! = evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_word_end ( cur ) ;
fail_if ( 18 ! = evas_textblock_cursor_pos_get ( cur ) ) ;
/* Bug with 1 char word separators at paragraph start. */
evas_object_textblock_text_markup_set ( tb , " =test " ) ;
evas_textblock_cursor_pos_set ( cur , 4 ) ;
evas_textblock_cursor_word_start ( cur ) ;
fail_if ( 1 ! = evas_textblock_cursor_pos_get ( cur ) ) ;
2014-02-19 06:31:33 -08:00
/* 1 char words separated by spaces. */
evas_object_textblock_text_markup_set ( tb , " a a a a " ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
evas_textblock_cursor_word_end ( cur ) ;
ck_assert_int_eq ( 0 , evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_word_start ( cur ) ;
ck_assert_int_eq ( 0 , evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
evas_textblock_cursor_word_start ( cur ) ;
ck_assert_int_eq ( 2 , evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_word_end ( cur ) ;
ck_assert_int_eq ( 2 , evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_pos_set ( cur , 3 ) ;
evas_textblock_cursor_word_start ( cur ) ;
ck_assert_int_eq ( 2 , evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_pos_set ( cur , 3 ) ;
evas_textblock_cursor_word_end ( cur ) ;
ck_assert_int_eq ( 4 , evas_textblock_cursor_pos_get ( cur ) ) ;
/* Going back when ending with whites. */
evas_object_textblock_text_markup_set ( tb , " aa bla " ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
evas_textblock_cursor_word_start ( cur ) ;
ck_assert_int_eq ( 3 , evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_word_end ( cur ) ;
ck_assert_int_eq ( 5 , evas_textblock_cursor_pos_get ( cur ) ) ;
Evas textblock: Correct word start/end moving at new line or line begins with spaces
Summary:
Word start/end works incorrectly when it goes to new line or line begins with spaces.
Ex: In elementary_test/Entry, place cursor at the end of line, press ctrl + right arrow keys: cursor moves to begin of next line. In this case, cursor should move to end of 1st word in next line.
Ex2: In elementary_test/Entry, add some spaces to begin of 2nd line (" uses markup"), place cursor at the first word ("uses"), press ctrl + left arrow keys twice, cursor moves to begin of 2nd line. In this case, cursor should move to begin of last word in 1st line.
This patch provides a fix by considerring next/previous text node to move cursor to correct place.
@fix
Reviewers: woohyun, raster, tasn
Subscribers: cedric
Differential Revision: https://phab.enlightenment.org/D1140
2014-08-04 03:01:51 -07:00
/* moving across paragraphs */
evas_object_textblock_text_markup_set ( tb ,
" test<ps/> "
" case " ) ;
evas_textblock_cursor_pos_set ( cur , 4 ) ;
evas_textblock_cursor_word_end ( cur ) ;
ck_assert_int_eq ( 10 , evas_textblock_cursor_pos_get ( cur ) ) ;
evas_textblock_cursor_pos_set ( cur , 6 ) ;
evas_textblock_cursor_word_start ( cur ) ;
ck_assert_int_eq ( 0 , evas_textblock_cursor_pos_get ( cur ) ) ;
2012-11-14 12:12:53 -08:00
}
2013-04-08 05:30:31 -07:00
/* Make sure coords are correct for ligatures */
{
evas_object_textblock_text_markup_set ( tb , " fi<br/>fii " ) ;
2013-04-09 23:48:55 -07:00
# ifdef HAVE_HARFBUZZ
2013-04-08 05:30:31 -07:00
for ( i = 0 ; i < 2 ; i + + )
{
evas_textblock_cursor_pen_geometry_get ( cur , NULL , NULL , & w , NULL ) ;
2013-04-11 08:00:24 -07:00
ck_assert_int_eq ( w , 3 ) ;
2013-04-08 05:30:31 -07:00
evas_textblock_cursor_char_next ( cur ) ;
}
evas_textblock_cursor_char_next ( cur ) ;
2013-04-11 09:47:51 -07:00
for ( i = 0 ; i < 2 ; i + + )
2013-04-08 05:30:31 -07:00
{
evas_textblock_cursor_pen_geometry_get ( cur , NULL , NULL , & w , NULL ) ;
2013-04-11 08:00:24 -07:00
ck_assert_int_eq ( w , 3 ) ;
2013-04-08 05:30:31 -07:00
evas_textblock_cursor_char_next ( cur ) ;
}
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , NULL , NULL , & w , NULL ) ;
ck_assert_int_eq ( w , 3 ) ;
2013-04-09 23:48:55 -07:00
# else
2013-04-11 08:00:24 -07:00
/* FIXME: Disabled because fails on jenkins */
#if 0
2013-04-09 23:48:55 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , NULL , NULL , & w , NULL ) ;
2013-04-11 08:00:24 -07:00
ck_assert_int_eq ( w , 4 ) ;
2013-04-09 23:48:55 -07:00
evas_textblock_cursor_char_next ( cur ) ;
evas_textblock_cursor_pen_geometry_get ( cur , NULL , NULL , & w , NULL ) ;
2013-04-11 08:00:24 -07:00
ck_assert_int_eq ( w , 3 ) ;
2013-04-09 23:48:55 -07:00
evas_textblock_cursor_pos_set ( cur , 3 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , NULL , NULL , & w , NULL ) ;
2013-04-11 08:00:24 -07:00
ck_assert_int_eq ( w , 4 ) ;
2013-04-09 23:48:55 -07:00
for ( i = 0 ; i < 2 ; i + + )
{
evas_textblock_cursor_char_next ( cur ) ;
evas_textblock_cursor_pen_geometry_get ( cur , NULL , NULL , & w , NULL ) ;
2013-04-11 08:00:24 -07:00
ck_assert_int_eq ( w , 3 ) ;
2013-04-09 23:48:55 -07:00
}
2013-04-11 08:00:24 -07:00
# endif
2013-04-09 23:48:55 -07:00
# endif
2013-04-08 05:30:31 -07:00
}
2015-12-07 07:23:24 -08:00
/* Line set with BiDi text */
{
size_t pos ;
evas_object_textblock_text_markup_set ( tb ,
" שלום עולם hello world<ps> "
" שלום עולם hello world<ps> "
" hello world שלום עולם " ) ;
evas_textblock_cursor_line_set ( cur , 0 ) ;
pos = evas_textblock_cursor_pos_get ( cur ) ;
ck_assert_int_eq ( pos , 0 ) ;
evas_textblock_cursor_line_set ( cur , 1 ) ;
pos = evas_textblock_cursor_pos_get ( cur ) ;
ck_assert_int_eq ( pos , 22 ) ;
evas_textblock_cursor_line_set ( cur , 2 ) ;
pos = evas_textblock_cursor_pos_get ( cur ) ;
ck_assert_int_eq ( pos , 44 ) ;
}
2016-07-03 06:57:22 -07:00
{
/* Test multiple cursors:
* Deleting characters should " pull " all the cursors positioned * after *
* the deleted position , and " push " on insertion .
* Testing with one additional cursor will suffice . */
int j , pos ;
Evas_Textblock_Cursor * cur2 ;
cur2 = evas_object_textblock_cursor_new ( tb ) ;
evas_object_textblock_text_markup_set ( tb , " Hello world " ) ;
evas_textblock_cursor_pos_set ( cur2 , 0 ) ;
evas_textblock_cursor_pos_set ( cur , 5 ) ;
for ( j = 5 ; j > = 0 ; j - - )
{
pos = evas_textblock_cursor_pos_get ( cur ) ;
ck_assert_int_eq ( pos , j ) ;
evas_textblock_cursor_char_delete ( cur2 ) ;
}
evas_object_textblock_text_markup_set ( tb , " Hello world " ) ;
evas_textblock_cursor_pos_set ( cur2 , 0 ) ;
evas_textblock_cursor_pos_set ( cur , 5 ) ;
for ( j = 5 ; j < = 10 ; j + + )
{
pos = evas_textblock_cursor_pos_get ( cur ) ;
ck_assert_int_eq ( pos , j ) ;
evas_textblock_cursor_text_append ( cur2 , " a " ) ;
}
evas_textblock_cursor_free ( cur2 ) ;
}
evas textblock: add/apply cursor cluster APIs based on grapheme cluster
Summary:
Add a feature for moving cursor over a grapheme cluster.
It is applied to edje_entry.c and elm_entry.c for improving
cursor handling just like other modern text editors. ex) gedit
The patch on Evas needs to update libunibreak library.
So, the patch will update libunibreak, too.
@feature
Test Plan:
1. Put "ഹലോ" in your entry.
2. Your cursor can reach at the end of text from the beginning
only in 2 right key event with this feature.
Reviewers: raster, cedric, jpeg, herdsman, zmike, devilhorns
Reviewed By: herdsman, zmike
Subscribers: #reviewers, #committers, zmike, bowonryu, woohyun
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D5490
2018-08-20 04:21:53 -07:00
/* Testing for grapheme cluster */
cur2 = evas_object_textblock_cursor_new ( tb ) ;
evas_object_textblock_text_markup_set ( tb , " ഹലോ " ) ;
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_pos_set ( cur2 , 0 ) ;
i = j = 0 ;
while ( evas_textblock_cursor_cluster_next ( cur ) ) i + + ;
ck_assert_int_eq ( i , 2 ) ;
while ( evas_textblock_cursor_char_next ( cur2 ) ) j + + ;
ck_assert_int_eq ( j , 4 ) ;
i = j = 0 ;
while ( evas_textblock_cursor_cluster_prev ( cur ) ) i + + ;
ck_assert_int_eq ( i , 2 ) ;
while ( evas_textblock_cursor_char_prev ( cur2 ) ) j + + ;
ck_assert_int_eq ( j , 4 ) ;
2012-11-14 12:12:53 -08:00
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
2013-04-11 09:47:51 -07:00
# ifdef HAVE_FRIBIDI
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_split_cursor )
2013-04-10 04:54:37 -07:00
{
START_TB_TEST ( ) ;
Evas_Coord x , w , x2 , w2 ;
Evas_Coord nw , nh ;
Evas_Coord cx , cy , cx2 , cy2 ;
2013-04-11 09:47:51 -07:00
/* Split cursor in LTR paragraph.
* Russian ' t ' in the beginnning to create additional item . */
/*01234 5 6789012345678 19 01234 */
evas_object_textblock_text_markup_set ( tb , " тest \u202b נס י ו ן abcנס י ו ן \u202c bang " ) ;
2013-04-10 04:54:37 -07:00
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
/* Logical cursor after "test " */
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 6 ) ;
2016-05-24 06:11:03 -07:00
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL , NULL ,
& cx2 , NULL , NULL , NULL , EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 18 ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 20 ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , x ) ;
ck_assert_int_eq ( cx2 , x2 ) ;
2013-04-10 04:54:37 -07:00
/* Logical cursor before "a" */
evas_textblock_cursor_pos_set ( cur , 11 ) ;
2016-05-24 06:11:03 -07:00
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL , NULL ,
& cx2 , NULL , NULL , NULL , EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 11 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
evas_textblock_cursor_pos_set ( cur , 10 ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , x ) ;
ck_assert_int_eq ( cx2 , x2 ) ;
2013-04-10 04:54:37 -07:00
/* Logical cursor after "c" */
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 14 ) ;
2013-04-10 04:54:37 -07:00
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , & cx2 , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 10 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
evas_textblock_cursor_pos_set ( cur , 11 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
ck_assert_int_eq ( cx , x ) ;
ck_assert_int_eq ( cx2 , x2 ) ;
/* Logical cursor before " bang" */
evas_textblock_cursor_pos_set ( cur , 20 ) ;
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , & cx2 , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
evas_textblock_cursor_pos_set ( cur , 19 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
ck_assert_int_eq ( cx , x ) ;
ck_assert_int_eq ( cx2 , x2 ) ;
2013-04-10 04:54:37 -07:00
/* Logical cursor in the beginning */
evas_textblock_cursor_line_char_first ( cur ) ;
fail_if ( evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , NULL , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , x ) ;
2013-04-10 04:54:37 -07:00
/* Logical cursor in the end */
evas_textblock_cursor_line_char_last ( cur ) ;
fail_if ( evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , NULL , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
ck_assert_int_eq ( cx , x ) ;
2013-04-10 04:54:37 -07:00
2013-04-11 09:47:51 -07:00
/* Logical cursor on the second pos */
evas_textblock_cursor_pos_set ( cur , 2 ) ;
2013-04-10 04:54:37 -07:00
fail_if ( evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , NULL , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , x ) ;
2013-04-10 04:54:37 -07:00
/* Split cursor in RTL paragraph. */
2013-04-11 09:47:51 -07:00
/* 1 2
01234 5 67890123456789 0 123456 */
evas_object_textblock_text_markup_set ( tb , " שלום \u202a test עברית efl \u202c נסיון " ) ;
2013-04-10 04:54:37 -07:00
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
/* Logical cursor before "test" */
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 6 ) ;
2013-04-10 04:54:37 -07:00
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , & cx2 , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 4 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
evas_textblock_cursor_pos_set ( cur , 6 ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , x ) ;
ck_assert_int_eq ( cx2 , x2 ) ;
2013-04-11 08:00:24 -07:00
2013-04-11 09:47:51 -07:00
/* Logical cursor after "test " */
evas_textblock_cursor_pos_set ( cur , 11 ) ;
2013-04-10 04:54:37 -07:00
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , & cx2 , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 16 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
evas_textblock_cursor_pos_set ( cur , 15 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
ck_assert_int_eq ( cx , x ) ;
ck_assert_int_eq ( cx2 , x2 ) ;
2013-04-10 04:54:37 -07:00
/* Logical cursor before " efl" */
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 16 ) ;
2013-04-10 04:54:37 -07:00
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , & cx2 , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 15 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
ck_assert_int_eq ( cx , x ) ;
ck_assert_int_eq ( cx2 , x2 ) ;
2013-04-11 08:00:24 -07:00
2013-04-11 09:47:51 -07:00
/* Logical cursor after " efl" */
evas_textblock_cursor_pos_set ( cur , 21 ) ;
2013-04-10 04:54:37 -07:00
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , & cx2 , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 6 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
evas_textblock_cursor_pos_set ( cur , 4 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
ck_assert_int_eq ( cx , x ) ;
ck_assert_int_eq ( cx2 , x2 ) ;
2013-04-10 04:54:37 -07:00
/* Logical cursor in the beginning */
evas_textblock_cursor_line_char_first ( cur ) ;
fail_if ( evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , NULL , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , & w , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , ( x + w ) ) ;
2013-04-10 04:54:37 -07:00
/* Logical cursor in the end */
evas_textblock_cursor_line_char_last ( cur ) ;
fail_if ( evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , NULL , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
evas_textblock_cursor_pos_set ( cur , 26 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , x ) ;
2013-04-10 04:54:37 -07:00
/* Corner cases for split cursor. */
2013-04-11 09:47:51 -07:00
/* End of line in LTR paragraph with embedding*/
/* 1
01234 5 678901234567 */
evas_object_textblock_text_markup_set ( tb , " test \u202b נס י ו ן شسيبabc " ) ;
2013-04-10 04:54:37 -07:00
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_textblock_cursor_line_char_last ( cur ) ;
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , & cx2 , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 15 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
evas_textblock_cursor_pos_set ( cur , 6 ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , & w , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , ( x + w ) ) ;
ck_assert_int_eq ( cx2 , x2 ) ;
2013-04-10 04:54:37 -07:00
/* End of line in RTL paragraph */
2013-04-11 09:47:51 -07:00
/* 1 2
01234567 8 9 01234567 890123 */
evas_object_textblock_text_markup_set ( tb , " נסיוןشسي \u202a testпр иве тשלו ם " ) ;
2013-04-10 04:54:37 -07:00
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_textblock_cursor_line_char_last ( cur ) ;
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , & cx2 , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
evas_textblock_cursor_pos_set ( cur , 8 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 10 ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , x ) ;
ck_assert_int_eq ( cx2 , x2 ) ;
2013-04-10 04:54:37 -07:00
/* Cursor is between items of the same direction */
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_pos_set ( cur , 14 ) ;
2013-04-10 04:54:37 -07:00
fail_if ( evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , NULL , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , x ) ;
2013-04-10 04:54:37 -07:00
/* Cursor type is UNDER */
evas_textblock_cursor_pos_set ( cur , 0 ) ;
fail_if ( evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , NULL , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_UNDER ) ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , x ) ;
2013-04-10 04:54:37 -07:00
/* Multiline */
Evas_Coord ly ;
int i ;
/* 012345678901234 */
evas_object_textblock_text_markup_set ( tb , " <wrap=char>testשלו םشسيبefl " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
nh = nh * 15 ;
evas_object_resize ( tb , nw , nh ) ;
for ( i = 0 ; i < nw ; i + + )
{
evas_object_resize ( tb , i , nh ) ;
evas_textblock_cursor_pos_set ( cur , 12 ) ;
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , & cy , NULL ,
NULL , & cx2 , & cy2 , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
evas_textblock_cursor_line_geometry_get ( cur , NULL , & ly , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cy , ly ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , x ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pos_set ( cur , 11 ) ;
evas_textblock_cursor_line_geometry_get ( cur , NULL , & ly , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cy2 , ly ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx2 , x2 ) ;
2013-04-10 04:54:37 -07:00
}
/* 01234567890123456789 */
evas_object_textblock_text_markup_set ( tb , " <wrap=char>נס י ו ן helloпр иве тשלו ם " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
nh = nh * 20 ;
evas_object_resize ( tb , nw , nh ) ;
for ( i = 0 ; i < nw ; i + + )
{
evas_object_resize ( tb , i , nh ) ;
evas_textblock_cursor_pos_set ( cur , 16 ) ;
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , & cy , NULL ,
NULL , & cx2 , & cy2 , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
evas_textblock_cursor_line_geometry_get ( cur , NULL , & ly , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cy , ly ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , & w , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , ( x + w ) ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pos_set ( cur , 15 ) ;
evas_textblock_cursor_line_geometry_get ( cur , NULL , & ly , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cy2 , ly ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , & w2 , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx2 , ( x2 + w2 ) ) ;
2013-04-10 04:54:37 -07:00
}
/* Testing multiline, when only RTL item is in the line. */
/* 012345678901234567890123 */
evas_object_textblock_text_markup_set ( tb , " <wrap=char>testtesttestте с тשלו םشسيب " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_textblock_cursor_pos_set ( cur , 15 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , & w , NULL ) ;
/* Resizing textblock, so RTL item will be on the next line.*/
evas_object_resize ( tb , x + w , nh ) ;
evas_textblock_cursor_pos_set ( cur , 24 ) ;
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , & cy , NULL ,
NULL , & cx2 , & cy2 , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
evas_textblock_cursor_pos_set ( cur , 16 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , & w , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , ( x + w ) ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_line_geometry_get ( cur , NULL , & ly , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cy , ly ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_pos_set ( cur , 23 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx2 , x2 ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_line_geometry_get ( cur , NULL , & ly , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cy2 , ly ) ;
2013-04-10 04:54:37 -07:00
/* Testing multiline, when only LTR item is in the line. */
/* 012345678901234567890123 */
evas_object_textblock_text_markup_set ( tb , " <wrap=char>שלו םשלו םשלו םشسيبtestте с т " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_textblock_cursor_pos_set ( cur , 15 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , & w , NULL ) ;
/* Resizing textblock, so LTR item will be on the next line.*/
evas_object_resize ( tb , nw - x , nh ) ;
evas_textblock_cursor_pos_set ( cur , 24 ) ;
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur , & cx , & cy , NULL ,
NULL , & cx2 , & cy2 , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
evas_textblock_cursor_pos_set ( cur , 16 ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cx , x ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_line_geometry_get ( cur , NULL , & ly , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cy , ly ) ;
2013-04-10 04:54:37 -07:00
2013-04-11 09:47:51 -07:00
evas_textblock_cursor_line_char_last ( cur ) ;
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
ck_assert_int_eq ( cx2 , x2 ) ;
2013-04-10 04:54:37 -07:00
evas_textblock_cursor_line_geometry_get ( cur , NULL , & ly , NULL , NULL ) ;
2013-04-11 09:47:51 -07:00
ck_assert_int_eq ( cy2 , ly ) ;
2013-04-10 04:54:37 -07:00
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2013-04-11 04:00:15 -07:00
# endif
2013-04-10 04:54:37 -07:00
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_format_removal )
2012-11-14 12:12:53 -08:00
{
START_TB_TEST ( ) ;
int i ;
const char * buf = " Th<b>is a<a>tes</a>st</b>. " ;
const Evas_Object_Textblock_Node_Format * fnode ;
Evas_Textblock_Cursor * main_cur = evas_object_textblock_cursor_get ( tb ) ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
/* Remove the "b" pair. */
fnode = evas_textblock_node_format_first_get ( tb ) ;
evas_textblock_node_format_remove_pair ( tb ,
( Evas_Object_Textblock_Node_Format * ) fnode ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" + a " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" - a " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
/* Now also remove the a pair */
fnode = evas_textblock_node_format_first_get ( tb ) ;
evas_textblock_node_format_remove_pair ( tb ,
( Evas_Object_Textblock_Node_Format * ) fnode ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( fnode ) ;
/* Remove the "a" pair. */
evas_object_textblock_text_markup_set ( tb , buf ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
evas_textblock_node_format_remove_pair ( tb ,
( Evas_Object_Textblock_Node_Format * ) fnode ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" + b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" - b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
/* Now also remove the b pair */
fnode = evas_textblock_node_format_first_get ( tb ) ;
evas_textblock_node_format_remove_pair ( tb ,
( Evas_Object_Textblock_Node_Format * ) fnode ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( fnode ) ;
/* Now remove formats by removing text */
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_pos_set ( cur , 6 ) ;
evas_textblock_cursor_char_delete ( cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
/* Only b formats should remain */
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" + b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" - b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
/* No formats should remain. */
evas_textblock_cursor_pos_set ( cur , 2 ) ;
evas_textblock_cursor_char_delete ( cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( fnode ) ;
/* Try to remove the formats in a way that shouldn't remove them */
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_pos_set ( cur , 7 ) ;
evas_textblock_cursor_char_delete ( cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" + b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" + a " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" - a " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" - b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
/* Try range deletion to delete a */
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_pos_set ( cur , 6 ) ;
evas_textblock_cursor_pos_set ( main_cur , 9 ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" + b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" - b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
/* Range deletion to delete both */
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
evas_textblock_cursor_pos_set ( main_cur , 11 ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( fnode ) ;
/* Range deletion across paragraphs */
evas_object_textblock_text_markup_set ( tb ,
" Th<b>is a<a>te<ps/> "
" s</a>st</b>. " ) ;
evas_textblock_cursor_pos_set ( cur , 6 ) ;
evas_textblock_cursor_pos_set ( main_cur , 10 ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" + b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" - b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
/* Range deletion across paragraph - a bug found in elm. */
evas_object_textblock_text_markup_set ( tb ,
" This is an entry widget in this window that<ps/> "
" uses markup <b>like this</> for styling and<ps/> "
" formatting <em>like this</>, as well as<ps/> "
" <a href=X><link>links in the text</></a>, so enter text<ps/> "
" in here to edit it. By the way, links are<ps/> "
" called <a href=anc-02>Anchors</a> so you will need<ps/> "
" to refer to them this way.<ps/> "
" <ps/> "
" Also you can stick in items with (relsize + ascent): "
" <item relsize=16x16 vsize=ascent href=emoticon/evil-laugh></item> "
" (full) "
" <item relsize=16x16 vsize=full href=emoticon/guilty-smile></item> "
" (to the left)<ps/> "
" Also (size + ascent): "
" <item size=16x16 vsize=ascent href=emoticon/haha></item> "
" (full) "
" <item size=16x16 vsize=full href=emoticon/happy-panting></item> "
" (before this)<ps/> "
" And as well (absize + ascent): "
" <item absize=64x64 vsize=ascent href=emoticon/knowing-grin></item> "
" (full) "
" <item absize=64x64 vsize=full href=emoticon/not-impressed></item> "
" or even paths to image files on disk too like: "
" <item absize=96x128 vsize=full href=file://bla/images/sky_01.jpg></item> "
" ... end. " ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
evas_textblock_cursor_paragraph_last ( main_cur ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( fnode ) ;
2013-12-10 03:42:58 -08:00
/* The first one below used to crash: empty value.
* Test some invalid stuff doesn ' t segv . We force relayout as this will
* trigger the parser . */
evas_object_textblock_text_markup_set ( tb , " A<a=> " ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , NULL ) ;
evas_object_textblock_text_markup_set ( tb , " A<=b> " ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , NULL ) ;
evas_object_textblock_text_markup_set ( tb , " A<=> " ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , NULL ) ;
evas_object_textblock_text_markup_set ( tb , " A<a='> " ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , NULL ) ;
evas_object_textblock_text_markup_set ( tb , " A<a=' " ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , NULL ) ;
2012-11-14 12:12:53 -08:00
/* Deleting a range with just one char and surrounded by formats, that
* deletes a paragraph . */
evas_object_textblock_text_markup_set ( tb , " A<ps/><b>B</b> " ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
evas_textblock_cursor_pos_set ( main_cur , 3 ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
/* Two formats in the same place. */
evas_object_textblock_text_markup_set ( tb , " a<b><a>b</a></b>b " ) ;
evas_textblock_cursor_pos_set ( cur , 1 ) ;
evas_textblock_cursor_char_delete ( cur ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( fnode ) ;
/* Two formats across different paragraphs with notihng in between. */
evas_object_textblock_text_markup_set ( tb , " <b><ps/></b> " ) ;
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_char_delete ( cur ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( fnode ) ;
/* Try with range */
evas_object_textblock_text_markup_set ( tb , " <b><ps/></b> " ) ;
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_pos_set ( main_cur , 1 ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( fnode ) ;
2013-04-15 09:15:22 -07:00
/* Range delete with empty paragraphs. */
evas_object_textblock_text_markup_set ( tb , " <ps/><ps/><ps/><ps/><ps/> " ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
evas_textblock_cursor_pos_set ( main_cur , 3 ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
ck_assert_str_eq ( evas_object_textblock_text_markup_get ( tb ) , " <ps/><ps/><ps/><ps/> " ) ;
2013-12-13 06:37:21 -08:00
/* Range delete with item formats, TEST_CASE#1 */
evas_object_textblock_text_markup_set ( tb , " The <b>Multiline</b><item size=50x50 href=abc></item> text! " ) ;
evas_textblock_cursor_pos_set ( cur , 4 ) ;
evas_textblock_cursor_pos_set ( main_cur , 14 ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
ck_assert_str_eq ( evas_object_textblock_text_markup_get ( tb ) , " The text! " ) ;
/* Range delete with item formats, TEST_CASE#2 */
2013-12-16 04:05:47 -08:00
evas_object_textblock_text_markup_set ( tb , " The <b>Multiline</b><item size=50x50 href=abc></item> text! it is lon<item size=40x40 href=move></item>g text for test. " ) ;
2013-12-13 06:37:21 -08:00
evas_textblock_cursor_pos_set ( cur , 14 ) ;
evas_textblock_cursor_pos_set ( main_cur , 15 ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
2013-12-16 04:05:47 -08:00
ck_assert_str_eq ( evas_object_textblock_text_markup_get ( tb ) , " The <b>Multiline</b><item size=50x50 href=abc></item>text! it is lon<item size=40x40 href=move></item>g text for test. " ) ;
2013-12-13 06:37:21 -08:00
2012-11-14 12:12:53 -08:00
/* Verify fmt position and REP_CHAR positions are the same */
evas_object_textblock_text_markup_set ( tb ,
" This is<ps/>an <item absize=93x152 vsize=ascent></>a. " ) ;
evas_textblock_cursor_pos_set ( cur , 7 ) ;
evas_textblock_cursor_char_delete ( cur ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
2012-11-17 23:12:38 -08:00
/* FIXME: to fix in Evas.h */
/* fail_if(_evas_textblock_format_offset_get(fnode) != 10); */
2012-11-14 12:12:53 -08:00
/* Out of order <b><i></b></i> mixes. */
evas_object_textblock_text_markup_set ( tb , " a<b>b<i>c</b>d</i>e " ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
for ( i = 0 ; i < 2 ; i + + )
{
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + i " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - i " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
evas_textblock_cursor_char_delete ( cur ) ;
}
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
/* This time with a generic closer */
evas_object_textblock_text_markup_set ( tb , " a<b>b<i>c</b>d</>e " ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
for ( i = 0 ; i < 2 ; i + + )
{
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + i " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
evas_textblock_cursor_char_delete ( cur ) ;
}
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
/* And now with remove pair. */
evas_object_textblock_text_markup_set ( tb , " a<b>b<i>c</b>d</i>e " ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
evas_textblock_node_format_remove_pair ( tb ,
( Evas_Object_Textblock_Node_Format * ) fnode ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + i " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - i " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
/* Remove the other pair */
evas_object_textblock_text_markup_set ( tb , " a<b>b<i>c</>d</i>e " ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
evas_textblock_node_format_remove_pair ( tb ,
( Evas_Object_Textblock_Node_Format * ) fnode ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - i " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
/* Remove two pairs with the same name and same positions. */
evas_object_textblock_text_markup_set ( tb , " <a><a>A</a></a> " ) ;
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_char_delete ( cur ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( fnode ) ;
/* Try to remove a format that doesn't have a pair (with a bad mkup) */
evas_object_textblock_text_markup_set ( tb , " a<b>b<i>c</>d</i>e " ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
evas_textblock_node_format_remove_pair ( tb ,
( Evas_Object_Textblock_Node_Format * ) fnode ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + i " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - i " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
/* Testing items */
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_items )
2012-11-14 12:12:53 -08:00
{
2015-12-17 03:54:35 -08:00
Evas_Coord x , y , w , h , w2 , h2 , nw , nh , ih ;
2012-11-14 12:12:53 -08:00
START_TB_TEST ( ) ;
const char * buf = " This is an <item absize=93x152></>. " ;
/* Absolute item size */
buf = " This is an <item absize=93x152 vsize=full></>. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
2013-08-19 08:42:30 -07:00
_ck_assert_int ( w , > = , 93 ) ;
2013-08-20 05:32:03 -07:00
_ck_assert_int ( h , > = , 153 ) ;
2012-11-14 12:12:53 -08:00
evas_textblock_cursor_pos_set ( cur , 11 ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w , & h ) ;
2013-08-19 08:42:30 -07:00
ck_assert_int_eq ( w , 93 ) ;
ck_assert_int_eq ( h , 152 ) ;
2012-11-14 12:12:53 -08:00
buf = " This is an <item absize=93x152 vsize=ascent></>. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
2013-08-19 08:42:30 -07:00
_ck_assert_int ( w , > = , 93 ) ;
2013-08-20 05:32:03 -07:00
_ck_assert_int ( h , > = , 153 ) ;
2012-11-14 12:12:53 -08:00
evas_textblock_cursor_pos_set ( cur , 11 ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w , & h ) ;
2013-08-19 08:42:30 -07:00
ck_assert_int_eq ( w , 93 ) ;
ck_assert_int_eq ( h , 152 ) ;
2012-11-14 12:12:53 -08:00
/* Size is the same as abssize, unless there's scaling applied. */
buf = " This is an <item size=93x152 vsize=full></>. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
2013-08-19 08:42:30 -07:00
_ck_assert_int ( w , > = , 93 ) ;
2013-08-20 05:32:03 -07:00
_ck_assert_int ( h , > = , 153 ) ;
2012-11-14 12:12:53 -08:00
evas_textblock_cursor_pos_set ( cur , 11 ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w , & h ) ;
fail_if ( ( w ! = 93 ) | | ( h ! = 152 ) ) ;
buf = " This is an <item size=93x152 vsize=ascent></>. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
2013-08-20 03:10:50 -07:00
fail_if ( ( w < 93 ) | | ( h < = 153 ) ) ;
2012-11-14 12:12:53 -08:00
evas_textblock_cursor_pos_set ( cur , 11 ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w , & h ) ;
fail_if ( ( w ! = 93 ) | | ( h ! = 152 ) ) ;
evas_object_scale_set ( tb , 2.0 ) ;
buf = " This is an <item size=93x152 vsize=full></>. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
2013-08-20 03:10:50 -07:00
fail_if ( ( w < ( 2 * 93 ) ) | | ( h ! = ( 2 * 154 ) ) ) ;
2012-11-14 12:12:53 -08:00
evas_textblock_cursor_pos_set ( cur , 11 ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w , & h ) ;
fail_if ( ( w ! = ( 2 * 93 ) ) | | ( h ! = ( 2 * 152 ) ) ) ;
evas_textblock_cursor_pos_set ( cur , 11 ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w , & h ) ;
fail_if ( ( w ! = ( 2 * 93 ) ) | | ( h ! = ( 2 * 152 ) ) ) ;
buf = " This is an <item size=93x152 vsize=ascent></>. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
2013-08-20 03:10:50 -07:00
fail_if ( ( w < ( 2 * 93 ) ) | | ( h < = ( 2 * 154 ) ) ) ;
2012-11-14 12:12:53 -08:00
evas_textblock_cursor_pos_set ( cur , 11 ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w , & h ) ;
fail_if ( ( w ! = ( 2 * 93 ) ) | | ( h ! = ( 2 * 152 ) ) ) ;
evas_object_scale_set ( tb , 1.0 ) ;
/* Relsize */
/* relsize means it should adjust itself to the size of the line */
2013-04-11 08:00:24 -07:00
buf = " This is an <item relsize=93x152 vsize=full></>. " ;
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
2013-08-20 03:10:50 -07:00
fail_if ( ( w > = 93 ) | | ( h > = 153 ) ) ;
2012-11-14 12:12:53 -08:00
evas_textblock_cursor_pos_set ( cur , 11 ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w , & ih ) ;
2013-09-20 09:59:12 -07:00
fail_if ( ( w > 108 ) | | ( h < = ih ) ) ;
2012-11-14 12:12:53 -08:00
2013-04-11 08:00:24 -07:00
buf = " This is an <item relize=93x152 vsize=ascent></>. " ;
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
2013-04-11 08:00:24 -07:00
fail_if ( ( w > = 93 ) | | ( h > = 152 ) ) ;
2012-11-14 12:12:53 -08:00
evas_textblock_cursor_pos_set ( cur , 11 ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w , & ih ) ;
2013-04-11 09:47:51 -07:00
fail_if ( ( w > 108 ) | | ( h < = ih ) ) ;
2012-11-14 12:12:53 -08:00
/* Relsize and abs size in the same line, all should be the same size */
buf = " <item relsize=64x64 vsize=ascent href=emoticon/knowing-grin></item><item absize=64x64 vsize=ascent href=emoticon/knowing-grin></item><item relsize=64x64 vsize=ascent href=emoticon/knowing-grin></item> " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
fail_if ( ( nw ! = w ) | | ( nh ! = h ) ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w , & h ) ;
evas_textblock_cursor_char_next ( cur ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w2 , & h2 ) ;
fail_if ( ( w ! = w2 ) | | ( h ! = h2 ) ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w , & h ) ;
evas_textblock_cursor_char_next ( cur ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w2 , & h2 ) ;
fail_if ( ( w ! = w2 ) | | ( h ! = h2 ) ) ;
2014-06-10 07:17:41 -07:00
buf = " <ellipsis=1.0>a<item absize=64x64 vsize=ascent href=emoticon/knowing-grin></item></ellipsis> " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_resize ( tb , 30 , 30 ) ;
evas_textblock_cursor_pos_set ( cur , 1 ) ;
if ( evas_textblock_cursor_format_item_geometry_get ( cur , NULL , NULL , & w , & h ) )
fail_if ( ( w ! = 64 ) | | ( h ! = 64 ) ) ;
2015-12-17 03:54:35 -08:00
/* Test char coordinate for item at middle position of the item to decide cursor position,
* it means when char coordinate exceeds the half width of the item then only
* cursor position is changed . */
buf = " <item size=100x100 vsize=full></>. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_format_item_geometry_get ( cur , & x , & y , & w , NULL ) ;
evas_textblock_cursor_char_coord_set ( cur , x + ( w / 2 ) + 1 , y ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! = 1 ) ;
/* Test small increment in x and cursor position will be same */
evas_textblock_cursor_char_coord_set ( cur , x + 10 , y ) ;
fail_if ( evas_textblock_cursor_pos_get ( cur ) ! = 0 ) ;
2012-11-14 12:12:53 -08:00
/* FIXME: Also verify x,y positions of the item. */
/* FIXME We need some item tests that involve line wrapping that make the
* items move between lines that are in different sizes .
* Also , tests that involve wrapping positions with relsized items . We
* want to make sure the item gets a relsize on the correct time ( before
* the wrapping , and then is updated after the wrapping ) and that
* all the lines have the correct sizes afterwards . */
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
/* Wrapping tests */
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_wrapping )
2012-11-14 12:12:53 -08:00
{
Evas_Coord bw , bh , w , h , nw , nh ;
int i ;
START_TB_TEST ( ) ;
evas_object_textblock_text_markup_set ( tb , " a " ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
/* Char wrap */
evas_object_textblock_text_markup_set ( tb , " aaaaaaa " ) ;
evas_textblock_cursor_format_prepend ( cur , " + wrap=char " ) ;
evas_object_resize ( tb , bw , bh ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
/* Wrap to minimum */
fail_if ( w ! = bw ) ;
fail_if ( h < = bh ) ;
/* Mixed - fallback to char wrap */
evas_object_textblock_text_markup_set ( tb , " aaaaaaa " ) ;
evas_textblock_cursor_format_prepend ( cur , " + wrap=mixed " ) ;
evas_object_resize ( tb , bw , bh ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
/* Wrap to minimum */
fail_if ( w ! = bw ) ;
fail_if ( h < = bh ) ;
/* Basic Word wrap */
evas_object_textblock_text_markup_set ( tb , " aaaa " ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
evas_object_textblock_text_markup_set ( tb , " aaaa aa " ) ;
evas_textblock_cursor_format_prepend ( cur , " + wrap=word " ) ;
evas_object_resize ( tb , bw , bh ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
/* Wrap to minimum */
fail_if ( w ! = bw ) ;
fail_if ( h < = bh ) ;
/* Mixed - fallback to word wrap */
evas_object_textblock_text_markup_set ( tb , " aaaa aa " ) ;
evas_textblock_cursor_format_prepend ( cur , " + wrap=mixed " ) ;
evas_object_resize ( tb , bw + 1 , bh ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
/* Wrap to minimum */
2014-02-27 02:39:52 -08:00
ck_assert_int_eq ( w , bw ) ;
2012-11-14 12:12:53 -08:00
fail_if ( w ! = bw ) ;
fail_if ( h < = bh ) ;
/* Wrap and then expand again. */
evas_object_textblock_text_markup_set ( tb , " aaaa aa " ) ;
evas_textblock_cursor_format_prepend ( cur , " + wrap=word " ) ;
evas_object_resize ( tb , bw , bh ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
2014-02-27 02:39:52 -08:00
ck_assert_int_eq ( w , nw ) ;
ck_assert_int_eq ( h , nh ) ;
2012-11-14 12:12:53 -08:00
/* Reduce size until reaching the minimum, making sure we don't
* get something wrong along the way */
/* Char wrap */
evas_object_textblock_text_markup_set ( tb , " a " ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
evas_object_textblock_text_markup_set ( tb ,
" aaaa aaaa aaa aa aaa<ps/> "
" aaaa aaa aaa aaa aaa<ps/> "
" a aaaaa aaaaaaaaaaaaaa<br/>aaaaa<ps/> "
" aaaaaa "
) ;
evas_textblock_cursor_format_prepend ( cur , " + wrap=char " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
Evas_Coord iw ;
for ( iw = nw ; iw > = bw ; iw - - )
{
evas_object_resize ( tb , iw , 1000 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
fail_if ( w < bw ) ;
fail_if ( w > iw ) ;
}
fail_if ( w ! = bw ) ;
2014-09-26 05:14:20 -07:00
/* Verify that no empty line is added */
evas_object_textblock_text_markup_set ( tb , " <wrap=word>Hello</wrap> " ) ;
evas_object_textblock_size_native_get ( tb , NULL , & nh ) ;
evas_object_resize ( tb , 0 , 1000 ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , & h ) ;
ck_assert_int_eq ( nh , h ) ;
evas_object_textblock_text_markup_set ( tb , " <wrap=char>a</wrap> " ) ;
evas_object_textblock_size_native_get ( tb , NULL , & nh ) ;
evas_object_resize ( tb , 0 , 1000 ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , & h ) ;
ck_assert_int_eq ( nh , h ) ;
2012-11-14 12:12:53 -08:00
/* Word wrap */
evas_object_textblock_text_markup_set ( tb , " aaaaaa " ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
evas_object_textblock_text_markup_set ( tb ,
" aaaa aaaa aaa aa aaa<ps/> "
" aaaa aaa aaa aaa aaa<ps/> "
" a aaaaa aaaaaa<br/>aaaaa<ps/> "
" aaaaa "
) ;
evas_textblock_cursor_format_prepend ( cur , " + wrap=word " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
for ( iw = nw ; iw > = bw ; iw - - )
{
evas_object_resize ( tb , iw , 1000 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
fail_if ( w < bw ) ;
fail_if ( w > iw ) ;
}
fail_if ( w ! = bw ) ;
/* Mixed wrap */
evas_object_textblock_text_markup_set ( tb , " a " ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
evas_object_textblock_text_markup_set ( tb ,
" aaaa aaaa aaa aa aaa<ps/> "
" aaaa aaa aaa aaa aaa<ps/> "
" a aaaaa aaaaaa<br/>aaaaa<ps/> "
" aaaaa "
) ;
evas_textblock_cursor_format_prepend ( cur , " + wrap=mixed " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
for ( iw = nw ; iw > = bw ; iw - - )
{
evas_object_resize ( tb , iw , 1000 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
fail_if ( w < bw ) ;
fail_if ( w > iw ) ;
}
fail_if ( w ! = bw ) ;
/* Resize, making sure we keep going down in the minimum size. */
char * wrap_style [ ] = { " + wrap=word " , " + wrap=char " , " + wrap=mixed " } ;
int wrap_items = sizeof ( wrap_style ) / sizeof ( * wrap_style ) ;
evas_object_textblock_text_markup_set ( tb ,
" This is an entry widget in this window that<br/> "
" uses markup <b>like this</> for styling and<br/> "
" formatting <em>like this</>, as well as<br/> "
" <a href=X><link>links in the text</></a>, so enter text<br/> "
" in here to edit it. By the way, links are<br/> "
" called <a href=anc-02>Anchors</a> so you will need<br/> "
" to refer to them this way.<br/> "
" <br/> "
" Also you can stick in items with (relsize + ascent): "
" <item relsize=16x16 vsize=ascent href=emoticon/evil-laugh></item> "
" (full) "
" <item relsize=16x16 vsize=full href=emoticon/guilty-smile></item> "
" (to the left)<br/> "
" Also (size + ascent): "
" <item size=16x16 vsize=ascent href=emoticon/haha></item> "
" (full) "
" <item size=16x16 vsize=full href=emoticon/happy-panting></item> "
" (before this)<br/> "
" And as well (absize + ascent): "
" <item absize=64x64 vsize=ascent href=emoticon/knowing-grin></item> "
" (full) "
" <item absize=64x64 vsize=full href=emoticon/not-impressed></item> "
" or even paths to image files on disk too like: "
" <item absize=96x128 vsize=full href=file://%s/images/sky_01.jpg></item> "
" ... end. "
) ;
/* Get minimum size */
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
for ( i = 0 ; i < wrap_items ; i + + )
{
evas_textblock_cursor_format_prepend ( cur , wrap_style [ i ] ) ;
evas_object_resize ( tb , 0 , 0 ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
for ( iw = nw ; iw > = bw ; iw - - )
{
evas_object_resize ( tb , iw , 1000 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
fail_if ( w < bw ) ;
fail_if ( w > iw ) ;
}
fail_if ( w ! = bw ) ;
}
/* Ellipsis */
2014-08-20 07:46:22 -07:00
int ellip_w = 0 ;
evas_object_textblock_text_markup_set ( tb , " … " ) ;
evas_object_textblock_size_native_get ( tb , & ellip_w , NULL ) ;
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb , " aaaaaaaaaaaaaaaaaa<br/>b " ) ;
evas_textblock_cursor_format_prepend ( cur , " + ellipsis=1.0 wrap=word " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw / 2 , nh * 2 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
Evas/Textblock: add support for ellipsis values
Summary:
This enables textblock to support more values other than 1.0.
For 0 <= ellipsis < 1.0, it splits the text such that it fits the
textblock's width. The ellipsis is relatively position according to the
ellipsis value, and characters are removed also relatively.
For example, a value of 0.5 will position the ellipsis right in the
center of the textblock's width, while removing characters equally right
and left from the center.
Basic approach to this feature was to do some work before the layout
process. We calculate the expected total width of the items, and by how
much we exceed from the textblock's width. Afterwards is it just some
careful work to set the boundaries of the width we want to cut, and
deciding which characters we need to removed to fulfill this requirement.
The rest is splitting the text and visually-removing the part we
need to cut.
This is all handled before any logical lines are created, so the
_layout_par function remains almost intact. A designated _ellip_prev_it
field in the Paragraph struct instructs after which item we place the
ellipsis item, if at all.
Note that we keep the fast path for ellipsis 1.0, as heavier work needs
to be done for the other values.
Added tests to evas_suite for a range of ellipsis values.
Also, multiline is unsupported at the moment.
@feature
Test Plan: Anything that uses Evas Textblock (single-line, please)
Reviewers: tasn, id213sin, raster
CC: cedric, JackDanielZ, raster
Differential Revision: https://phab.enlightenment.org/D905
2014-05-29 07:46:45 -07:00
ck_assert_int_le ( w , ( nw / 2 ) ) ;
2014-09-02 03:42:32 -07:00
evas_object_textblock_text_markup_set ( tb , " a<b>b</b>a<b>b</b>a<b>b</b> " ) ;
evas_textblock_cursor_format_prepend ( cur , " + font_size=50 ellipsis=1.0 " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw / 2 , nh * 2 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
ck_assert_int_le ( w , ( nw / 2 ) ) ;
2017-11-05 18:29:43 -08:00
/* Vertical ellipsis when text includes "br" tags */
evas_object_textblock_text_markup_set ( tb , " AAAA<br/>BBBB<br/>CCCC<br/>DDDD<br/>EEEE<br/>FFFF<br/> " ) ;
evas_textblock_cursor_format_prepend ( cur , " + font_size=20 ellipsis=1.0 " ) ;
evas_object_resize ( tb , 500 , 500 ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
evas_object_resize ( tb , bw * 10 , bh / 2 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
ck_assert_int_le ( h , ( bh / 2 ) ) ;
2014-09-02 03:42:32 -07:00
evas_object_textblock_text_markup_set ( tb , " <item absize=100x100 href=item1></item><item absize=100x100 href=item2></item> " ) ;
evas_textblock_cursor_format_prepend ( cur , " + ellipsis=1.0 " ) ;
evas_object_resize ( tb , 101 , 100 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
ck_assert_int_le ( w , 100 ) ;
evas_object_textblock_text_markup_set ( tb , " ab " ) ;
evas_textblock_cursor_format_prepend ( cur , " + ellipsis=1.0 " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw / 2 , nh * 2 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
ck_assert_int_le ( w , ellip_w ) ;
2015-12-01 23:36:47 -08:00
/* Ellipsis test for multiple items in singleline. */
{
evas_object_resize ( tb , 500 , 500 ) ;
evas_object_textblock_text_markup_set ( tb , " ABC 한글한글 DEF " ) ;
evas_textblock_cursor_format_prepend ( cur , " + ellipsis=1.0 " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
/* Make the object's width smaller. */
for ( i = 1 ; ( nw / 5 ) < = ( nw - i ) ; i + + )
{
evas_object_resize ( tb , nw - i , nh ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
ck_assert_int_le ( bw , w ) ;
}
/* Revert the object's width to native width. */
for ( ; ( nw - i ) < = nw ; i - - )
{
evas_object_resize ( tb , nw - i , nh ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
ck_assert_int_le ( bw , w ) ;
}
/* The object resized same as native size.
* So , formatted width and native width should be same
* just like our first check . */
ck_assert_int_eq ( bw , w ) ;
}
Evas/Textblock: add support for ellipsis values
Summary:
This enables textblock to support more values other than 1.0.
For 0 <= ellipsis < 1.0, it splits the text such that it fits the
textblock's width. The ellipsis is relatively position according to the
ellipsis value, and characters are removed also relatively.
For example, a value of 0.5 will position the ellipsis right in the
center of the textblock's width, while removing characters equally right
and left from the center.
Basic approach to this feature was to do some work before the layout
process. We calculate the expected total width of the items, and by how
much we exceed from the textblock's width. Afterwards is it just some
careful work to set the boundaries of the width we want to cut, and
deciding which characters we need to removed to fulfill this requirement.
The rest is splitting the text and visually-removing the part we
need to cut.
This is all handled before any logical lines are created, so the
_layout_par function remains almost intact. A designated _ellip_prev_it
field in the Paragraph struct instructs after which item we place the
ellipsis item, if at all.
Note that we keep the fast path for ellipsis 1.0, as heavier work needs
to be done for the other values.
Added tests to evas_suite for a range of ellipsis values.
Also, multiline is unsupported at the moment.
@feature
Test Plan: Anything that uses Evas Textblock (single-line, please)
Reviewers: tasn, id213sin, raster
CC: cedric, JackDanielZ, raster
Differential Revision: https://phab.enlightenment.org/D905
2014-05-29 07:46:45 -07:00
{
double ellip ;
for ( ellip = 0.0 ; ellip < = 1.0 ; ellip = ellip + 0.1 )
{
char buf [ 128 ] ;
Evas_Coord w1 , h1 , w2 , h2 ;
sprintf ( buf , " + ellipsis=%f " , ellip ) ;
evas_object_textblock_text_markup_set ( tb , " aaaaaaaaaa " ) ;
evas_textblock_cursor_format_prepend ( cur , buf ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw / 2 , nh ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
ck_assert_int_le ( w , ( nw / 2 ) ) ;
ck_assert_int_eq ( h , nh ) ;
evas_object_textblock_text_markup_set ( tb , " aaaaaaaaaa " ) ;
evas_textblock_cursor_format_prepend ( cur , buf ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
evas_object_resize ( tb , nw / 2 , nh ) ;
evas_object_textblock_size_formatted_get ( tb , & w1 , & h1 ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_object_textblock_size_formatted_get ( tb , & w2 , & h2 ) ;
ck_assert_int_eq ( w , w2 ) ;
ck_assert_int_eq ( h , h2 ) ;
sprintf ( buf , " + ellipsis=%f " , ellip ) ;
evas_object_textblock_text_markup_set ( tb ,
" the<tab>quick brown fox "
" jumps<tab> over the<tab> lazy dog "
) ;
evas_textblock_cursor_format_prepend ( cur , buf ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw / 2 , nh ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
ck_assert_int_le ( w , ( nw / 2 ) ) ;
ck_assert_int_eq ( h , nh ) ;
}
}
2012-11-14 12:12:53 -08:00
2014-08-20 07:46:22 -07:00
evas_object_textblock_text_markup_set ( tb , " aaaaaaaaaaaaaaaaaa " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_textblock_cursor_format_prepend ( cur , " + ellipsis=1.0 wrap=char " ) ;
nw / = 3 ;
nh * = 2 ;
evas_object_resize ( tb , nw , nh ) ;
{
evas_object_textblock_line_number_geometry_get ( tb , 1 , NULL , NULL , & w , NULL ) ;
ck_assert_int_gt ( w , ellip_w ) ;
}
2013-11-25 06:38:05 -08:00
/* Word wrap ending with whites. */
evas_object_resize ( tb , 322 , 400 ) ;
evas_object_textblock_text_markup_set ( tb , " <wrap=word>This is an example text that should break at the end aaa " ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
Evas_Coord cx , cy , cw , ch ;
evas_textblock_cursor_text_prepend ( cur , " " ) ;
fail_if ( - 1 = = evas_textblock_cursor_geometry_get ( cur , & cx , & cy , & cw , & ch ,
NULL , EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
2014-02-10 06:16:48 -08:00
/* Getting whites back after wrapping. */
evas_object_resize ( tb , 1 , 1 ) ;
evas_object_textblock_text_markup_set ( tb , " <wrap=word><keyword>return</keyword> <number>0</number>;</wrap> " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
2014-02-27 02:39:52 -08:00
ck_assert_int_eq ( w , 32 ) ;
2014-03-18 07:56:57 -07:00
_ck_assert_int ( h , > = , 25 ) ;
2014-02-10 06:16:48 -08:00
evas_object_resize ( tb , 400 , 400 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
2014-03-18 07:56:57 -07:00
_ck_assert_int ( w , > = , 44 ) ;
2014-02-10 06:16:48 -08:00
ck_assert_int_eq ( h , 16 ) ;
2014-02-19 04:03:56 -08:00
/* Complex compound clusters using Devanagari. */
evas_object_resize ( tb , 0 , 0 ) ;
evas_object_textblock_text_markup_set ( tb , " <wrap=char> करेंकरेंकरेंकरेंकरेंकरें " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
fail_if ( w > h ) ; /* FIXME: Not the best test, should be more strict. */
2015-06-28 05:02:28 -07:00
evas_object_textblock_text_markup_set ( tb ,
" <wrap=none>aaa bbbbbbbbbbb ccccc</wrap><wrap=word>dddddd</wrap> " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw / 2 , nh * 4 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , NULL ) ;
ck_assert_int_le ( w , nw ) ;
2015-07-14 04:44:38 -07:00
{
int bret , ret ;
evas_object_textblock_text_markup_set ( tb ,
" <ellipsis=1.0>aaa<ps>bbb</ellipsis> " ) ;
evas_object_resize ( tb , 1 , 1 ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , NULL ) ;
evas_textblock_cursor_line_set ( cur , 1 ) ;
bret = evas_textblock_cursor_pos_get ( cur ) ;
evas_object_resize ( tb , 500 , 500 ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , NULL ) ;
evas_object_resize ( tb , 1 , 1 ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , NULL ) ;
evas_textblock_cursor_line_set ( cur , 1 ) ;
ret = evas_textblock_cursor_pos_get ( cur ) ;
ck_assert_int_eq ( bret , ret ) ;
}
2015-12-02 04:37:58 -08:00
/* Check that line wrap produces the same height values as paragraph break */
evas_object_resize ( tb , 1 , 100 ) ;
evas_object_textblock_text_markup_set ( tb , " <wrap=word>hello world " ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , & bh ) ;
evas_object_textblock_text_markup_set ( tb , " hello<ps>world " ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , & h ) ;
ck_assert_int_eq ( bh , h ) ;
2016-01-04 07:00:56 -08:00
/* Check that unnecessary ellipsis is not applied */
evas_object_textblock_text_markup_set ( tb , " This is test for ellipsis with formatted height. " ) ;
evas_textblock_cursor_format_prepend ( cur , " + wrap=mixed " ) ;
evas_object_resize ( tb , 100 , 100 ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , & bh ) ;
evas_object_resize ( tb , 100 , bh ) ;
evas_textblock_cursor_format_prepend ( cur , " + wrap=mixed ellipsis=1.0 " ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , & h ) ;
ck_assert_int_ge ( h , bh ) ;
2016-03-23 02:53:53 -07:00
/* Check char-wrapping for small items */
evas_object_textblock_text_markup_set ( tb , " x " ) ;
evas_object_textblock_size_native_get ( tb , & bw , NULL ) ;
evas_object_textblock_text_markup_set ( tb , " AxAx " ) ;
evas_textblock_cursor_format_prepend ( cur , " + wrap=char " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw - bw , nh ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , NULL ) ;
evas_object_textblock_text_markup_set ( tb , " A<color=#f00>x</color>Ax " ) ;
evas_textblock_cursor_format_prepend ( cur , " + wrap=char " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , NULL ) ;
ck_assert_int_eq ( bw , w ) ;
2016-08-01 05:52:18 -07:00
# ifdef HAVE_FRIBIDI
/* Check the ellipsis is placed at proper place
* in RTL text with formats */
evas_object_textblock_text_markup_set ( tb , " ) " ) ;
evas_object_textblock_size_native_get ( tb , & bw , NULL ) ;
bw + + ;
/* Expect to see: "...)ي" */
evas_object_textblock_text_markup_set ( tb , " ي(ي) " ) ;
evas_textblock_cursor_format_prepend ( cur , " + ellipsis=1.0 " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw - bw , nh ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , NULL ) ;
/* Expect to see: "...)ي"
* But , Evas Textblock could put ellipsis item at wrong place : " )...ي "
* Then , formatted size could be different from the case without format . */
evas_object_textblock_text_markup_set ( tb , " ي<color=#f00>(</color>ي) " ) ;
evas_textblock_cursor_format_prepend ( cur , " + ellipsis=1.0 " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , NULL ) ;
ck_assert_int_eq ( bw , w ) ;
# endif
2012-11-14 12:12:53 -08:00
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
/* Various textblock stuff */
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_various )
2012-11-14 12:12:53 -08:00
{
Evas_Coord w , h , bw , bh ;
START_TB_TEST ( ) ;
const char * buf = " This<ps/>textblock<ps/>has<ps/>a<ps/>lot<ps/>of<ps/>lines<ps/>. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
/* Move outside of the screen so it'll have to search for the correct
* paragraph and etc . */
evas_object_move ( tb , - ( w / 2 ) , - ( h / 2 ) ) ;
/* Replacement char */
evas_object_textblock_text_markup_set ( tb , " * " ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
evas_object_textblock_replace_char_set ( tb , " * " ) ;
evas_object_textblock_text_markup_set ( tb , " | " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
fail_if ( ( w ! = bw ) | | ( h ! = bh ) ) ;
/* Items have correct text node information */
2012-11-17 23:12:38 -08:00
/* FIXME: to fix in Evas.h */
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb , " " ) ;
2012-11-17 23:12:38 -08:00
/* fail_if(!_evas_textblock_check_item_node_link(tb)); */
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb , " <ps/> " ) ;
2012-11-17 23:12:38 -08:00
/* fail_if(!_evas_textblock_check_item_node_link(tb)); */
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb , " a<ps/> " ) ;
2012-11-17 23:12:38 -08:00
/* fail_if(!_evas_textblock_check_item_node_link(tb)); */
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb , " a<ps/>a " ) ;
2012-11-17 23:12:38 -08:00
/* fail_if(!_evas_textblock_check_item_node_link(tb)); */
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb , " a<ps/>a<ps/> " ) ;
2012-11-17 23:12:38 -08:00
/* fail_if(!_evas_textblock_check_item_node_link(tb)); */
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb , " a<ps/>a<ps/>a " ) ;
2012-11-17 23:12:38 -08:00
/* fail_if(!_evas_textblock_check_item_node_link(tb)); */
2012-11-14 12:12:53 -08:00
/* These shouldn't crash (although the desired outcome is not yet defined) */
evas_object_textblock_text_markup_set ( tb , "  " ) ;
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_char_delete ( cur ) ;
evas_object_textblock_text_markup_set ( tb , " \xEF \xBF \xBC " ) ;
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_char_delete ( cur ) ;
2014-11-26 00:18:49 -08:00
/* Check margins' position */
{
Evas_Coord nw , nh , lx , lw ;
evas_object_textblock_text_markup_set ( tb , " This is a test " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_object_textblock_line_number_geometry_get ( tb , 0 , & lx , NULL , & lw , NULL ) ;
ck_assert_int_eq ( lx , 0 ) ;
ck_assert_int_eq ( lx + lw , nw ) ;
evas_object_textblock_text_markup_set ( tb , " <left_margin=10 right_margin=5>This is a test</> " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_object_textblock_line_number_geometry_get ( tb , 0 , & lx , NULL , & lw , NULL ) ;
ck_assert_int_eq ( lx , 10 ) ;
ck_assert_int_eq ( lx + lw + 5 , nw ) ;
evas_object_textblock_text_markup_set ( tb , " עוד פסקה " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_object_textblock_line_number_geometry_get ( tb , 0 , & lx , NULL , & lw , NULL ) ;
ck_assert_int_eq ( lx , 0 ) ;
ck_assert_int_eq ( lx + lw , nw ) ;
evas_object_textblock_text_markup_set ( tb , " <left_margin=10 right_margin=5>עוד פסקה</> " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_object_textblock_line_number_geometry_get ( tb , 0 , & lx , NULL , & lw , NULL ) ;
ck_assert_int_eq ( lx , 10 ) ;
ck_assert_int_eq ( lx + lw + 5 , nw ) ;
}
2013-03-11 08:18:21 -07:00
/* Super big one line item. */
{
# define CNT 10000
char str [ ( CNT * 6 ) + 128 ] , * d ;
const char substr [ ] = " x " ;
Evas_Textblock_Style * stt ;
int i , l ;
l = strlen ( substr ) ;
d = str ;
for ( i = 0 ; i < CNT ; i + + )
{
memcpy ( d , substr , l ) ;
d + = l ;
}
* d = 0 ;
stt = evas_textblock_style_new ( ) ;
evas_textblock_style_set ( stt ,
2013-05-13 07:13:25 -07:00
" DEFAULT=' " TEST_FONT " font_size=10 align=left color=#000000 wrap=char' " ) ;
2013-03-11 08:18:21 -07:00
evas_object_textblock_style_set ( tb , stt ) ;
evas_textblock_style_free ( stt ) ;
evas_object_textblock_text_markup_set ( tb , substr ) ;
Evas_Textblock_Cursor * cr ;
cr = evas_object_textblock_cursor_get ( tb ) ;
evas_textblock_cursor_text_append ( cr , str ) ;
evas_object_resize ( tb , 480 , 800 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
fail_if ( w = = 0 ) ;
}
2012-11-14 12:12:53 -08:00
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
/* Various geometries. e.g. range geometry. */
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_geometries )
2012-11-14 12:12:53 -08:00
{
START_TB_TEST ( ) ;
const char * buf = " This is a <br/> test. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
/* Single line range */
Evas_Textblock_Cursor * main_cur = evas_object_textblock_cursor_get ( tb ) ;
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_pos_set ( main_cur , 6 ) ;
Eina_List * rects , * rects2 ;
Evas_Textblock_Rectangle * tr , * tr2 ;
rects = evas_textblock_cursor_range_geometry_get ( cur , main_cur ) ;
fail_if ( ! rects ) ;
rects2 = evas_textblock_cursor_range_geometry_get ( main_cur , cur ) ;
fail_if ( ! rects2 ) ;
fail_if ( eina_list_count ( rects ) ! = 1 ) ;
fail_if ( eina_list_count ( rects2 ) ! = 1 ) ;
tr = eina_list_data_get ( rects ) ;
fail_if ( ( tr - > h < = 0 ) | | ( tr - > w < = 0 ) ) ;
tr2 = eina_list_data_get ( rects2 ) ;
fail_if ( ( tr2 - > h < = 0 ) | | ( tr2 - > w < = 0 ) ) ;
fail_if ( ( tr - > x ! = tr2 - > x ) | | ( tr - > y ! = tr2 - > y ) | | ( tr - > w ! = tr2 - > w ) | |
( tr - > h ! = tr2 - > h ) ) ;
2013-02-08 07:31:25 -08:00
EINA_LIST_FREE ( rects , tr )
free ( tr ) ;
EINA_LIST_FREE ( rects2 , tr2 )
free ( tr2 ) ;
2012-11-14 12:12:53 -08:00
/* Multiline range */
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_pos_set ( main_cur , 14 ) ;
rects = evas_textblock_cursor_range_geometry_get ( cur , main_cur ) ;
fail_if ( ! rects ) ;
rects2 = evas_textblock_cursor_range_geometry_get ( main_cur , cur ) ;
fail_if ( ! rects2 ) ;
fail_if ( eina_list_count ( rects ) ! = 2 ) ;
fail_if ( eina_list_count ( rects2 ) ! = 2 ) ;
tr = eina_list_data_get ( rects ) ;
fail_if ( ( tr - > h < = 0 ) | | ( tr - > w < = 0 ) ) ;
tr2 = eina_list_data_get ( rects2 ) ;
fail_if ( ( tr2 - > h < = 0 ) | | ( tr2 - > w < = 0 ) ) ;
fail_if ( ( tr - > x ! = tr2 - > x ) | | ( tr - > y ! = tr2 - > y ) | | ( tr - > w ! = tr2 - > w ) | |
( tr - > h ! = tr2 - > h ) ) ;
tr = eina_list_data_get ( eina_list_next ( rects ) ) ;
fail_if ( ( tr - > h < = 0 ) | | ( tr - > w < = 0 ) ) ;
tr2 = eina_list_data_get ( eina_list_next ( rects2 ) ) ;
fail_if ( ( tr2 - > h < = 0 ) | | ( tr2 - > w < = 0 ) ) ;
fail_if ( ( tr - > x ! = tr2 - > x ) | | ( tr - > y ! = tr2 - > y ) | | ( tr - > w ! = tr2 - > w ) | |
( tr - > h ! = tr2 - > h ) ) ;
/* Check that the second line is positioned below the first */
tr = eina_list_data_get ( rects ) ;
tr2 = eina_list_data_get ( eina_list_next ( rects ) ) ;
fail_if ( tr - > y > = tr2 - > y ) ;
2013-02-08 07:31:25 -08:00
EINA_LIST_FREE ( rects , tr )
free ( tr ) ;
EINA_LIST_FREE ( rects2 , tr2 )
free ( tr2 ) ;
/* Same run different scripts */
2016-07-30 14:48:12 -07:00
evas_object_textblock_text_markup_set ( tb , " עברית " ) ;
evas_textblock_cursor_pos_set ( main_cur , 4 ) ; // last character
evas_textblock_cursor_pos_set ( cur , 5 ) ; // after last character
rects = evas_textblock_cursor_range_geometry_get ( cur , main_cur ) ;
fail_if ( ! rects ) ;
EINA_LIST_FREE ( rects , tr )
free ( tr ) ;
2013-02-08 07:31:25 -08:00
evas_object_textblock_text_markup_set ( tb , " עברי תenglishр у с с кийעברי ת " ) ;
evas_textblock_cursor_pos_set ( cur , 3 ) ;
evas_textblock_cursor_pos_set ( main_cur , 7 ) ;
rects = evas_textblock_cursor_range_geometry_get ( cur , main_cur ) ;
fail_if ( eina_list_count ( rects ) ! = 2 ) ;
2013-02-13 04:42:44 -08:00
EINA_LIST_FREE ( rects , tr )
free ( tr ) ;
/* Same run different styles */
evas_object_textblock_text_markup_set ( tb , " test<b>test2</b>test3 " ) ;
evas_textblock_cursor_pos_set ( cur , 3 ) ;
evas_textblock_cursor_pos_set ( main_cur , 11 ) ;
rects = evas_textblock_cursor_range_geometry_get ( cur , main_cur ) ;
fail_if ( eina_list_count ( rects ) ! = 3 ) ;
2014-01-28 09:03:07 -08:00
EINA_LIST_FREE ( rects , tr )
free ( tr ) ;
/* Bidi text with a few back and forth from bidi. */
evas_object_textblock_text_markup_set ( tb , " נגכדגךלח eountoheunth ךלחגדךכלח " ) ;
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_pos_set ( main_cur , 28 ) ;
rects = evas_textblock_cursor_range_geometry_get ( cur , main_cur ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 3 ) ;
2013-02-08 07:31:25 -08:00
EINA_LIST_FREE ( rects , tr )
free ( tr ) ;
2014-11-26 03:29:08 -08:00
/* Range simple geometry */
/* Single line range */
Eina_Iterator * it , * it2 ;
Evas_Textblock_Rectangle * tr3 ;
Evas_Coord w = 200 ;
evas_object_textblock_text_markup_set ( tb , " This <br/> is a test.<br/>Another <br/>text. " ) ;
evas_object_resize ( tb , w , w / 2 ) ;
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_pos_set ( main_cur , 3 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
it2 = evas_textblock_cursor_range_simple_geometry_get ( main_cur , cur ) ;
fail_if ( ! it2 ) ;
rects2 = eina_iterator_container_get ( it2 ) ;
fail_if ( ! rects2 ) ;
fail_if ( eina_list_count ( rects ) ! = 1 ) ;
fail_if ( eina_list_count ( rects2 ) ! = 1 ) ;
tr = eina_list_data_get ( rects ) ;
fail_if ( ( tr - > h < = 0 ) | | ( tr - > w < = 0 ) ) ;
tr2 = eina_list_data_get ( rects2 ) ;
fail_if ( ( tr - > h < = 0 ) | | ( tr - > w < = 0 ) ) ;
fail_if ( ( tr - > x ! = tr2 - > x ) | | ( tr - > y ! = tr2 - > y ) | | ( tr - > w ! = tr2 - > w ) | |
( tr - > h ! = tr2 - > h ) ) ;
eina_iterator_free ( it ) ;
eina_iterator_free ( it2 ) ;
/* Multiple range */
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_pos_set ( main_cur , 16 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
it2 = evas_textblock_cursor_range_simple_geometry_get ( main_cur , cur ) ;
fail_if ( ! it2 ) ;
rects2 = eina_iterator_container_get ( it2 ) ;
fail_if ( ! rects2 ) ;
fail_if ( eina_list_count ( rects ) ! = 3 ) ;
fail_if ( eina_list_count ( rects2 ) ! = 3 ) ;
tr = eina_list_data_get ( rects ) ;
fail_if ( ( tr - > h < = 0 ) | | ( tr - > w < = 0 ) ) ;
tr2 = eina_list_data_get ( rects2 ) ;
fail_if ( ( tr2 - > h < = 0 ) | | ( tr2 - > w < = 0 ) ) ;
fail_if ( ( tr - > x ! = tr2 - > x ) | | ( tr - > y ! = tr2 - > y ) | | ( tr - > w ! = tr2 - > w ) | |
( tr - > h ! = tr2 - > h ) ) ;
tr = eina_list_nth ( rects , 1 ) ;
fail_if ( ( tr - > h < = 0 ) | | ( tr - > w < = 0 ) ) ;
tr2 = eina_list_data_get ( eina_list_next ( rects2 ) ) ;
fail_if ( ( tr2 - > h < = 0 ) | | ( tr2 - > w < = 0 ) ) ;
fail_if ( ( tr - > x ! = tr2 - > x ) | | ( tr - > y ! = tr2 - > y ) | | ( tr - > w ! = tr2 - > w ) | |
( tr - > h ! = tr2 - > h ) ) ;
tr = eina_list_nth ( rects , 2 ) ;
fail_if ( ( tr - > h < = 0 ) | | ( tr - > w < = 0 ) ) ;
tr2 = eina_list_nth ( rects2 , 2 ) ;
fail_if ( ( tr2 - > h < = 0 ) | | ( tr2 - > w < = 0 ) ) ;
fail_if ( ( tr - > x ! = tr2 - > x ) | | ( tr - > y ! = tr2 - > y ) | | ( tr - > w ! = tr2 - > w ) | |
( tr - > h ! = tr2 - > h ) ) ;
/* Check that the second line is positioned below the first */
tr = eina_list_data_get ( rects ) ;
tr2 = eina_list_nth ( rects , 1 ) ;
tr3 = eina_list_nth ( rects , 2 ) ;
fail_if ( ( tr - > y > = tr3 - > y ) | | ( tr2 - > y > = tr3 - > y ) ) ;
fail_if ( tr2 - > x + tr2 - > w ! = w ) ;
/* Have middle rectangle */
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_pos_set ( main_cur , 31 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
it2 = evas_textblock_cursor_range_simple_geometry_get ( main_cur , cur ) ;
fail_if ( ! it2 ) ;
rects2 = eina_iterator_container_get ( it2 ) ;
fail_if ( ! rects2 ) ;
fail_if ( eina_list_count ( rects ) ! = 4 ) ;
fail_if ( eina_list_count ( rects ) ! = 4 ) ;
tr = eina_list_data_get ( rects ) ;
fail_if ( ( tr - > h < = 0 ) | | ( tr - > w < = 0 ) ) ;
tr2 = eina_list_data_get ( rects2 ) ;
fail_if ( ( tr2 - > h < = 0 ) | | ( tr2 - > w < = 0 ) ) ;
fail_if ( ( tr - > x ! = tr2 - > x ) | | ( tr - > y ! = tr2 - > y ) | | ( tr - > w ! = tr2 - > w ) | |
( tr - > h ! = tr2 - > h ) ) ;
tr = eina_list_nth ( rects , 1 ) ;
fail_if ( ( tr - > h < = 0 ) | | ( tr - > w < = 0 ) ) ;
tr2 = eina_list_nth ( rects2 , 1 ) ;
fail_if ( ( tr2 - > h < = 0 ) | | ( tr2 - > w < = 0 ) ) ;
fail_if ( ( tr - > x ! = tr2 - > x ) | | ( tr - > y ! = tr2 - > y ) | | ( tr - > w ! = tr2 - > w ) | |
( tr - > h ! = tr2 - > h ) ) ;
tr = eina_list_nth ( rects , 2 ) ;
fail_if ( ( tr - > h < = 0 ) | | ( tr - > w < = 0 ) ) ;
tr2 = eina_list_nth ( rects2 , 2 ) ;
fail_if ( ( tr2 - > h < = 0 ) | | ( tr2 - > w < = 0 ) ) ;
fail_if ( ( tr - > x ! = tr2 - > x ) | | ( tr - > y ! = tr2 - > y ) | | ( tr - > w ! = tr2 - > w ) | |
( tr - > h ! = tr2 - > h ) ) ;
tr = eina_list_nth ( rects , 3 ) ;
fail_if ( ( tr - > h < = 0 ) | | ( tr - > w < = 0 ) ) ;
tr2 = eina_list_nth ( rects2 , 3 ) ;
fail_if ( ( tr2 - > h < = 0 ) | | ( tr2 - > w < = 0 ) ) ;
fail_if ( ( tr - > x ! = tr2 - > x ) | | ( tr - > y ! = tr2 - > y ) | | ( tr - > w ! = tr2 - > w ) | |
( tr - > h ! = tr2 - > h ) ) ;
/* Check that the middle rectanlge is between first and last rectangles */
tr = eina_list_data_get ( rects ) ;
tr2 = eina_list_nth ( rects , 2 ) ;
tr3 = eina_list_nth ( rects , 3 ) ;
fail_if ( ( tr2 - > y < tr - > y + tr - > h ) | | ( tr2 - > y + tr2 - > h > tr3 - > y ) ) ;
/* Check that the middle rectangle has proper width */
tr = eina_list_data_get ( rects ) ;
tr2 = eina_list_nth ( rects , 1 ) ;
fail_if ( ( tr - > y ! = tr2 - > y ) | | ( tr - > h ! = tr2 - > h ) ) ;
tr3 = eina_list_nth ( rects , 2 ) ;
fail_if ( ( tr2 - > x + tr2 - > w ! = w ) | | ( tr2 - > x + tr2 - > w ! = tr3 - > x + tr3 - > w ) ) ;
tr2 = eina_list_nth ( rects , 2 ) ;
tr3 = eina_list_nth ( rects , 3 ) ;
fail_if ( ( tr2 - > x ! = tr3 - > x ) ) ;
eina_iterator_free ( it ) ;
eina_iterator_free ( it2 ) ;
2015-12-08 07:17:59 -08:00
/* Check number of rectangles in case a of line wrapping */
evas_object_textblock_text_markup_set ( tb , " <wrap=word>abc def <color=#0ff>ghi " ) ;
evas_object_resize ( tb , w , w / 2 ) ;
evas_textblock_cursor_pos_set ( cur , 10 ) ;
{
Evas_Coord cx ;
evas_textblock_cursor_geometry_bidi_get ( cur , & cx , NULL , NULL ,
NULL , NULL , NULL , NULL , NULL ,
EVAS_TEXTBLOCK_CURSOR_BEFORE ) ;
/* enforce wrapping of "ghi" to the next line */
evas_object_resize ( tb , cx , 400 ) ;
/* Sanity, check there is actually a second line */
fail_if ( ! evas_textblock_cursor_line_set ( cur , 1 ) ) ;
fail_if ( evas_textblock_cursor_line_set ( cur , 2 ) ) ;
}
evas_textblock_cursor_pos_set ( cur , 7 ) ;
evas_textblock_cursor_pos_set ( main_cur , 9 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
2018-11-13 23:19:30 -08:00
ck_assert_int_eq ( eina_list_count ( rects ) , 2 ) ;
2015-12-08 07:17:59 -08:00
{
2018-11-13 23:19:30 -08:00
Evas_Coord x1 , y1 , x2 , y2 ;
2015-12-08 07:17:59 -08:00
void * tmp = tr ;
2018-11-13 23:19:30 -08:00
/* We have 2 rectangles */
2015-12-08 07:17:59 -08:00
Eina_Iterator * itr = it ;
fail_if ( ! eina_iterator_next ( itr , & tmp ) ) ;
tr = tmp ;
2018-11-13 23:19:30 -08:00
x1 = tr - > x ;
2015-12-08 07:17:59 -08:00
y1 = tr - > y ;
fail_if ( ! eina_iterator_next ( itr , & tmp ) ) ;
tr = tmp ;
2018-11-13 23:19:30 -08:00
x2 = tr - > x ;
2015-12-08 07:17:59 -08:00
y2 = tr - > y ;
2018-11-13 23:19:30 -08:00
/* These rectangles must be placed without overlapping.
* In this test case , we expect to see a rect for each line . */
fail_if ( ( x1 = = x2 ) & & ( y1 = = y2 ) ) ;
ck_assert_int_ne ( y1 , y2 ) ;
2015-12-08 07:17:59 -08:00
eina_iterator_free ( it ) ;
}
/* Alignment fills */
/* LTR text */
evas_object_resize ( tb , 400 , 400 ) ;
evas_object_textblock_text_markup_set ( tb ,
" <align=0.1> "
" Hello World<ps> "
" How are you<ps> " ) ;
evas_textblock_cursor_line_set ( cur , 0 ) ;
evas_textblock_cursor_line_set ( main_cur , 1 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 3 ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
eina_iterator_free ( it ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 4 ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
eina_iterator_free ( it ) ;
evas_textblock_cursor_line_set ( main_cur , 2 ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 4 ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
eina_iterator_free ( it ) ;
/* RTL text aligned to the left */
evas_object_textblock_text_markup_set ( tb ,
" <align=left> "
" שלום עולם<ps> "
" מה שלומך " ) ;
evas_textblock_cursor_line_set ( cur , 0 ) ;
evas_textblock_cursor_line_set ( main_cur , 1 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 2 ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
eina_iterator_free ( it ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 3 ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
eina_iterator_free ( it ) ;
/* RTL text aligned to the middle */
evas_object_textblock_text_markup_set ( tb ,
" <align=middle> "
" שלום עולם<ps> "
" מה שלומך " ) ;
evas_textblock_cursor_line_set ( cur , 0 ) ;
evas_textblock_cursor_line_set ( main_cur , 1 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 3 ) ;
eina_iterator_free ( it ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 4 ) ;
eina_iterator_free ( it ) ;
evas_object_textblock_text_markup_set ( tb ,
" <align=middle> "
" שלום עולם<ps> "
" מה שלומך " ) ;
evas_textblock_cursor_line_set ( cur , 0 ) ;
evas_textblock_cursor_line_set ( main_cur , 1 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 3 ) ;
eina_iterator_free ( it ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 4 ) ;
eina_iterator_free ( it ) ;
/* Auto align RTL and LTR */
evas_object_textblock_text_markup_set ( tb ,
" Hello world<ps> "
" מה שלומך " ) ;
evas_textblock_cursor_line_set ( cur , 0 ) ;
evas_textblock_cursor_line_set ( main_cur , 1 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 2 ) ;
eina_iterator_free ( it ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 3 ) ;
eina_iterator_free ( it ) ;
2014-11-26 03:29:08 -08:00
/* Same run different scripts */
evas_object_textblock_text_markup_set ( tb , " עברי תenglishр у с с кийעברי ת " ) ;
evas_textblock_cursor_pos_set ( cur , 3 ) ;
evas_textblock_cursor_pos_set ( main_cur , 7 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
fail_if ( eina_list_count ( rects ) ! = 2 ) ;
eina_iterator_free ( it ) ;
/* Same run different styles */
evas_object_textblock_text_markup_set ( tb , " test<b>test2</b>test3 " ) ;
evas_textblock_cursor_pos_set ( cur , 3 ) ;
evas_textblock_cursor_pos_set ( main_cur , 11 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( eina_list_count ( rects ) ! = 3 ) ;
eina_iterator_free ( it ) ;
/* Bidi text with a few back and forth from bidi. */
evas_object_textblock_text_markup_set ( tb , " נגכדגךלח eountoheunth ךלחגדךכלח " ) ;
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_pos_set ( main_cur , 28 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
fail_if ( ! it ) ;
rects = eina_iterator_container_get ( it ) ;
fail_if ( ! rects ) ;
ck_assert_int_eq ( eina_list_count ( rects ) , 3 ) ;
eina_iterator_free ( it ) ;
2016-07-11 09:18:54 -07:00
/* Check trivial case with format items */
evas_object_textblock_text_markup_set ( tb , " abc<item size=32x32>efg " ) ;
evas_textblock_cursor_pos_set ( cur , 3 ) ;
evas_textblock_cursor_pos_set ( main_cur , 3 ) ;
it = evas_textblock_cursor_range_simple_geometry_get ( cur , main_cur ) ;
rects = eina_iterator_container_get ( it ) ;
ck_assert ( ! rects ) ;
eina_iterator_free ( it ) ;
2012-11-14 12:12:53 -08:00
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
/* Should handle all the text editing. */
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_editing )
2012-11-14 12:12:53 -08:00
{
START_TB_TEST ( ) ;
const char * buf = " First par.<ps/>Second par. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
Evas_Textblock_Cursor * main_cur = evas_object_textblock_cursor_get ( tb ) ;
/* Check deletion works */
/* Try deleting after the end of the textblock */
{
char * content ;
evas_textblock_cursor_paragraph_last ( cur ) ;
content = strdup ( evas_object_textblock_text_markup_get ( tb ) ) ;
evas_textblock_cursor_char_delete ( cur ) ;
fail_if ( strcmp ( content , evas_object_textblock_text_markup_get ( tb ) ) ) ;
free ( content ) ;
}
/* Delete the first char */
evas_textblock_cursor_paragraph_first ( cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) ,
" irst par.<ps/>Second par. " ) ) ;
/* Delete some arbitrary char */
evas_textblock_cursor_char_next ( cur ) ;
evas_textblock_cursor_char_next ( cur ) ;
evas_textblock_cursor_char_next ( cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) ,
" irs par.<ps/>Second par. " ) ) ;
/* Delete a range */
evas_textblock_cursor_pos_set ( main_cur , 1 ) ;
evas_textblock_cursor_pos_set ( cur , 6 ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) ,
" ir.<ps/>Second par. " ) ) ;
evas_textblock_cursor_paragraph_char_first ( main_cur ) ;
evas_textblock_cursor_paragraph_char_last ( cur ) ;
evas_textblock_cursor_char_next ( cur ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) ,
" Second par. " ) ) ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_paragraph_last ( main_cur ) ;
evas_object_textblock_text_markup_prepend ( main_cur , " Test<b>bla</b>bla. " ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
evas_textblock_cursor_paragraph_char_first ( main_cur ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) ,
" First par.<ps/> " ) ) ;
/* Merging paragraphs */
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_paragraph_char_last ( cur ) ;
evas_textblock_cursor_copy ( cur , main_cur ) ;
evas_textblock_cursor_char_delete ( cur ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
fail_if ( evas_textblock_cursor_paragraph_next ( cur ) ) ;
/* Split paragraphs */
evas_textblock_cursor_format_prepend ( cur , " ps " ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
fail_if ( ! evas_textblock_cursor_paragraph_next ( cur ) ) ;
fail_if ( evas_textblock_cursor_paragraph_next ( cur ) ) ;
/* Merge paragraphs using range deletion */
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
evas_textblock_cursor_paragraph_char_last ( cur ) ;
evas_textblock_cursor_copy ( cur , main_cur ) ;
evas_textblock_cursor_char_prev ( cur ) ;
evas_textblock_cursor_char_next ( main_cur ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
fail_if ( evas_textblock_cursor_paragraph_next ( cur ) ) ;
Evas Textblock: Don't convert <br/> to <ps/> after changing text
Summary:
It was only happened when legacy newline is enabled. By default,
legacy newline is enabled. As I know, legacy newline option has
to change textblock's internal behavior. But, it shouldn't change
the given original text. It fixes T3399.
Test Plan: A Test case is included in Evas test suite.
Reviewers: Jaehyun_Cho, z-wony, tasn, woohyun, herdsman, Blackmole, devilhorns
Subscribers: #committers, zmike, raster, cedric, jpeg
Tags: #efl
Maniphest Tasks: T3399
Differential Revision: https://phab.enlightenment.org/D3874
2018-07-02 06:17:33 -07:00
/* Test cursor range delete with <br/> tags when legacy newline is enabled.
* After deleting first < br / > tag , the second < br / > tag shouldn ' t be changed to < ps / > */
evas_object_textblock_legacy_newline_set ( tb , EINA_TRUE ) ;
evas_object_textblock_text_markup_set ( tb , " A<br/><br/>B " ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
evas_textblock_cursor_paragraph_first ( main_cur ) ;
evas_textblock_cursor_pos_set ( main_cur , 2 ) ;
ck_assert_str_eq ( evas_textblock_cursor_range_text_get ( cur , main_cur , EVAS_TEXTBLOCK_TEXT_MARKUP ) , " A<br/> " ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
ck_assert_str_eq ( evas_object_textblock_text_markup_get ( tb ) , " <br/>B " ) ;
/* Restore legacy newline disabled setting */
evas_object_textblock_legacy_newline_set ( tb , EINA_FALSE ) ;
2012-11-14 12:12:53 -08:00
{
/* Limit to 1000 iterations so we'll never get into an infinite loop,
* even if broken */
int limit = 1000 ;
evas_object_textblock_text_markup_set ( tb , " this is a test eauoeuaou<ps/>this is a test1<ps/>this is a test 3 " ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
while ( evas_textblock_cursor_pos_get ( cur ) > 0 )
{
limit - - ;
fail_if ( limit < = 0 ) ;
evas_textblock_cursor_copy ( cur , main_cur ) ;
evas_textblock_cursor_char_prev ( cur ) ;
evas_textblock_cursor_word_start ( cur ) ;
evas_textblock_cursor_range_delete ( cur , main_cur ) ;
}
}
/* Insert illegal characters inside the format. */
{
const char * content ;
evas_object_textblock_text_markup_set ( tb , " a \n " ) ;
evas_textblock_cursor_pos_set ( cur , 1 ) ;
content = evas_textblock_cursor_content_get ( cur ) ;
evas_object_textblock_text_markup_set ( tb , " a \t " ) ;
evas_textblock_cursor_pos_set ( cur , 1 ) ;
content = evas_textblock_cursor_content_get ( cur ) ;
evas_object_textblock_text_markup_set ( tb , " a \xEF \xBF \xBC " ) ;
evas_textblock_cursor_pos_set ( cur , 1 ) ;
content = evas_textblock_cursor_content_get ( cur ) ;
evas_object_textblock_text_markup_set ( tb , " a \xE2 \x80 \xA9 " ) ;
evas_textblock_cursor_pos_set ( cur , 1 ) ;
content = evas_textblock_cursor_content_get ( cur ) ;
( void ) content ;
}
/* FIXME: Also add text appending/prepending */
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
/* Text getters */
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_text_getters )
2012-11-14 12:12:53 -08:00
{
START_TB_TEST ( ) ;
const char * buf = " This is a <br/> test.<ps/> "
" טקסט בעברית<ps/>and now in english. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
fail_if ( strcmp ( evas_textblock_cursor_paragraph_text_get ( cur ) ,
" This is a <br/> test. " ) ) ;
evas_textblock_cursor_paragraph_next ( cur ) ;
fail_if ( strcmp ( evas_textblock_cursor_paragraph_text_get ( cur ) ,
" טקסט בעברית " ) ) ;
evas_textblock_cursor_paragraph_next ( cur ) ;
fail_if ( strcmp ( evas_textblock_cursor_paragraph_text_get ( cur ) ,
" and now in english. " ) ) ;
/* Range get */
2015-12-13 07:13:13 -08:00
/* If one of the given cursor is NULL, it returns NULL. */
fail_if ( evas_textblock_cursor_range_text_get ( NULL , NULL ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) ) ;
fail_if ( evas_textblock_cursor_range_text_get ( cur , NULL ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) ) ;
fail_if ( evas_textblock_cursor_range_text_get ( NULL , cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) ) ;
2012-11-14 12:12:53 -08:00
Evas_Textblock_Cursor * main_cur = evas_object_textblock_cursor_get ( tb ) ;
evas_textblock_cursor_pos_set ( main_cur , 2 ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
fail_if ( * evas_textblock_cursor_range_text_get ( main_cur , cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) ) ;
evas_textblock_cursor_pos_set ( main_cur , 2 ) ;
evas_textblock_cursor_pos_set ( cur , 6 ) ;
fail_if ( strcmp ( evas_textblock_cursor_range_text_get ( main_cur , cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) , " is i " ) ) ;
evas_textblock_cursor_pos_set ( main_cur , 5 ) ;
evas_textblock_cursor_pos_set ( cur , 14 ) ;
fail_if ( strcmp ( evas_textblock_cursor_range_text_get ( main_cur , cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) , " is a <br/> te " ) ) ;
evas_textblock_cursor_pos_set ( main_cur , 14 ) ;
evas_textblock_cursor_pos_set ( cur , 20 ) ;
fail_if ( strcmp ( evas_textblock_cursor_range_text_get ( main_cur , cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) , " st.<ps/>טק " ) ) ;
evas_textblock_cursor_pos_set ( main_cur , 14 ) ;
evas_textblock_cursor_pos_set ( cur , 32 ) ;
fail_if ( strcmp ( evas_textblock_cursor_range_text_get ( main_cur , cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) , " st.<ps/>טקסט בעברית<ps/>an " ) ) ;
/* Backward range get */
evas_textblock_cursor_pos_set ( main_cur , 2 ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
fail_if ( * evas_textblock_cursor_range_text_get ( cur , main_cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) ) ;
evas_textblock_cursor_pos_set ( main_cur , 2 ) ;
evas_textblock_cursor_pos_set ( cur , 6 ) ;
fail_if ( strcmp ( evas_textblock_cursor_range_text_get ( cur , main_cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) , " is i " ) ) ;
evas_textblock_cursor_pos_set ( main_cur , 5 ) ;
evas_textblock_cursor_pos_set ( cur , 14 ) ;
fail_if ( strcmp ( evas_textblock_cursor_range_text_get ( cur , main_cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) , " is a <br/> te " ) ) ;
evas_textblock_cursor_pos_set ( main_cur , 14 ) ;
evas_textblock_cursor_pos_set ( cur , 20 ) ;
fail_if ( strcmp ( evas_textblock_cursor_range_text_get ( cur , main_cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) , " st.<ps/>טק " ) ) ;
evas_textblock_cursor_pos_set ( main_cur , 14 ) ;
evas_textblock_cursor_pos_set ( cur , 32 ) ;
fail_if ( strcmp ( evas_textblock_cursor_range_text_get ( cur , main_cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) , " st.<ps/>טקסט בעברית<ps/>an " ) ) ;
/* Uninit cursors and other weird cases */
evas_object_textblock_clear ( tb ) ;
evas_textblock_cursor_copy ( main_cur , cur ) ;
evas_textblock_cursor_text_prepend ( main_cur , " aaa " ) ;
fail_if ( strcmp ( evas_textblock_cursor_range_text_get ( cur , main_cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) , " aaa " ) ) ;
/* Markup to plain and vice versa */
{
char * tmp , * tmp2 ;
/* Real textblock object */
tmp = evas_textblock_text_markup_to_utf8 ( tb , " <br/>aa< \n />bb< \t /> " ) ;
fail_if ( strcmp ( tmp , " \n aa \n bb \t " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( tb , tmp ) ;
fail_if ( strcmp ( tmp2 , " <br/>aa<br/>bb<tab/> " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
tmp = evas_textblock_text_markup_to_utf8 ( tb , " a<item></item> " ) ;
fail_if ( strcmp ( tmp , " a \xEF \xBF \xBC " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( tb , tmp ) ;
fail_if ( strcmp ( tmp2 , " a " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
tmp = evas_textblock_text_markup_to_utf8 ( tb , " a " ) ;
fail_if ( strcmp ( tmp , " a \xC2 \xA0 " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( tb , tmp ) ;
fail_if ( strcmp ( tmp2 , " a \xC2 \xA0 " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
tmp = evas_textblock_text_markup_to_utf8 ( tb , " a<b>b</b><more></>a " ) ;
fail_if ( strcmp ( tmp , " aba " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( tb , tmp ) ;
fail_if ( strcmp ( tmp2 , " aba " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
tmp = evas_textblock_text_markup_to_utf8 ( tb , " a&a " ) ;
fail_if ( strcmp ( tmp , " a&a " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( tb , tmp ) ;
fail_if ( strcmp ( tmp2 , " a&a " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
tmp = evas_textblock_text_markup_to_utf8 ( tb , " a<newline/>a " ) ;
fail_if ( strcmp ( tmp , " a \n a " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( tb , tmp ) ;
fail_if ( strcmp ( tmp2 , " a<br/>a " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
/* NULL textblock object */
tmp = evas_textblock_text_markup_to_utf8 ( NULL , " <br/>aa< \n />bb< \t /> " ) ;
fail_if ( strcmp ( tmp , " \n aa \n bb \t " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( NULL , tmp ) ;
fail_if ( strcmp ( tmp2 , " <br/>aa<br/>bb<tab/> " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
tmp = evas_textblock_text_markup_to_utf8 ( NULL , " a<item></item> " ) ;
fail_if ( strcmp ( tmp , " a \xEF \xBF \xBC " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( NULL , tmp ) ;
fail_if ( strcmp ( tmp2 , " a " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
tmp = evas_textblock_text_markup_to_utf8 ( NULL , " a " ) ;
fail_if ( strcmp ( tmp , " a \xC2 \xA0 " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( NULL , tmp ) ;
fail_if ( strcmp ( tmp2 , " a \xC2 \xA0 " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
tmp = evas_textblock_text_markup_to_utf8 ( NULL , " a<b>b</b><more></>a " ) ;
fail_if ( strcmp ( tmp , " aba " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( NULL , tmp ) ;
fail_if ( strcmp ( tmp2 , " aba " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
tmp = evas_textblock_text_markup_to_utf8 ( tb , " a&a " ) ;
fail_if ( strcmp ( tmp , " a&a " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( tb , tmp ) ;
fail_if ( strcmp ( tmp2 , " a&a " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
tmp = evas_textblock_text_markup_to_utf8 ( NULL , " a<newline/>a " ) ;
fail_if ( strcmp ( tmp , " aa " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( NULL , tmp ) ;
fail_if ( strcmp ( tmp2 , " aa " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
2019-05-02 07:34:04 -07:00
tmp = evas_textblock_text_markup_to_utf8 ( NULL , " <align=center>hello</align>&gt;"' " ) ;
fail_if ( strcmp ( tmp , " <align=center>hello</align>> \" \' " ) ) ;
tmp2 = evas_textblock_text_utf8_to_markup ( NULL , tmp ) ;
fail_if ( strcmp ( tmp2 , " <align=center>hello</align>&gt;"' " ) ) ;
free ( tmp2 ) ;
free ( tmp ) ;
2012-11-14 12:12:53 -08:00
}
2013-11-19 07:47:06 -08:00
/* complex markup set/get */
{
const char * text =
" This is an entry widget in this window that<ps/> "
" uses markup <b>like this</> for styling and<ps/> "
" formatting <em>like this</>, as well as<ps/> "
" <a href=X><link>links in the text</></a>, so enter text<ps/> "
" in here to edit it. By the way, links are<ps/> "
" called <a href=anc-02>Anchors</a> so you will need<ps/> "
" to refer to them this way.<ps/> "
" <ps/> "
" Also you can stick in items with (relsize + ascent): "
" <item relsize=16x16 vsize=ascent href=emoticon/evil-laugh></item> "
" (full) "
" <item relsize=16x16 vsize=full href=emoticon/guilty-smile></item> "
" (to the left)<ps/> "
" Also (size + ascent): "
" <item size=16x16 vsize=ascent href=emoticon/haha></item> "
" (full) "
" <item size=16x16 vsize=full href=emoticon/happy-panting></item> "
" (before this)<ps/> "
" And as well (absize + ascent): "
" <item absize=64x64 vsize=ascent href=emoticon/knowing-grin></item> "
" (full) "
" <item absize=64x64 vsize=full href=emoticon/not-impressed></item> "
" or even paths to image files on disk too like: "
" <item absize=96x128 vsize=full href=file://bla/images/sky_01.jpg></item> "
" ... end. " ;
evas_object_textblock_text_markup_set ( tb , text ) ;
ck_assert_str_eq ( text , evas_object_textblock_text_markup_get ( tb ) ) ;
}
2013-12-22 18:01:57 -08:00
/* complex markup range get */
{
const char * text = " Break tag tes<item size=40x40 href=a></item>t <br/>Next<br/> line with it<item size=40x40 href=i></item>em tag " ;
evas_object_textblock_text_markup_set ( tb , text ) ;
evas_textblock_cursor_pos_set ( main_cur , 14 ) ;
evas_textblock_cursor_pos_set ( cur , 37 ) ;
fail_if ( strcmp ( evas_textblock_cursor_range_text_get ( main_cur , cur ,
EVAS_TEXTBLOCK_TEXT_MARKUP ) , " </item>t <br/>Next<br/> line with it<item size=40x40 href=i></item>e " ) ) ;
}
2012-11-14 12:12:53 -08:00
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
/* Formats */
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_formats )
2012-11-14 12:12:53 -08:00
{
START_TB_TEST ( ) ;
const char * buf = " Th<b>i<font_size=15 wrap=none>s i</font_size=13>s</> a <br/> te<ps/>st<item></>. " ;
const Evas_Object_Textblock_Node_Format * fnode ;
2016-07-11 01:57:36 -07:00
Evas_Coord w , h , nw , nh ;
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb , buf ) ;
/* Walk from the start */
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" + font_size=15 wrap=none " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" - font_size=13 " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " br " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " ps " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + item " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( fnode ) ;
/* Walk backwards */
fnode = evas_textblock_node_format_last_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - " ) ) ;
fnode = evas_textblock_node_format_prev_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + item " ) ) ;
fnode = evas_textblock_node_format_prev_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " ps " ) ) ;
fnode = evas_textblock_node_format_prev_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " br " ) ) ;
fnode = evas_textblock_node_format_prev_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - " ) ) ;
fnode = evas_textblock_node_format_prev_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" - font_size=13 " ) ) ;
fnode = evas_textblock_node_format_prev_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) ,
" + font_size=15 wrap=none " ) ) ;
fnode = evas_textblock_node_format_prev_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + b " ) ) ;
fnode = evas_textblock_node_format_prev_get ( fnode ) ;
fail_if ( fnode ) ;
/* Cursor and format detection */
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
evas_textblock_cursor_at_format_set ( cur , fnode ) ;
fail_if ( evas_textblock_cursor_format_is_visible_get ( cur ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
evas_textblock_cursor_at_format_set ( cur , fnode ) ;
fail_if ( evas_textblock_cursor_format_is_visible_get ( cur ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
evas_textblock_cursor_at_format_set ( cur , fnode ) ;
fail_if ( evas_textblock_cursor_format_is_visible_get ( cur ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
evas_textblock_cursor_at_format_set ( cur , fnode ) ;
fail_if ( evas_textblock_cursor_format_is_visible_get ( cur ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
evas_textblock_cursor_at_format_set ( cur , fnode ) ;
fail_if ( ! evas_textblock_cursor_format_is_visible_get ( cur ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
evas_textblock_cursor_at_format_set ( cur , fnode ) ;
fail_if ( ! evas_textblock_cursor_format_is_visible_get ( cur ) ) ;
size_t i = 0 ;
evas_textblock_cursor_paragraph_first ( cur ) ;
do
{
switch ( i )
{
case 2 :
case 3 :
case 6 :
case 7 :
case 10 :
case 14 :
case 17 :
case 18 :
fail_if ( ! evas_textblock_cursor_is_format ( cur ) ) ;
break ;
default :
fail_if ( evas_textblock_cursor_is_format ( cur ) ) ;
fail_if ( evas_textblock_cursor_format_is_visible_get ( cur ) ) ;
break ;
}
i + + ;
}
while ( evas_textblock_cursor_char_next ( cur ) ) ;
/* Format text nodes invalidation */
{
evas_object_textblock_text_markup_set ( tb , " Test " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
evas_textblock_cursor_paragraph_first ( cur ) ;
2013-04-11 08:00:24 -07:00
evas_textblock_cursor_format_prepend ( cur , " + font_size=40 " ) ;
2012-11-14 12:12:53 -08:00
evas_object_textblock_size_formatted_get ( tb , & nw , & nh ) ;
fail_if ( ( w > = nw ) | | ( h > = nh ) ) ;
}
/* FIXME: Should extend invalidation tests. */
/* Various formats, just verify there's no seg, we can't really
* verify them visually , well , we can some of them . Possibly in the
* future we will */
evas_object_textblock_text_markup_set ( tb ,
" <font_size=40>font_size=40</><ps/> "
" <color=#F210B3FF>color=#F210B3FF</><ps/> "
" <underline=single underline_color=#A2B3C4>underline=single underline_color=#A2B3C4</><ps/> "
2015-05-27 03:14:59 -07:00
" <underline=single underline_color=#F2D006 underline_height=5.5>underline=single underline_color=#F2D006 underline_height=5.5</><ps/> "
2012-11-14 12:12:53 -08:00
" <underline=double underline_color=#F00 underline2_color=#00F>underline=double underline_color=#F00 underline2_color=#00F</><ps/> "
" <underline=dashed underline_dash_color=#0F0 underline_dash_width=2 underline_dash_gap=1>underline=dashed underline_dash_color=#0F0 underline_dash_width=2 underline_dash_gap=1</><ps/> "
" <style=outline outline_color=#F0FA>style=outline outline_color=#F0FA</><ps/> "
" <style=shadow shadow_color=#F0F>style=shadow shadow_color=#F0F</><ps/> "
" <style=glow glow_color=#BBB>style=glow glow_color=#BBB</><ps/> "
" <style=glow glow2_color=#0F0>style=glow glow2_color=#0F0</><ps/> "
" <style=glow color=#fff glow2_color=#fe87 glow_color=#f214>style=glow color=#fff glow2_color=#fe87 glow_color=#f214</><ps/> "
" <backing=on backing_color=#00F>backing=on backing_color=#00F</><ps/> "
" <strikethrough=on strikethrough_color=#FF0>strikethrough=on strikethrough_color=#FF0</><ps/> "
" <align=right>align=right</><ps/> "
" <backing=on backing_color=#F008 valign=0.0>valign=0.0</><ps/> "
" <backing=on backing_color=#0F08 tabstops=50>tabstops=< \\ t></>50</><ps/> "
" <backing=on backing_color=#00F8 linesize=40>linesize=40</><ps/> "
" <backing=on backing_color=#F0F8 linerelsize=200%>linerelsize=200%</><ps/> "
" <backing=on backing_color=#0FF8 linegap=20>linegap=20</><ps/> "
" <backing=on backing_color=#FF08 linerelgap=100%>linerelgap=100%</><ps/> " ) ;
/* Force a relayout */
evas_object_textblock_size_formatted_get ( tb , NULL , NULL ) ;
/* Removing paired formats. */
evas_object_textblock_text_markup_set ( tb , " <a>aa<b>bb</b>cc</a> " ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
evas_textblock_node_format_remove_pair ( tb , ( Evas_Object_Textblock_Node_Format * ) fnode ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + b " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - b " ) ) ;
evas_object_textblock_text_markup_set ( tb , " <a>aa<b>bb</b>cc</a> " ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
evas_textblock_node_format_remove_pair ( tb , ( Evas_Object_Textblock_Node_Format * ) fnode ) ;
fnode = evas_textblock_node_format_first_get ( tb ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + a " ) ) ;
fnode = evas_textblock_node_format_next_get ( fnode ) ;
fail_if ( ! fnode ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " - a " ) ) ;
/* Format list get */
evas_object_textblock_text_markup_set ( tb , " <a>a</>a<item>b</> "
" b<item>b</>c<a>c</> " ) ;
const Eina_List * flist = evas_textblock_node_format_list_get ( tb , " a " ) ;
const Eina_List * itr ;
EINA_LIST_FOREACH ( flist , itr , fnode )
{
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + a " ) ) ;
}
flist = evas_textblock_node_format_list_get ( tb , " item " ) ;
EINA_LIST_FOREACH ( flist , itr , fnode )
{
fail_if ( strcmp ( evas_textblock_node_format_text_get ( fnode ) , " + item " ) ) ;
}
/* Make sure we get all the types of visible formats correctly. */
evas_object_textblock_text_markup_set ( tb , " <ps/>a<br/>a<tab/>a<item></> " ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get (
evas_textblock_cursor_format_get ( cur ) ) , " ps " ) ) ;
fail_if ( strcmp ( evas_textblock_cursor_content_get ( cur ) , " <ps/> " ) ) ;
fail_if ( ! evas_textblock_cursor_format_is_visible_get ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_char_next ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_char_next ( cur ) ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get (
evas_textblock_cursor_format_get ( cur ) ) , " br " ) ) ;
fail_if ( strcmp ( evas_textblock_cursor_content_get ( cur ) , " <br/> " ) ) ;
fail_if ( ! evas_textblock_cursor_format_is_visible_get ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_char_next ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_char_next ( cur ) ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get (
evas_textblock_cursor_format_get ( cur ) ) , " tab " ) ) ;
fail_if ( strcmp ( evas_textblock_cursor_content_get ( cur ) , " <tab/> " ) ) ;
fail_if ( ! evas_textblock_cursor_format_is_visible_get ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_char_next ( cur ) ) ;
fail_if ( ! evas_textblock_cursor_char_next ( cur ) ) ;
fail_if ( strcmp ( evas_textblock_node_format_text_get (
evas_textblock_cursor_format_get ( cur ) ) , " + item " ) ) ;
fail_if ( strcmp ( evas_textblock_cursor_content_get ( cur ) , " <item> " ) ) ;
fail_if ( ! evas_textblock_cursor_format_is_visible_get ( cur ) ) ;
2013-11-19 07:36:34 -08:00
evas_object_textblock_text_markup_set ( tb , " abc<br/>def " ) ;
evas_textblock_cursor_pos_set ( cur , 3 ) ;
evas_object_textblock_text_markup_prepend ( cur , " <b></b> " ) ;
ck_assert_str_eq ( evas_object_textblock_text_markup_get ( tb ) , " abc<b></b><br/>def " ) ;
evas_object_textblock_text_markup_set ( tb , " abc<br/>def " ) ;
evas_textblock_cursor_pos_set ( cur , 2 ) ;
evas_object_textblock_text_markup_prepend ( cur , " <b></b> " ) ;
ck_assert_str_eq ( evas_object_textblock_text_markup_get ( tb ) , " ab<b></b>c<br/>def " ) ;
2014-06-04 02:14:24 -07:00
/* Ligatures cut by formats */
evas_object_textblock_text_markup_set ( tb , " f<color=#f00>i</color>f " ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , NULL ) ;
2013-11-19 07:36:34 -08:00
2016-07-11 01:57:36 -07:00
/* Scaling Line size */
evas_object_scale_set ( tb , 1.0 ) ;
evas_object_textblock_text_markup_set ( tb , " <linesize=100>Line size 100</linesize> " ) ;
evas_object_resize ( tb , 400 , 400 ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , & h ) ;
ck_assert_int_ge ( h , 100 ) ;
evas_object_scale_set ( tb , 2.0 ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , & h ) ;
ck_assert_int_ge ( h , 200 ) ;
/* Scaling Line gap */
evas_object_scale_set ( tb , 1.0 ) ;
evas_object_textblock_text_markup_set ( tb , " <linegap=100>Line gap 100</linegap> " ) ;
evas_object_resize ( tb , 50 , 400 ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , & h ) ;
ck_assert_int_ge ( h , 100 ) ;
evas_object_scale_set ( tb , 2.0 ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , & h ) ;
ck_assert_int_ge ( h , 200 ) ;
/* Restore scale */
evas_object_scale_set ( tb , 1.0 ) ;
2015-11-13 04:17:37 -08:00
/* Line gap and multi language */
{
Evas_Textblock_Style * newst ;
buf = " This is a test suite for line gap - ഈ ലൈൻ "
" വിടവ് ടെസ്റ്റ് ടെസ്റ്റ് ടെസ്റ്റ് ടെസ്റ്റ് ഒരു പരീക്ഷണ വെയര് " ;
newst = evas_textblock_style_new ( ) ;
fail_if ( ! newst ) ;
evas_textblock_style_set ( newst ,
" DEFAULT=' " TEST_FONT " font_size=10 color=#000 wrap=word linegap=50' "
" br=' \n ' "
" ps='ps' "
" tab=' \t ' " ) ;
evas_object_textblock_style_set ( tb , newst ) ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , buf ) ) ;
evas_object_resize ( tb , 400 , 400 ) ;
evas_object_textblock_size_formatted_get ( tb , NULL , & h ) ;
fail_if ( h > 150 ) ;
}
2012-11-14 12:12:53 -08:00
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
/* Different text styles, for example, shadow. */
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_style )
2012-11-14 12:12:53 -08:00
{
Evas_Coord w , h , nw , nh ;
Evas_Coord l , r , t , b ;
2017-10-14 14:29:36 -07:00
Evas_Coord bw ;
2012-11-14 12:12:53 -08:00
START_TB_TEST ( ) ;
Evas_Textblock_Style * newst ;
const char * buf = " Test<ps/>Test2<ps/>נסיון " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , buf ) ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
newst = evas_textblock_style_new ( ) ;
fail_if ( ! newst ) ;
evas_textblock_style_set ( newst ,
2013-04-11 09:47:51 -07:00
" DEFAULT=' " TEST_FONT " font_size=50 color=#000 text_class=entry' "
2012-11-14 12:12:53 -08:00
" br=' \n ' "
" ps='ps' "
" tab=' \t ' " ) ;
evas_object_textblock_style_set ( tb , newst ) ;
evas_object_textblock_size_formatted_get ( tb , & nw , & nh ) ;
fail_if ( ( w > = nw ) | | ( h > = nh ) ) ;
2014-08-05 02:26:05 -07:00
/* Style tag test */
buf = " Test <br><br/><ps><ps/><tab><tab/> " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
fail_if ( strcmp ( buf , evas_object_textblock_text_markup_get ( tb ) ) ) ;
2012-11-14 12:12:53 -08:00
/* Style padding. */
evas_object_textblock_text_markup_set ( tb , " Test " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , & t , & b ) ;
fail_if ( ( l ! = 0 ) | | ( r ! = 0 ) | | ( t ! = 0 ) | | ( b ! = 0 ) ) ;
evas_object_textblock_text_markup_set ( tb , " <style=shadow>Test</> " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , & t , & b ) ;
fail_if ( ( l ! = 0 ) | | ( r ! = 1 ) | | ( t ! = 0 ) | | ( b ! = 1 ) ) ;
evas_object_textblock_text_markup_set ( tb , " <style=outline>Test</> " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , & t , & b ) ;
fail_if ( ( l ! = 1 ) | | ( r ! = 1 ) | | ( t ! = 1 ) | | ( b ! = 1 ) ) ;
evas_object_textblock_text_markup_set ( tb , " <style=soft_outline>Test</> " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , & t , & b ) ;
fail_if ( ( l ! = 2 ) | | ( r ! = 2 ) | | ( t ! = 2 ) | | ( b ! = 2 ) ) ;
evas_object_textblock_text_markup_set ( tb , " <style=glow>Test</> " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , & t , & b ) ;
fail_if ( ( l ! = 2 ) | | ( r ! = 2 ) | | ( t ! = 2 ) | | ( b ! = 2 ) ) ;
evas_object_textblock_text_markup_set ( tb , " <style=outline_shadow>Test</> " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , & t , & b ) ;
fail_if ( ( l ! = 1 ) | | ( r ! = 2 ) | | ( t ! = 1 ) | | ( b ! = 2 ) ) ;
evas_object_textblock_text_markup_set ( tb , " <style=far_shadow>Test</> " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , & t , & b ) ;
fail_if ( ( l ! = 1 ) | | ( r ! = 2 ) | | ( t ! = 1 ) | | ( b ! = 2 ) ) ;
evas_object_textblock_text_markup_set ( tb , " <style=outline_soft_shadow>Test</> " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , & t , & b ) ;
fail_if ( ( l ! = 1 ) | | ( r ! = 3 ) | | ( t ! = 1 ) | | ( b ! = 3 ) ) ;
evas_object_textblock_text_markup_set ( tb , " <style=soft_shadow>Test</> " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , & t , & b ) ;
fail_if ( ( l ! = 1 ) | | ( r ! = 3 ) | | ( t ! = 1 ) | | ( b ! = 3 ) ) ;
evas_object_textblock_text_markup_set ( tb , " <style=far_soft_shadow>Test</> " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , & t , & b ) ;
fail_if ( ( l ! = 0 ) | | ( r ! = 4 ) | | ( t ! = 0 ) | | ( b ! = 4 ) ) ;
/* Mixed style padding */
evas_object_textblock_text_markup_set ( tb ,
" <style=far_shadow>Test</><style=far_soft_shadow>Test</> " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , & t , & b ) ;
fail_if ( ( l ! = 1 ) | | ( r ! = 4 ) | | ( t ! = 1 ) | | ( b ! = 4 ) ) ;
2014-01-09 18:15:48 -08:00
/* Multi-line padding */
{
2014-02-07 05:18:38 -08:00
Evas_Coord x [ 5 ] = { 0 } , y [ 5 ] = { 0 } , w2 [ 5 ] = { 0 } , h2 [ 5 ] = { 0 } ;
2014-01-09 18:15:48 -08:00
2014-02-07 05:18:38 -08:00
// w2, h2 should not change between test 1 and 2
2014-01-09 18:15:48 -08:00
// insets and x, y should increase by 2
// line 1 in test 2 should have same geometry as in test 1 (despite style)
evas_object_textblock_text_markup_set ( tb , " Test<br/>Test " ) ;
2014-02-07 05:18:38 -08:00
evas_object_textblock_line_number_geometry_get ( tb , 0 , & x [ 0 ] , & y [ 0 ] , & w2 [ 0 ] , & h2 [ 0 ] ) ;
evas_object_textblock_line_number_geometry_get ( tb , 1 , & x [ 1 ] , & y [ 1 ] , & w2 [ 1 ] , & h2 [ 1 ] ) ;
2014-01-09 18:15:48 -08:00
// check line 1 geometry relatively to line 0
2014-02-27 02:39:52 -08:00
ck_assert_int_eq ( w2 [ 0 ] , w2 [ 1 ] ) ;
2014-02-07 05:18:38 -08:00
fail_if ( ( x [ 0 ] ! = x [ 1 ] ) | | ( ( y [ 0 ] + h2 [ 0 ] ) ! = y [ 1 ] ) | | ( w2 [ 0 ] ! = w2 [ 1 ] ) | | ( h2 [ 0 ] ! = h2 [ 1 ] ) ) ;
2014-01-09 18:15:48 -08:00
evas_object_textblock_text_markup_set ( tb , " Test<br/><style=glow>Test</><br/>Test " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , & t , & b ) ;
2014-02-07 05:18:38 -08:00
evas_object_textblock_line_number_geometry_get ( tb , 0 , & x [ 2 ] , & y [ 2 ] , & w2 [ 2 ] , & h2 [ 2 ] ) ;
evas_object_textblock_line_number_geometry_get ( tb , 1 , & x [ 3 ] , & y [ 3 ] , & w2 [ 3 ] , & h2 [ 3 ] ) ;
evas_object_textblock_line_number_geometry_get ( tb , 2 , & x [ 4 ] , & y [ 4 ] , & w2 [ 4 ] , & h2 [ 4 ] ) ;
2014-01-09 18:15:48 -08:00
// check line 1 geometry relatively to line 0
2014-02-27 02:39:52 -08:00
fail_if ( ( x [ 2 ] ! = x [ 3 ] ) | | ( ( y [ 2 ] + h2 [ 2 ] ) ! = y [ 3 ] ) | | ( w2 [ 2 ] > w2 [ 3 ] ) | | ( h2 [ 2 ] ! = h2 [ 3 ] ) ) ;
2014-01-09 18:15:48 -08:00
// check padding is correct
fail_if ( ( x [ 2 ] ! = ( x [ 0 ] + l ) ) | | ( y [ 2 ] ! = ( y [ 0 ] + t ) ) ) ;
// line 2 should not suffer from padding in line 1, as it is globally applied
2014-02-07 05:18:38 -08:00
fail_if ( ( x [ 4 ] ! = x [ 2 ] ) | | ( ( y [ 2 ] + h2 [ 2 ] + h2 [ 3 ] ) ! = y [ 4 ] ) ) ;
2014-01-09 18:15:48 -08:00
}
2013-06-25 08:37:48 -07:00
/* No font */
evas_textblock_style_set ( newst , " DEFAULT='' " ) ;
evas_object_textblock_text_markup_set ( tb , " Test " ) ;
evas_object_textblock_size_formatted_get ( tb , & nw , & nh ) ;
ck_assert_int_eq ( nw , 0 ) ;
ck_assert_int_eq ( nw , nh ) ;
2017-10-14 12:21:54 -07:00
evas_textblock_style_set ( newst ,
" DEFAULT=' " TEST_FONT " font_size=10 color=#000 "
" style=glow text_class=entry' " ) ;
evas_object_textblock_style_set ( tb , newst ) ;
evas_object_textblock_text_markup_set ( tb , " Hello " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
evas_textblock_style_set ( newst ,
" DEFAULT=' " TEST_FONT " font_size=10 color=#000 text_class=entry' " ) ;
evas_object_textblock_style_set ( tb , newst ) ;
evas_object_textblock_text_markup_set ( tb ,
" <style=glow>Hello " ) ;
evas_object_textblock_size_formatted_get ( tb , & nw , & nh ) ;
ck_assert_int_eq ( w , nw ) ;
ck_assert_int_eq ( h , nh ) ;
2017-10-14 14:29:36 -07:00
// Ellipsis style padding
// Should be consistent if style_pad is added
evas_object_textblock_text_markup_set ( tb , " hello " ) ;
evas_object_textblock_size_native_get ( tb , & w , & h ) ;
evas_object_resize ( tb , w - 1 , 200 ) ;
evas_object_textblock_text_markup_set ( tb ,
" <ellipsis=1.0>hello " ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , NULL ) ;
evas_object_textblock_text_markup_set ( tb ,
" <ellipsis=1.0 style=glow>hello</style> " ) ;
evas_object_textblock_style_insets_get ( tb , & l , & r , NULL , NULL ) ;
// Add padding to compensate for the style
evas_object_resize ( tb , w - 1 + l + r , 200 ) ;
evas_object_textblock_size_formatted_get ( tb , & nw , & nh ) ;
ck_assert_int_eq ( nw , bw ) ;
evas textblock: update format nodes when a Evas Textblock Style is updated
Summary:
A style tag among a text has to be replcaed by its matched tag when
a format node is created. If the matched tag is changed, format nodes
should be updated.
But, if a style text for Evas Textblock Style is changed,
related format nodes are not updated without setting new text.
The patch changes to update format nodes when new style text is set.
@fix
Test Plan: Included in Evas Test Suite.
Reviewers: raster, tasn, herdsman, subodh6129, zmike
Subscribers: zmike, cedric, z-wony, Blackmole
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D4697
Committer's note: rebased.
2018-05-16 10:21:08 -07:00
evas_textblock_style_set ( newst , " DEFAULT='font=Sans font_size=30'small_size='+ font_size=10' " ) ;
evas_object_textblock_text_markup_set ( tb , " Test <small_size>SMALL</small_size> " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
ck_assert_int_gt ( w , 0 ) ;
ck_assert_int_gt ( h , 0 ) ;
evas_textblock_style_set ( newst , " DEFAULT='font=Sans font_size=30'small_size='+font_size=50' " ) ;
evas_object_textblock_size_formatted_get ( tb , & nw , & nh ) ;
ck_assert_int_gt ( nw , w ) ;
ck_assert_int_gt ( nh , h ) ;
2017-10-14 14:29:36 -07:00
2012-11-14 12:12:53 -08:00
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
2018-05-05 12:15:54 -07:00
/* Basic test for style user push/peek/pop. */
START_TEST ( evas_textblock_style_user )
{
Evas_Textblock_Style * user_st ;
START_TB_TEST ( ) ;
user_st = evas_textblock_style_new ( ) ;
fail_if ( ! user_st ) ;
evas_textblock_style_set ( user_st , " DEFAULT=' " TEST_FONT " font_size=50 color=#000' " ) ;
evas_object_textblock_style_user_push ( tb , user_st ) ;
fail_if ( evas_object_textblock_style_user_peek ( tb ) ! = user_st ) ;
evas_object_textblock_style_user_pop ( tb ) ;
fail_if ( evas_object_textblock_style_user_peek ( tb ) ! = NULL ) ;
/* new/free should be handled from outside of Evas Textblock. */
evas_textblock_style_free ( user_st ) ;
END_TB_TEST ( ) ;
}
END_TEST
2012-11-14 12:12:53 -08:00
/* Various setters and getters */
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_set_get )
2012-11-14 12:12:53 -08:00
{
START_TB_TEST ( ) ;
const char * buf = " " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
fail_if ( strcmp ( evas_textblock_style_get ( st ) , style_buf ) ) ;
fail_if ( evas_object_textblock_style_get ( tb ) ! = st ) ;
evas_object_textblock_replace_char_set ( tb , " | " ) ;
fail_if ( strcmp ( evas_object_textblock_replace_char_get ( tb ) , " | " ) ) ;
evas_object_textblock_replace_char_set ( tb , " ש " ) ;
fail_if ( strcmp ( evas_object_textblock_replace_char_get ( tb ) , " ש " ) ) ;
evas_object_textblock_valign_set ( tb , - 1.0 ) ;
fail_if ( evas_object_textblock_valign_get ( tb ) ! = 0.0 ) ;
evas_object_textblock_valign_set ( tb , 0.0 ) ;
fail_if ( evas_object_textblock_valign_get ( tb ) ! = 0.0 ) ;
evas_object_textblock_valign_set ( tb , 0.432 ) ;
fail_if ( evas_object_textblock_valign_get ( tb ) ! = 0.432 ) ;
evas_object_textblock_valign_set ( tb , 1.0 ) ;
fail_if ( evas_object_textblock_valign_get ( tb ) ! = 1.0 ) ;
evas_object_textblock_valign_set ( tb , 1.5 ) ;
fail_if ( evas_object_textblock_valign_get ( tb ) ! = 1.0 ) ;
evas_object_textblock_bidi_delimiters_set ( tb , " ,.| " ) ;
fail_if ( strcmp ( evas_object_textblock_bidi_delimiters_get ( tb ) , " ,.| " ) ) ;
evas_object_textblock_bidi_delimiters_set ( tb , " ,| " ) ;
fail_if ( strcmp ( evas_object_textblock_bidi_delimiters_get ( tb ) , " ,| " ) ) ;
evas_object_textblock_bidi_delimiters_set ( tb , NULL ) ;
fail_if ( evas_object_textblock_bidi_delimiters_get ( tb ) ) ;
evas_object_textblock_bidi_delimiters_set ( tb , " ,| " ) ;
fail_if ( strcmp ( evas_object_textblock_bidi_delimiters_get ( tb ) , " ,| " ) ) ;
/* Hinting */
evas_object_textblock_text_markup_set ( tb , " This is<ps/>a test<br/>bla " ) ;
/* Force relayout */
evas_object_textblock_size_formatted_get ( tb , NULL , NULL ) ;
evas_font_hinting_set ( evas , EVAS_FONT_HINTING_NONE ) ;
evas_font_hinting_set ( evas , EVAS_FONT_HINTING_AUTO ) ;
evas_font_hinting_set ( evas , EVAS_FONT_HINTING_BYTECODE ) ;
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
/* Aux evas stuff, such as scale. */
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_evas )
2012-11-14 12:12:53 -08:00
{
Evas_Coord w , h , sw , sh ;
START_TB_TEST ( ) ;
const char * buf = " Test " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
evas_object_scale_set ( tb , 3.0 ) ;
evas_object_textblock_size_formatted_get ( tb , & sw , & sh ) ;
fail_if ( ( sw < = w ) | | ( sh < = h ) ) ;
evas_object_scale_set ( tb , 0.5 ) ;
evas_object_textblock_size_formatted_get ( tb , & sw , & sh ) ;
fail_if ( ( sw > = w ) | | ( sh > = h ) ) ;
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
/* All the string escaping stuff */
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_escaping )
2012-11-14 12:12:53 -08:00
{
int len ;
START_TB_TEST ( ) ;
fail_if ( strcmp ( evas_textblock_escape_string_get ( " & " ) , " & " ) ) ;
fail_if ( strcmp ( evas_textblock_string_escape_get ( " & " , & len ) , " & " ) ) ;
fail_if ( len ! = 1 ) ;
fail_if ( strcmp ( evas_textblock_escape_string_get ( " · " ) , " \xc2 \xb7 " ) ) ;
fail_if ( strcmp ( evas_textblock_string_escape_get ( " \xc2 \xb7 " , & len ) ,
" · " ) ) ;
fail_if ( len ! = 2 ) ;
fail_if ( strcmp ( evas_textblock_escape_string_get ( " 👙 " ) ,
" \xF0 \x9F \x91 \x99 " ) ) ;
fail_if ( strcmp ( evas_textblock_escape_string_get ( " 👙 " ) ,
" \xF0 \x9F \x91 \x99 " ) ) ;
fail_if ( evas_textblock_escape_string_get ( " ·aa " ) ) ;
const char * tmp = " ·aa " ;
fail_if ( strcmp ( evas_textblock_escape_string_range_get ( tmp , tmp + 8 ) ,
" \xc2 \xb7 " ) ) ;
fail_if ( evas_textblock_escape_string_range_get ( tmp , tmp + 9 ) ) ;
fail_if ( evas_textblock_escape_string_range_get ( tmp , tmp + 7 ) ) ;
fail_if ( evas_textblock_escape_string_range_get ( tmp , tmp + 5 ) ) ;
const char * buf = " This · is " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
2016-02-26 01:34:36 -08:00
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , buf ) ) ;
2012-11-14 12:12:53 -08:00
buf = " This is " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
2016-02-26 01:34:36 -08:00
fail_if ( strcmp ( evas_object_textblock_text_markup_get ( tb ) , buf ) ) ;
2012-11-14 12:12:53 -08:00
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_size )
2012-11-14 12:12:53 -08:00
{
START_TB_TEST ( ) ;
Evas_Coord w , h , h2 , nw , nh ;
const char * buf = " This is a <br/> test.<br/>גם בעברית " ;
2013-08-19 09:57:37 -07:00
/* Empty textblock */
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
ck_assert_int_eq ( w , nw ) ;
ck_assert_int_eq ( h , nh ) ;
fail_if ( w ! = 0 ) ;
2012-11-14 12:12:53 -08:00
/* When wrapping is off, native size should be the same as formatted
* size */
2013-08-19 09:57:37 -07:00
evas_object_textblock_text_markup_set ( tb , buf ) ;
2012-11-14 12:12:53 -08:00
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
2013-08-19 08:42:30 -07:00
ck_assert_int_eq ( w , nw ) ;
ck_assert_int_eq ( h , nh ) ;
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb , " a<br/>a " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h2 ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
2013-08-19 08:42:30 -07:00
ck_assert_int_eq ( w , nw ) ;
ck_assert_int_eq ( h2 , nh ) ;
2012-11-14 12:12:53 -08:00
2014-10-01 08:45:10 -07:00
evas_object_textblock_text_markup_set ( tb , " /u200eאאא AAA " ) ;
evas_object_resize ( tb , 1 , 1 ) ; //force wrapping
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , nw , nh ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
ck_assert_int_eq ( w , nw ) ;
ck_assert_int_eq ( h , nh ) ;
2013-08-06 01:28:38 -07:00
/* Two lines != double the height */
fail_if ( h * 2 = = h2 ) ;
2012-11-14 12:12:53 -08:00
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
fail_if ( ( w ! = nw ) | | ( h ! = nh ) ) ;
fail_if ( w < = 0 ) ;
2014-08-06 02:40:02 -07:00
evas_object_textblock_text_markup_set ( tb , " i<b>。</b> " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
ck_assert_int_eq ( w , nw ) ;
ck_assert_int_eq ( h , nh ) ;
evas_object_textblock_text_markup_set ( tb , " 。<b>i</b> " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
ck_assert_int_eq ( w , nw ) ;
ck_assert_int_eq ( h , nh ) ;
2012-11-14 12:12:53 -08:00
/* This time with margins. */
{
Evas_Textblock_Style * newst ;
Evas_Coord oldw , oldh , oldnw , oldnh ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & oldw , & oldh ) ;
evas_object_textblock_size_native_get ( tb , & oldnw , & oldnh ) ;
newst = evas_textblock_style_new ( ) ;
fail_if ( ! newst ) ;
evas_textblock_style_set ( newst ,
" DEFAULT='left_margin=4 right_margin=4' " ) ;
evas_object_textblock_style_user_push ( tb , newst ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
fail_if ( ( w ! = oldw + 8 ) | | ( h ! = oldh ) | |
( nw ! = oldnw + 8 ) | | ( nh ! = oldnh ) ) ;
}
2014-08-20 07:03:12 -07:00
evas_object_resize ( tb , 1000 , 1000 ) ;
evas_object_textblock_text_markup_set ( tb , " \u200f Hello שלום " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , NULL ) ;
evas_object_textblock_size_native_get ( tb , & nw , NULL ) ;
ck_assert_int_eq ( nw , w ) ;
2017-05-23 02:14:57 -07:00
{
/* Check correct recalculation of sizes when some of the paragraphs
* are not dirty */
Evas_Coord bw , bh ;
evas_object_textblock_text_markup_set ( tb ,
" XXXXXXXXXXXX<ps> "
" YYY " ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
evas_textblock_cursor_text_append ( cur , " Y " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
ck_assert_int_eq ( bw , w ) ;
2017-08-29 03:05:01 -07:00
evas_object_textblock_text_markup_set ( tb ,
" XXXXXXXXXXXX<br> "
" X<ps> "
" YYY<br> " ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
evas_textblock_cursor_paragraph_last ( cur ) ;
evas_textblock_cursor_text_append ( cur , " Y " ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
ck_assert_int_eq ( bw , w ) ;
2017-05-23 02:14:57 -07:00
}
2012-11-14 12:12:53 -08:00
/* FIXME: There is a lot more to be done. */
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2012-11-14 12:12:53 -08:00
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_delete )
2014-06-17 03:09:26 -07:00
{
START_TB_TEST ( ) ;
const Evas_Object_Textblock_Node_Format * fmt ;
/* The first and the second set of commands should result in the same
* conditions for format and text nodes of the textblock object .
* Essentially , it creates the markup ' a < ps > b ' */
evas_object_textblock_text_markup_set ( tb , " ab " ) ;
fmt = evas_textblock_cursor_format_get ( cur ) ;
fail_if ( fmt ) ;
evas_textblock_cursor_pos_set ( cur , 1 ) ;
evas_object_textblock_text_markup_prepend ( cur , " <ps/> " ) ;
evas_textblock_cursor_pos_set ( cur , 1 ) ;
fmt = evas_textblock_cursor_format_get ( cur ) ;
fail_if ( ! fmt ) ;
evas_textblock_cursor_char_delete ( cur ) ;
fmt = evas_textblock_cursor_format_get ( cur ) ;
fail_if ( fmt ) ;
evas_object_textblock_text_markup_set ( tb , " ab " ) ;
fmt = evas_textblock_cursor_format_get ( cur ) ;
fail_if ( fmt ) ;
evas_textblock_cursor_pos_set ( cur , 1 ) ;
evas_object_textblock_text_markup_prepend ( cur , " <ps> " ) ;
evas_textblock_cursor_pos_set ( cur , 1 ) ;
fmt = evas_textblock_cursor_format_get ( cur ) ;
fail_if ( ! fmt ) ;
evas_textblock_cursor_char_delete ( cur ) ;
fmt = evas_textblock_cursor_format_get ( cur ) ;
fail_if ( fmt ) ;
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST ;
2014-06-17 03:09:26 -07:00
2015-07-01 08:24:31 -07:00
/* Runs x,y in [from,to] range */
static void
_obstacle_run ( Evas_Object * tb , Evas_Object * obj ,
Evas_Coord from_x , Evas_Coord to_x ,
Evas_Coord from_y , Evas_Coord to_y ,
Evas_Coord bh )
{
Evas_Coord fw , fh ;
Evas_Coord x , y ;
for ( y = from_y ; y < = to_y ; y + = 5 )
{
for ( x = from_x ; x < = to_x ; x + = 5 )
{
evas_object_move ( obj , x , y ) ;
evas_object_textblock_obstacles_update ( tb ) ;
evas_object_textblock_size_formatted_get ( tb , & fw , & fh ) ;
/* the obstacle size is large enough to assume that adding it
* will at least make the formatted height value bigger */
ck_assert_int_ge ( fh , bh ) ;
}
}
}
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_obstacle )
2015-07-01 08:24:31 -07:00
{
START_TB_TEST ( ) ;
Evas_Coord fw , fh ;
Evas_Object * rect , * rect2 , * rect3 ;
const char * buf =
" This is an example text to demonstrate the textblock object "
" with obstacle objects support. "
" Any evas object <item size=72x16></item>can register itself as an obstacle to the textblock "
2018-08-31 01:45:31 -07:00
" object. Upon registering, it affects the layout of the text in "
2015-07-01 08:24:31 -07:00
" certain situations. Usually, when the obstacle shows above the text "
" area, it will cause the layout of the text to split and move "
" parts of it, so that all text area is apparent. " ;
rect = evas_object_rectangle_add ( evas ) ;
rect2 = evas_object_rectangle_add ( evas ) ;
rect3 = evas_object_rectangle_add ( evas ) ;
evas_object_resize ( rect , 50 , 50 ) ;
evas_object_resize ( rect2 , 50 , 50 ) ;
evas_object_resize ( rect3 , 50 , 50 ) ;
2020-02-05 22:36:30 -08:00
evas_object_resize ( tb , 300 , 400 ) ;
2015-07-01 08:24:31 -07:00
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_format_prepend ( cur , " <wrap=word> " ) ;
evas_object_textblock_size_formatted_get ( tb , & fw , & fh ) ;
ck_assert ( ! evas_object_textblock_obstacle_del ( tb , rect ) ) ;
ck_assert ( evas_object_textblock_obstacle_add ( tb , rect ) ) ;
ck_assert ( ! evas_object_textblock_obstacle_add ( tb , rect ) ) ;
ck_assert ( evas_object_textblock_obstacle_add ( tb , rect2 ) ) ;
ck_assert ( evas_object_textblock_obstacle_add ( tb , rect3 ) ) ;
evas_object_show ( rect ) ;
evas_object_show ( rect2 ) ;
evas_object_show ( rect3 ) ;
2020-02-05 22:36:30 -08:00
/*check if first character after the obstacle*/
Evas_Coord cx ;
evas_textblock_cursor_char_geometry_get ( cur , & cx , NULL , NULL , NULL ) ;
ck_assert_int_eq ( cx , 50 ) ;
2015-07-01 08:24:31 -07:00
/* Compare formatted size with and without obstacle */
_obstacle_run ( tb , rect , 0 , fw , fh / 2 , fh / 2 , fh ) ;
/* Now, with bigger obstacles */
evas_object_resize ( rect , 150 , 150 ) ;
evas_object_resize ( rect3 , 300 , 300 ) ;
evas_object_hide ( rect ) ;
evas_object_textblock_obstacles_update ( tb ) ;
_obstacle_run ( tb , rect , 0 , fw , fh / 2 , fh / 2 , fh ) ;
evas_object_textblock_obstacle_del ( tb , rect ) ;
/* running with rect, now that it's not observed */
evas_textblock_cursor_format_prepend ( cur , " <wrap=mixed> " ) ;
_obstacle_run ( tb , rect , 0 , fw , fh / 2 , fh / 2 , fh ) ;
evas_object_del ( rect2 ) ;
/* running with rect again, since rect2 is deleted */
evas_textblock_cursor_format_prepend ( cur , " <wrap=char> " ) ;
_obstacle_run ( tb , rect , 0 , fw , fh / 2 , fh / 2 , fh ) ;
evas_object_del ( rect ) ;
_obstacle_run ( tb , rect3 , 0 , fw , 0 , 0 , fh ) ;
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST ;
2015-07-01 08:24:31 -07:00
evas_textblock: content fit feature
Summary:
**Content Fit Feature for Evas_Object_Textblock**
This Feature is available at **Evas **object level. And **Edje **level (where it is internally use evas functionality)
This feature will allow text block to fit its content font size to proper size to fit its area.
**Main Properties:**
Fit Modes : None=Default, Width, Height, All [Width+Height]
Fit Size Range : Contains maximum and minimum font size to be used (and in between).
Fit Step Size : Step(Jump) value when trying fonts sizes between Size_Range max and min.
Fit Size Array : Other way to resize font, where you explicitly select font sizes to be uses (for example [20, 50, 100] it will try 3 sizes only)
Text Fit feature was available in Edje but:
1- It doesn't effected by ellipsis or warping in font style (or do not handle the in right way)
2- Accuracy is not good (specially if you have fix pixel size elements (spaces,tabs,items))
3- No (Step size, Size Array) available.
Test Plan:
To check the Feature
> elementary_test
> fit
> textbock fit
You can modify all the modes and properties
These are two examples, One using Evas other uses Edje
**Evas**
```
#include <Elementary.h>
enum BUTTON{
BUTTON_MODE = 0,
BUTTON_MAX = 1,
BUTTON_MIN = 2,
BUTTON_STEP = 3,
BUTTON_ARRAY = 4,
BUTTON_CONTENT = 5,
BUTTON_STYLE = 6,
BUTTON_ALL = BUTTON_STYLE+1,
};
char* BUTTON_STR[BUTTON_ALL] ={
"MODE",
"MAX",
"MIN",
"STEP",
"ARRAY",
"CONTENT",
"STYLE",
};
char *contents[] = {
"Hello World",
"This is Line<br>THis is other Line",
"This text contains <font_size=20 color=#F00>SPECIFIC SIZE</font_size> that does not effected by fit mode"
};
char *styles[] = {
"DEFAULT='font=sans font_size=30 color=#000 wrap=mixed ellipsis=1.0'",
"DEFAULT='font=sans font_size=30 color=#000 wrap=mixed'",
"DEFAULT='font=sans font_size=30 color=#000 ellipsis=1.0'",
"DEFAULT='font=sans font_size=30 color=#000'",
};
char *styles_names[] = {
"wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>1.0</color>",
"wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>NONE</color>",
"wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>1.0</color>",
"wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>NONE</color>",
};
typedef struct _APP
{
Evas_Object *win, *box, *txtblock,*bg, *boxHor, *boxHor2;
Eo *btn[BUTTON_ALL];
Eo *lbl_status;
char * str;
unsigned int i_contnet, i_style;
} APP;
APP *app;
char * get_fit_status(Eo * textblock);
static void _btn_clicked(void *data EINA_UNUSED, Eo *obj, void *eventInfo EINA_UNUSED){
if (obj == app->btn[BUTTON_MODE])
{
unsigned int options;
evas_textblock_fit_options_get(app->txtblock, &options);
if (options == TEXTBLOCK_FIT_MODE_NONE)
evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_HEIGHT);
else if (options == TEXTBLOCK_FIT_MODE_HEIGHT)
evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_WIDTH);
else if (options == TEXTBLOCK_FIT_MODE_WIDTH)
evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_ALL);
else if (options == TEXTBLOCK_FIT_MODE_ALL)
evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_NONE);
}
else if (obj == app->btn[BUTTON_MAX])
{
unsigned int min, max;
evas_textblock_fit_size_range_get(app->txtblock, &min, &max);
max -= 5;
evas_textblock_fit_size_range_set(app->txtblock, min, max);
}
else if (obj == app->btn[BUTTON_MIN])
{
unsigned int min, max;
evas_textblock_fit_size_range_get(app->txtblock, &min, &max);
min += 5;
evas_textblock_fit_size_range_set(app->txtblock, min, max);
}
else if (obj == app->btn[BUTTON_STEP])
{
unsigned int step;
evas_textblock_fit_step_size_get(app->txtblock, &step);
step++;
evas_textblock_fit_step_size_set(app->txtblock, step);
}
else if (obj == app->btn[BUTTON_ARRAY])
{
unsigned int font_size[] = {10, 50, 100 ,150};
evas_textblock_fit_size_array_set(app->txtblock,font_size,4);
}
else if (obj == app->btn[BUTTON_CONTENT])
{
app->i_contnet++;
if(app->i_contnet>=sizeof(contents)/sizeof(char*))
app->i_contnet=0;
evas_object_textblock_text_markup_set(app->txtblock,contents[app->i_contnet]);
}
else if (obj == app->btn[BUTTON_STYLE])
{
app->i_style++;
if(app->i_style>=sizeof(styles)/sizeof(char*))
app->i_style=0;
Evas_Textblock_Style *style = evas_object_textblock_style_get(app->txtblock);
evas_textblock_style_set(style,styles[app->i_style]);
}
elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock));
}
char * get_fit_status(Eo * textblock)
{
static char status[0xFFF];
unsigned int options,min,max,step,size_array[256];
size_t size_array_len;
evas_textblock_fit_options_get(textblock,&options);
evas_textblock_fit_size_range_get(textblock,&min,&max);
evas_textblock_fit_step_size_get(textblock,&step);
evas_textblock_fit_size_array_get(textblock,NULL,&size_array_len,0);
if (size_array_len>255)
size_array_len = 255;
evas_textblock_fit_size_array_get(textblock,size_array,NULL,size_array_len);
strcpy(status,"Mode : ");
if (options == TEXTBLOCK_FIT_MODE_NONE)
strcat(status,"MODE_NONE");
else if (options == TEXTBLOCK_FIT_MODE_HEIGHT)
strcat(status,"MODE_HEIGHT");
else if (options == TEXTBLOCK_FIT_MODE_WIDTH)
strcat(status,"MODE_WIDTH");
else if (options == TEXTBLOCK_FIT_MODE_ALL)
strcat(status,"MODE_ALL");
strcat(status,"<br>");
sprintf(status + strlen(status),"Max : %d<br>",max);
sprintf(status + strlen(status),"Min : %d<br>",min);
sprintf(status + strlen(status),"Step : %d<br>",step);
sprintf(status + strlen(status),"Array : [ ");
for (size_t i = 0 ; i < 10 ; i++)
{
if(i<size_array_len)
sprintf(status + strlen(status)," %d,",size_array[i]);
}
if(10<size_array_len)
sprintf(status + strlen(status)," ... ");
sprintf(status + strlen(status)," ]");
sprintf(status + strlen(status),"<br>");
sprintf(status + strlen(status),"%s",styles_names[app->i_style]);
return status;
}
int elm_main(int argc, char **argv)
{
app = calloc(sizeof(APP), 1);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
app->win = elm_win_util_standard_add("Main", "App");
elm_win_autodel_set(app->win, EINA_TRUE);
app->box = elm_box_add(app->win);
app->boxHor = elm_box_add(app->box);
app->boxHor2 = elm_box_add(app->box);
app->txtblock = evas_object_textblock_add(app->box);
app->bg = elm_bg_add(app->box);
elm_bg_color_set(app->bg,255,255,255);
Evas_Textblock_Style *style = evas_textblock_style_new();
evas_textblock_style_set(style,styles[0]);
evas_object_textblock_style_set(app->txtblock,style);
evas_object_textblock_text_markup_set(app->txtblock,contents[0]);
elm_box_horizontal_set(app->boxHor, EINA_TRUE);
elm_box_horizontal_set(app->boxHor2, EINA_TRUE);
evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(app->txtblock);
evas_object_show(app->bg);
evas_object_show(app->box);
evas_object_show(app->boxHor);
evas_object_show(app->boxHor2);
elm_box_pack_end(app->box, app->bg);
elm_box_pack_end(app->box, app->boxHor);
elm_box_pack_end(app->box, app->boxHor2);
elm_object_content_set(app->bg,app->txtblock);
elm_win_resize_object_add(app->win, app->box);
evas_object_resize(app->win, 320, 480);
for(int i = 0 ; i < BUTTON_ALL ; i++)
{
app->btn[i] = elm_button_add(app->boxHor);
evas_object_smart_callback_add(app->btn[i], "clicked", _btn_clicked, NULL);
elm_object_text_set(app->btn[i], BUTTON_STR[i]);
elm_box_pack_end(app->boxHor, app->btn[i]);
evas_object_show(app->btn[i]);
}
app->lbl_status = elm_label_add(app->boxHor2);
elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock));
elm_box_pack_end(app->boxHor2, app->lbl_status);
evas_object_show(app->lbl_status);
evas_object_size_hint_weight_set(app->txtblock, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(app->txtblock, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(app->bg, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(app->bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(app->win);
elm_run();
return 0;
}
ELM_MAIN()
```
**Edje**
```
// compile: edje_cc source.edc
// run: edje_player source.edje
collections {
styles
{
style
{
name: "text_style";
base: "font=sans font_size=30 color=#FFF wrap=mixed ellipsis=1.0";
tag: "br" "\n";
tag: "ps" "ps";
tag: "tab" "\t";
tag: "b" "+ font_weight=Bold";
}
}
group {
name: "my_group"; // must be the same as in source.c
parts {
part
{
name: "background";
type: RECT;
scale: 1;
description
{
color: 0 0 0 0;
rel1.relative: 0.0 0.0;
rel2.relative: 1.0 1.0;
}
}
part
{
name: "text";
type: TEXTBLOCK;
scale: 1;
entry_mode: NONE;
effect: OUTLINE_SHADOW;
description
{
state: "default" 0.0;
rel1.to : "background";
rel1.relative: 0.0 0.0;
rel2.to : "background";
rel2.relative: 1.0 1.0;
text
{
style: "text_style";
align: 0.0 0.0;
text: "Hello World This is Me";
fit: 1 1;
fit_step: 1;
size_range: 30 200;
//fit_size_array: 20 40 60 80 100 200;
}
}
}
}
}
}
```
Found Task T5724 relative to this Feature
Reviewers: woohyun, bowonryu, cedric, raster
Reviewed By: woohyun
Subscribers: a.srour, #committers, #reviewers, cedric
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D9280
2019-12-11 21:22:45 -08:00
EFL_START_TEST ( evas_textblock_fit )
{
START_TB_TEST ( ) ;
Evas_Coord fw , fh , fw_new , fh_new ;
int n_ret ;
const char * buf =
" This is an example text to demonstrate the textblock object "
" with content fit feature. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_resize ( tb , 300 , 300 ) ;
evas_object_textblock_size_formatted_get ( tb , & fw , & fh ) ;
n_ret = evas_textblock_fit_options_set ( tb , TEXTBLOCK_FIT_MODE_ALL ) ;
fail_if ( n_ret ! = EVAS_ERROR_SUCCESS ) ;
n_ret = evas_textblock_fit_size_range_set ( tb , 1 , 50 ) ;
fail_if ( n_ret ! = EVAS_ERROR_SUCCESS ) ;
evas_object_textblock_size_formatted_get ( tb , & fw_new , & fh_new ) ;
fail_if ( fw_new = = fw & & fh_new = = fh ) ;
unsigned int size_array [ 3 ] = { 150 , 200 , 250 } ;
n_ret = evas_textblock_fit_size_array_set ( tb , size_array , 3 ) ;
fail_if ( n_ret ! = EVAS_ERROR_SUCCESS ) ;
evas_object_textblock_size_formatted_get ( tb , & fw , & fh ) ;
fail_if ( fw_new = = fw & & fh_new = = fh ) ;
END_TB_TEST ( ) ;
}
EFL_END_TEST ;
2016-02-12 04:12:00 -08:00
# ifdef HAVE_HYPHEN
2015-11-11 23:49:08 -08:00
static void
_hyphenation_width_stress ( Evas_Object * tb , Evas_Textblock_Cursor * cur )
{
Evas_Coord bw , bh , iw , nw , nh , w , h ;
evas_object_resize ( tb , 100000 , 1000 ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
evas_object_resize ( tb , 1 , 1000 ) ;
evas_textblock_cursor_format_prepend ( cur , " <wrap=mixed> " ) ;
evas_object_textblock_size_formatted_get ( tb , & bw , & bh ) ;
evas_textblock_cursor_format_prepend ( cur , " <wrap=hyphenation> " ) ;
for ( iw = nw ; iw > = bw ; iw - - )
{
evas_object_resize ( tb , iw , 1000 ) ;
evas_object_textblock_size_formatted_get ( tb , & w , & h ) ;
ck_assert_int_ge ( w , bw ) ;
ck_assert_int_le ( w , iw ) ;
}
ck_assert_int_eq ( w , bw ) ;
}
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_hyphenation )
2015-11-11 23:49:08 -08:00
{
START_TB_TEST ( ) ;
2016-04-08 03:17:51 -07:00
Evas_Coord w , fw ;
const char * buf = " Automati- " ;
2018-11-15 14:29:32 -08:00
setenv ( " EVAS_DICTS_HYPHEN_DIR " , TESTS_DIC_DIR , 1 ) ;
2016-04-08 03:17:51 -07:00
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , NULL ) ;
evas_object_resize ( tb , w , 100 ) ;
setlocale ( LC_MESSAGES , " en_US.UTF-8 " ) ;
/* Language should be reinitialized after calling setlocale(). */
evas_language_reinit ( ) ;
buf = " Automatically " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_format_prepend ( cur , " <wrap=hyphenation> " ) ;
evas_object_textblock_size_formatted_get ( tb , & fw , NULL ) ;
ck_assert_int_eq ( w , fw ) ;
/* Restore locale */
setlocale ( LC_MESSAGES , " C " ) ;
evas_language_reinit ( ) ;
2015-11-11 23:49:08 -08:00
/* SHY-HYPHEN (­) */
/* Note: placing ­ in a ligature is errornuos, so for the sake
* of this test , it was removed from the " officia " word */
2016-04-08 03:17:51 -07:00
buf =
2015-11-11 23:49:08 -08:00
" Lorem ipsum dolor sit amet, cons­ectetur adipisicing elit, "
" sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
" Ut enim ad minim veniam, quis nostrud exer­citation ullamco "
" laboris nisi ut aliquip ex ea com­modo consequat. Duis aute "
" irure dolor in repre­henderit in voluptate velit esse cillum "
" dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat "
" non proident, sunt in culpa qui oficia deserunt mollit anim "
" id est lab­orum. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
/* Dictionary + locale fallback (en_US) */
2016-04-08 03:17:51 -07:00
setlocale ( LC_MESSAGES , " en_US.UTF-8 " ) ;
evas_language_reinit ( ) ;
2015-11-11 23:49:08 -08:00
/* Mixture of Dictionary with SHY-HYPHEN */
_hyphenation_width_stress ( tb , cur ) ;
/* Just dictionary */
buf =
" Lorem ipsum dolor sit amet, consectetur adipisicing elit, "
" sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
" Ut enim ad minim veniam, quis nostrud exercitation ullamco "
" laboris nisi ut aliquip ex ea commodo consequat. Duis aute "
" irure dolor in reprehenderit in voluptate velit esse cillum "
" dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat "
" non proident, sunt in culpa qui oficia deserunt mollit anim "
" id est laborum. " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
_hyphenation_width_stress ( tb , cur ) ;
Evas textblock: fix wrong hyphenation issues with non UTF8 encoded dictionary
Summary:
hnj_hyphen_hyphenate2() needs properly encoded text based on the given
dictionary. Each dictionary contains its encoding information at the head
of file. So, text will be converted to proper encoding before calling
the function. It fixes T3221.
@fix
Test Plan: Included in Evas test suite.
Reviewers: z-wony, tasn, woohyun, herdsman, Blackmole, minudf
Subscribers: zmike, stefan_schmidt, raster, cedric, jpeg
Tags: #efl
Maniphest Tasks: T3221
Differential Revision: https://phab.enlightenment.org/D3863
2018-05-06 00:24:58 -07:00
buf = " europäi- " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_object_textblock_size_formatted_get ( tb , & w , NULL ) ;
buf = " europäischen " ;
evas_object_textblock_text_markup_set ( tb , buf ) ;
evas_textblock_cursor_format_prepend ( cur , " <wrap=hyphenation lang=de_DE> " ) ;
evas_object_resize ( tb , w , 100 ) ;
evas_object_textblock_size_formatted_get ( tb , & fw , NULL ) ;
ck_assert_int_eq ( w , fw ) ;
unsetenv ( " EVAS_DICTS_HYPHEN_DIR " ) ;
2015-11-11 23:49:08 -08:00
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST ;
2016-02-12 04:12:00 -08:00
# endif
2015-11-11 23:49:08 -08:00
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_text_iface )
2016-05-24 06:11:03 -07:00
{
START_TB_TEST ( ) ;
Evas_Coord nw , nh ;
Evas_Coord bw , bh ;
Evas_Coord w , h ;
const char * utf8 ;
/* Set text */
efl_text_set ( tb , " hello world " ) ;
evas_object_textblock_size_native_get ( tb , & bw , & bh ) ;
efl_text_set ( tb , " hello \n world " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
ck_assert_int_gt ( nh , bh ) ;
ck_assert_int_gt ( bw , nw ) ;
efl_text_set ( tb , " hello \n world \n goodbye \n world " ) ;
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
ck_assert_int_ge ( nh , bh * 3 ) ;
/* Delete text */
efl_text_set ( tb , " a " ) ;
evas_object_textblock_size_native_get ( tb , & bw , & bh ) ;
efl_text_set ( tb , " a \n b " ) ;
2016-06-05 05:44:03 -07:00
evas_textblock_cursor_pos_set ( cur , 1 ) ;
evas_textblock_cursor_char_delete ( cur ) ;
2016-05-24 06:11:03 -07:00
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
ck_assert_int_eq ( nh , bh ) ;
/* Paragraph checks */
efl_text_set ( tb , " d " ) ;
evas_object_textblock_size_native_get ( tb , & w , & h ) ;
efl_text_set ( tb , " aa \n b \n c \n d " ) ;
evas_object_textblock_size_native_get ( tb , & bw , & bh ) ;
2016-06-05 05:44:03 -07:00
evas_textblock_cursor_pos_set ( cur , 0 ) ;
evas_textblock_cursor_char_delete ( cur ) ; // delete 'a'
2016-05-24 06:11:03 -07:00
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
ck_assert_int_eq ( nh , bh ) ;
2016-06-05 05:44:03 -07:00
evas_textblock_cursor_char_delete ( cur ) ; // delete 'a'
evas_textblock_cursor_char_delete ( cur ) ; // delete '\n'
2016-05-24 06:11:03 -07:00
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
ck_assert_int_lt ( nh , bh ) ;
/* "b\nc\nd" is left */
2016-06-05 05:44:03 -07:00
evas_textblock_cursor_char_delete ( cur ) ; // b
evas_textblock_cursor_char_delete ( cur ) ; // \n
evas_textblock_cursor_char_delete ( cur ) ; // c
evas_textblock_cursor_char_delete ( cur ) ; // \n
2016-05-24 06:11:03 -07:00
/* expecting "d" only */
evas_object_textblock_size_native_get ( tb , & nw , & nh ) ;
ck_assert_int_eq ( nh , h ) ;
ck_assert_int_eq ( nw , w ) ;
/* Text get */
utf8 = " a " ;
efl_text_set ( tb , utf8 ) ;
ck_assert_str_eq ( utf8 , efl_text_get ( tb ) ) ;
utf8 = " a \n b " ;
efl_text_set ( tb , utf8 ) ;
ck_assert_str_eq ( utf8 , efl_text_get ( tb ) ) ;
utf8 = " a \u2029 b " ;
efl_text_set ( tb , utf8 ) ;
ck_assert_str_eq ( utf8 , efl_text_get ( tb ) ) ;
utf8 = " a \u2029 bc \n def \n \u2029 " ;
efl_text_set ( tb , utf8 ) ;
ck_assert_str_eq ( utf8 , efl_text_get ( tb ) ) ;
utf8 = " \u2029 \n \n \n \n \u2029 \n \u2029 \n \n \n " ;
efl_text_set ( tb , utf8 ) ;
ck_assert_str_eq ( utf8 , efl_text_get ( tb ) ) ;
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST ;
2016-05-24 06:11:03 -07:00
# define _COMP_STR(...) ((const char *[]) { __VA_ARGS__ })
# define _CREATE_PARAMS(X) (sizeof(X) / sizeof(X[0])), (X)
# define _COMP_PARAMS(...) _CREATE_PARAMS(_COMP_STR(__VA_ARGS__))
2018-03-26 11:19:28 -07:00
EFL_START_TEST ( evas_textblock_annotation )
2016-05-24 06:11:03 -07:00
{
START_TB_TEST ( ) ;
2020-04-07 04:11:13 -07:00
Efl_Text_Cursor_Object * start , * end ;
2016-05-24 06:11:03 -07:00
2019-12-10 00:39:59 -08:00
start = efl_canvas_textblock_cursor_create ( tb ) ;
end = efl_canvas_textblock_cursor_create ( tb ) ;
2016-05-24 06:11:03 -07:00
const char * buf =
" This text will check annotation. "
" By \" annotating \" the text, we can apply formatting simply by "
" specifying a range (start, end) in the text, and the format we want "
" for it. "
;
efl_text_set ( tb , buf ) ;
/* Check some trivial cases */
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( start , 0 ) ;
efl_text_cursor_object_position_set ( end , 3 ) ;
2019-12-20 03:35:13 -08:00
efl_text_formatter_attribute_insert ( start , end , " font_size=80 " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( start , 1 ) ;
efl_text_cursor_object_position_set ( end , 2 ) ;
2019-12-20 03:35:13 -08:00
efl_text_formatter_attribute_insert ( start , end , " font=arial " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( start , 2 ) ;
efl_text_cursor_object_position_set ( end , 3 ) ;
2019-12-20 03:35:13 -08:00
efl_text_formatter_attribute_insert ( start , end , " color=#fff " ) ;
Efl.Text.Attribute_Factory
Summary:
Implementation of new Efl.Text.Attribute_Factory class which replace the annotation interface.
Currently, we have two public methods:
```
void efl_text_attribute_factory_attribute_insert(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end, const char *format)
unsigned int efl_text_attribute_factory_attribute_clear(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end);
```
Other methods will be internal methods, for the time being, we will redesign internal methods
Reviewers: woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Subscribers: zmike, q66, cedric, segfaultxavi, bu5hm4n, a.srour, #committers, #reviewers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10646
2019-11-26 20:04:31 -08:00
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( start , 0 ) ;
efl_text_cursor_object_position_set ( end , 3 ) ;
2019-12-20 03:35:13 -08:00
unsigned int count = efl_text_formatter_attribute_clear ( start , end ) ;
Efl.Text.Attribute_Factory
Summary:
Implementation of new Efl.Text.Attribute_Factory class which replace the annotation interface.
Currently, we have two public methods:
```
void efl_text_attribute_factory_attribute_insert(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end, const char *format)
unsigned int efl_text_attribute_factory_attribute_clear(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end);
```
Other methods will be internal methods, for the time being, we will redesign internal methods
Reviewers: woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Subscribers: zmike, q66, cedric, segfaultxavi, bu5hm4n, a.srour, #committers, #reviewers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10646
2019-11-26 20:04:31 -08:00
fail_if ( count ! = 3 ) ;
2016-05-24 06:11:03 -07:00
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST ;
2016-05-24 06:11:03 -07:00
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
static const char * efl_style_buf =
" " TEST_FONT " font_size=10 color=#000 text_class=entry " ;
2019-12-10 00:39:59 -08:00
# define START_EFL_CANVAS_TEXTBLOCK_TEST() \
2018-05-16 10:56:27 -07:00
Evas * evas ; \
Eo * txt ; \
Efl.Text.Cursor
Summary:
Implementation of new cursor text object.
This Patch Contains :
1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor
=> there are some modifications on cursor methods
2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces
3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory
4- Add main cursor property into efl.text.interactive
5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface)
There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement.
```
enum @beta Efl.Text.Cursor_Move_Type
{
[[Text cursor movement types]]
char_next, [[Advances to the next character]]
char_prev, [[Advances to the previous character]]
cluster_next, [[Advances to the next grapheme cluster]]
cluster_prev, [[Advances to the previous grapheme cluster]]
paragraph_start, [[Advances to the first character in this paragraph]]
paragraph_end, [[Advances to the last character in this paragraph]]
word_start, [[Advance to current word start]]
word_end, [[Advance to current word end]]
line_start, [[Advance to current line first character]]
line_end, [[Advance to current line last character]]
paragraph_first, [[Advance to current paragraph first character]]
paragraph_last, [[Advance to current paragraph last character]]
paragraph_next, [[Advances to the start of the next text node]]
paragraph_prev [[Advances to the end of the previous text node]]
}
move {
[[Move the cursor]]
params {
@in type: Efl.Text.Cursor_Move_Type; [[The type of movement]]
}
return: bool; [[True if actually moved]]
}
```
or old way:
```
char_next {
[[Advances to the next character]]
// FIXME: Make the number of characters we moved by? Useful for all the other functions
return: bool; [[True if actually moved]]
}
char_prev {
[[Advances to the previous character]]
return: bool; [[True if actually moved]]
}
char_delete {
[[Deletes a single character from position pointed by given cursor.]]
}
cluster_next {
[[Advances to the next grapheme cluster]]
return: bool; [[True if actually moved]]
}
cluster_prev {
[[Advances to the previous grapheme cluster]]
return: bool; [[True if actually moved]]
}
// FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character.
paragraph_start {
[[Advances to the first character in this paragraph]]
return: bool; [[True if actually moved]]
}
paragraph_end {
[[Advances to the last character in this paragraph]]
return: bool; [[True if actually moved]]
}
word_start {
[[Advance to current word start]]
return: bool; [[True if actually moved]]
}
word_end {
[[Advance to current word end]]
return: bool; [[True if actually moved]]
}
line_start {
[[Advance to current line first character]]
return: bool; [[True if actually moved]]
}
line_end {
[[Advance to current line last character]]
return: bool; [[True if actually moved]]
}
paragraph_first {
[[Advance to current paragraph first character]]
return: bool; [[True if actually moved]]
}
paragraph_last {
[[Advance to current paragraph last character]]
return: bool; [[True if actually moved]]
}
paragraph_next {
[[Advances to the start of the next text node]]
return: bool; [[True if actually moved]]
}
paragraph_prev {
[[Advances to the end of the previous text node]]
return: bool; [[True if actually moved]]
}
```
Reviewers: woohyun, tasn, segfaultxavi
Reviewed By: woohyun
Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
Efl_Text_Cursor_Handle * cur ; \
2020-04-07 04:11:13 -07:00
Efl_Text_Cursor_Object * cur_obj ; \
2018-05-16 10:56:27 -07:00
evas = EVAS_TEST_INIT_EVAS ( ) ; \
evas_font_hinting_set ( evas , EVAS_FONT_HINTING_AUTO ) ; \
2019-12-10 00:39:59 -08:00
txt = efl_add ( EFL_CANVAS_TEXTBLOCK_CLASS , evas ) ; \
2018-05-16 10:56:27 -07:00
fail_if ( ! txt ) ; \
2019-12-10 00:39:59 -08:00
efl_canvas_textblock_newline_as_paragraph_separator_set ( txt , EINA_FALSE ) ; \
efl_canvas_textblock_style_apply ( txt , efl_style_buf ) ; \
fail_if ( ! efl_canvas_textblock_all_styles_get ( txt ) ) ; \
cur_obj = efl_canvas_textblock_cursor_create ( txt ) ; \
Efl.Text.Attribute_Factory
Summary:
Implementation of new Efl.Text.Attribute_Factory class which replace the annotation interface.
Currently, we have two public methods:
```
void efl_text_attribute_factory_attribute_insert(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end, const char *format)
unsigned int efl_text_attribute_factory_attribute_clear(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end);
```
Other methods will be internal methods, for the time being, we will redesign internal methods
Reviewers: woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Subscribers: zmike, q66, cedric, segfaultxavi, bu5hm4n, a.srour, #committers, #reviewers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10646
2019-11-26 20:04:31 -08:00
cur = evas_object_textblock_cursor_new ( txt ) ; \
2018-05-16 10:56:27 -07:00
fail_if ( ! cur ) ; \
do \
{ \
} \
while ( 0 )
2019-12-10 00:39:59 -08:00
# define END_EFL_CANVAS_TEXTBLOCK_TEST() \
2018-05-16 10:56:27 -07:00
do \
{ \
Efl.Text.Cursor
Summary:
Implementation of new cursor text object.
This Patch Contains :
1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor
=> there are some modifications on cursor methods
2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces
3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory
4- Add main cursor property into efl.text.interactive
5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface)
There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement.
```
enum @beta Efl.Text.Cursor_Move_Type
{
[[Text cursor movement types]]
char_next, [[Advances to the next character]]
char_prev, [[Advances to the previous character]]
cluster_next, [[Advances to the next grapheme cluster]]
cluster_prev, [[Advances to the previous grapheme cluster]]
paragraph_start, [[Advances to the first character in this paragraph]]
paragraph_end, [[Advances to the last character in this paragraph]]
word_start, [[Advance to current word start]]
word_end, [[Advance to current word end]]
line_start, [[Advance to current line first character]]
line_end, [[Advance to current line last character]]
paragraph_first, [[Advance to current paragraph first character]]
paragraph_last, [[Advance to current paragraph last character]]
paragraph_next, [[Advances to the start of the next text node]]
paragraph_prev [[Advances to the end of the previous text node]]
}
move {
[[Move the cursor]]
params {
@in type: Efl.Text.Cursor_Move_Type; [[The type of movement]]
}
return: bool; [[True if actually moved]]
}
```
or old way:
```
char_next {
[[Advances to the next character]]
// FIXME: Make the number of characters we moved by? Useful for all the other functions
return: bool; [[True if actually moved]]
}
char_prev {
[[Advances to the previous character]]
return: bool; [[True if actually moved]]
}
char_delete {
[[Deletes a single character from position pointed by given cursor.]]
}
cluster_next {
[[Advances to the next grapheme cluster]]
return: bool; [[True if actually moved]]
}
cluster_prev {
[[Advances to the previous grapheme cluster]]
return: bool; [[True if actually moved]]
}
// FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character.
paragraph_start {
[[Advances to the first character in this paragraph]]
return: bool; [[True if actually moved]]
}
paragraph_end {
[[Advances to the last character in this paragraph]]
return: bool; [[True if actually moved]]
}
word_start {
[[Advance to current word start]]
return: bool; [[True if actually moved]]
}
word_end {
[[Advance to current word end]]
return: bool; [[True if actually moved]]
}
line_start {
[[Advance to current line first character]]
return: bool; [[True if actually moved]]
}
line_end {
[[Advance to current line last character]]
return: bool; [[True if actually moved]]
}
paragraph_first {
[[Advance to current paragraph first character]]
return: bool; [[True if actually moved]]
}
paragraph_last {
[[Advance to current paragraph last character]]
return: bool; [[True if actually moved]]
}
paragraph_next {
[[Advances to the start of the next text node]]
return: bool; [[True if actually moved]]
}
paragraph_prev {
[[Advances to the end of the previous text node]]
return: bool; [[True if actually moved]]
}
```
Reviewers: woohyun, tasn, segfaultxavi
Reviewed By: woohyun
Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
efl_del ( cur_obj ) ; \
Efl.Text.Attribute_Factory
Summary:
Implementation of new Efl.Text.Attribute_Factory class which replace the annotation interface.
Currently, we have two public methods:
```
void efl_text_attribute_factory_attribute_insert(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end, const char *format)
unsigned int efl_text_attribute_factory_attribute_clear(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end);
```
Other methods will be internal methods, for the time being, we will redesign internal methods
Reviewers: woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Subscribers: zmike, q66, cedric, segfaultxavi, bu5hm4n, a.srour, #committers, #reviewers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10646
2019-11-26 20:04:31 -08:00
evas_textblock_cursor_free ( cur ) ; \
2018-05-16 10:56:27 -07:00
efl_del ( txt ) ; \
evas_free ( evas ) ; \
} \
while ( 0 )
2019-12-10 00:39:59 -08:00
EFL_START_TEST ( efl_canvas_textblock_simple )
2018-05-16 10:56:27 -07:00
{
2019-12-10 00:39:59 -08:00
START_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
2018-05-16 10:56:27 -07:00
2019-12-10 00:39:59 -08:00
/* It is simple test for Efl_Canvas_Textblock.
2018-05-16 10:56:27 -07:00
* The main object is " txt " . */
const char * buf = " Th<i>i</i>s is a <br/> te<b>s</b>t. " ;
efl_text_set ( txt , buf ) ;
fail_if ( strcmp ( efl_text_get ( txt ) , buf ) ) ;
2019-12-01 17:56:12 -08:00
/* Check if password is false by default*/
Eina_Bool password = efl_text_password_get ( txt ) ;
fail_if ( password ) ;
efl_text_password_set ( txt , EINA_TRUE ) ;
password = efl_text_password_get ( txt ) ;
fail_if ( ! password ) ;
efl_text_password_set ( txt , EINA_FALSE ) ;
password = efl_text_password_get ( txt ) ;
fail_if ( password ) ;
2019-12-10 00:39:59 -08:00
END_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
2018-05-16 10:56:27 -07:00
}
EFL_END_TEST
2018-09-07 02:34:37 -07:00
EFL_START_TEST ( efl_text )
2016-05-24 06:11:03 -07:00
{
START_TB_TEST ( ) ;
# ifdef HAVE_FRIBIDI
Evas_Coord x , x2 ;
Evas_Coord nw , nh ;
Evas_Coord cx , cx2 ;
Efl.Text.Cursor
Summary:
Implementation of new cursor text object.
This Patch Contains :
1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor
=> there are some modifications on cursor methods
2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces
3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory
4- Add main cursor property into efl.text.interactive
5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface)
There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement.
```
enum @beta Efl.Text.Cursor_Move_Type
{
[[Text cursor movement types]]
char_next, [[Advances to the next character]]
char_prev, [[Advances to the previous character]]
cluster_next, [[Advances to the next grapheme cluster]]
cluster_prev, [[Advances to the previous grapheme cluster]]
paragraph_start, [[Advances to the first character in this paragraph]]
paragraph_end, [[Advances to the last character in this paragraph]]
word_start, [[Advance to current word start]]
word_end, [[Advance to current word end]]
line_start, [[Advance to current line first character]]
line_end, [[Advance to current line last character]]
paragraph_first, [[Advance to current paragraph first character]]
paragraph_last, [[Advance to current paragraph last character]]
paragraph_next, [[Advances to the start of the next text node]]
paragraph_prev [[Advances to the end of the previous text node]]
}
move {
[[Move the cursor]]
params {
@in type: Efl.Text.Cursor_Move_Type; [[The type of movement]]
}
return: bool; [[True if actually moved]]
}
```
or old way:
```
char_next {
[[Advances to the next character]]
// FIXME: Make the number of characters we moved by? Useful for all the other functions
return: bool; [[True if actually moved]]
}
char_prev {
[[Advances to the previous character]]
return: bool; [[True if actually moved]]
}
char_delete {
[[Deletes a single character from position pointed by given cursor.]]
}
cluster_next {
[[Advances to the next grapheme cluster]]
return: bool; [[True if actually moved]]
}
cluster_prev {
[[Advances to the previous grapheme cluster]]
return: bool; [[True if actually moved]]
}
// FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character.
paragraph_start {
[[Advances to the first character in this paragraph]]
return: bool; [[True if actually moved]]
}
paragraph_end {
[[Advances to the last character in this paragraph]]
return: bool; [[True if actually moved]]
}
word_start {
[[Advance to current word start]]
return: bool; [[True if actually moved]]
}
word_end {
[[Advance to current word end]]
return: bool; [[True if actually moved]]
}
line_start {
[[Advance to current line first character]]
return: bool; [[True if actually moved]]
}
line_end {
[[Advance to current line last character]]
return: bool; [[True if actually moved]]
}
paragraph_first {
[[Advance to current paragraph first character]]
return: bool; [[True if actually moved]]
}
paragraph_last {
[[Advance to current paragraph last character]]
return: bool; [[True if actually moved]]
}
paragraph_next {
[[Advances to the start of the next text node]]
return: bool; [[True if actually moved]]
}
paragraph_prev {
[[Advances to the end of the previous text node]]
return: bool; [[True if actually moved]]
}
```
Reviewers: woohyun, tasn, segfaultxavi
Reviewed By: woohyun
Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
Eina_Size2D size ;
2016-05-24 06:11:03 -07:00
/* Split cursor in LTR paragraph.
* Russian ' t ' in the beginnning to create additional item . */
/*01234 5 6789012345678 19 01234 */
efl_text_set ( tb , " тest \u202b נס י ו ן abcנס י ו ן \u202c bang " ) ;
2019-12-10 00:39:59 -08:00
size = efl_canvas_textblock_size_native_get ( tb ) ;
Efl.Text.Cursor
Summary:
Implementation of new cursor text object.
This Patch Contains :
1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor
=> there are some modifications on cursor methods
2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces
3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory
4- Add main cursor property into efl.text.interactive
5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface)
There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement.
```
enum @beta Efl.Text.Cursor_Move_Type
{
[[Text cursor movement types]]
char_next, [[Advances to the next character]]
char_prev, [[Advances to the previous character]]
cluster_next, [[Advances to the next grapheme cluster]]
cluster_prev, [[Advances to the previous grapheme cluster]]
paragraph_start, [[Advances to the first character in this paragraph]]
paragraph_end, [[Advances to the last character in this paragraph]]
word_start, [[Advance to current word start]]
word_end, [[Advance to current word end]]
line_start, [[Advance to current line first character]]
line_end, [[Advance to current line last character]]
paragraph_first, [[Advance to current paragraph first character]]
paragraph_last, [[Advance to current paragraph last character]]
paragraph_next, [[Advances to the start of the next text node]]
paragraph_prev [[Advances to the end of the previous text node]]
}
move {
[[Move the cursor]]
params {
@in type: Efl.Text.Cursor_Move_Type; [[The type of movement]]
}
return: bool; [[True if actually moved]]
}
```
or old way:
```
char_next {
[[Advances to the next character]]
// FIXME: Make the number of characters we moved by? Useful for all the other functions
return: bool; [[True if actually moved]]
}
char_prev {
[[Advances to the previous character]]
return: bool; [[True if actually moved]]
}
char_delete {
[[Deletes a single character from position pointed by given cursor.]]
}
cluster_next {
[[Advances to the next grapheme cluster]]
return: bool; [[True if actually moved]]
}
cluster_prev {
[[Advances to the previous grapheme cluster]]
return: bool; [[True if actually moved]]
}
// FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character.
paragraph_start {
[[Advances to the first character in this paragraph]]
return: bool; [[True if actually moved]]
}
paragraph_end {
[[Advances to the last character in this paragraph]]
return: bool; [[True if actually moved]]
}
word_start {
[[Advance to current word start]]
return: bool; [[True if actually moved]]
}
word_end {
[[Advance to current word end]]
return: bool; [[True if actually moved]]
}
line_start {
[[Advance to current line first character]]
return: bool; [[True if actually moved]]
}
line_end {
[[Advance to current line last character]]
return: bool; [[True if actually moved]]
}
paragraph_first {
[[Advance to current paragraph first character]]
return: bool; [[True if actually moved]]
}
paragraph_last {
[[Advance to current paragraph last character]]
return: bool; [[True if actually moved]]
}
paragraph_next {
[[Advances to the start of the next text node]]
return: bool; [[True if actually moved]]
}
paragraph_prev {
[[Advances to the end of the previous text node]]
return: bool; [[True if actually moved]]
}
```
Reviewers: woohyun, tasn, segfaultxavi
Reviewed By: woohyun
Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
nw = size . w ;
nh = size . h ;
2018-04-05 01:47:26 -07:00
efl_gfx_entity_size_set ( tb , EINA_SIZE2D ( nw , nh ) ) ;
2016-05-24 06:11:03 -07:00
/* Logical cursor after "test " */
2016-06-05 05:44:03 -07:00
evas_textblock_cursor_pos_set ( cur , 6 ) ;
Efl.Text.Cursor
Summary:
Implementation of new cursor text object.
This Patch Contains :
1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor
=> there are some modifications on cursor methods
2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces
3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory
4- Add main cursor property into efl.text.interactive
5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface)
There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement.
```
enum @beta Efl.Text.Cursor_Move_Type
{
[[Text cursor movement types]]
char_next, [[Advances to the next character]]
char_prev, [[Advances to the previous character]]
cluster_next, [[Advances to the next grapheme cluster]]
cluster_prev, [[Advances to the previous grapheme cluster]]
paragraph_start, [[Advances to the first character in this paragraph]]
paragraph_end, [[Advances to the last character in this paragraph]]
word_start, [[Advance to current word start]]
word_end, [[Advance to current word end]]
line_start, [[Advance to current line first character]]
line_end, [[Advance to current line last character]]
paragraph_first, [[Advance to current paragraph first character]]
paragraph_last, [[Advance to current paragraph last character]]
paragraph_next, [[Advances to the start of the next text node]]
paragraph_prev [[Advances to the end of the previous text node]]
}
move {
[[Move the cursor]]
params {
@in type: Efl.Text.Cursor_Move_Type; [[The type of movement]]
}
return: bool; [[True if actually moved]]
}
```
or old way:
```
char_next {
[[Advances to the next character]]
// FIXME: Make the number of characters we moved by? Useful for all the other functions
return: bool; [[True if actually moved]]
}
char_prev {
[[Advances to the previous character]]
return: bool; [[True if actually moved]]
}
char_delete {
[[Deletes a single character from position pointed by given cursor.]]
}
cluster_next {
[[Advances to the next grapheme cluster]]
return: bool; [[True if actually moved]]
}
cluster_prev {
[[Advances to the previous grapheme cluster]]
return: bool; [[True if actually moved]]
}
// FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character.
paragraph_start {
[[Advances to the first character in this paragraph]]
return: bool; [[True if actually moved]]
}
paragraph_end {
[[Advances to the last character in this paragraph]]
return: bool; [[True if actually moved]]
}
word_start {
[[Advance to current word start]]
return: bool; [[True if actually moved]]
}
word_end {
[[Advance to current word end]]
return: bool; [[True if actually moved]]
}
line_start {
[[Advance to current line first character]]
return: bool; [[True if actually moved]]
}
line_end {
[[Advance to current line last character]]
return: bool; [[True if actually moved]]
}
paragraph_first {
[[Advance to current paragraph first character]]
return: bool; [[True if actually moved]]
}
paragraph_last {
[[Advance to current paragraph last character]]
return: bool; [[True if actually moved]]
}
paragraph_next {
[[Advances to the start of the next text node]]
return: bool; [[True if actually moved]]
}
paragraph_prev {
[[Advances to the end of the previous text node]]
return: bool; [[True if actually moved]]
}
```
Reviewers: woohyun, tasn, segfaultxavi
Reviewed By: woohyun
Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
fail_if ( ! evas_textblock_cursor_geometry_bidi_get ( cur ,
& cx , NULL , NULL , NULL , & cx2 ,
NULL , NULL , NULL , EVAS_TEXTBLOCK_CURSOR_BEFORE ) ) ;
2016-06-05 05:44:03 -07:00
evas_textblock_cursor_pos_set ( cur , 18 ) ;
2016-05-24 06:11:03 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x , NULL , NULL , NULL ) ;
2016-06-05 05:44:03 -07:00
evas_textblock_cursor_pos_set ( cur , 20 ) ;
2016-05-24 06:11:03 -07:00
evas_textblock_cursor_pen_geometry_get ( cur , & x2 , NULL , NULL , NULL ) ;
ck_assert_int_eq ( cx , x ) ;
ck_assert_int_eq ( cx2 , x2 ) ;
# endif
END_TB_TEST ( ) ;
}
2018-03-26 11:19:28 -07:00
EFL_END_TEST
2016-05-24 06:11:03 -07:00
2019-12-12 22:10:32 -08:00
static void
_increment_int_changed ( void * data EINA_UNUSED , const Efl_Event * ev EINA_UNUSED )
{
int * value = data ;
( * value ) + + ;
}
2019-12-10 00:39:59 -08:00
EFL_START_TEST ( efl_canvas_textblock_cursor )
2018-09-07 02:34:37 -07:00
{
2019-12-10 00:39:59 -08:00
START_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
2018-09-07 02:34:37 -07:00
int pos ;
2019-12-12 22:10:32 -08:00
int changed_emit = 0 ;
efl_event_callback_add ( txt , EFL_CANVAS_TEXTBLOCK_EVENT_CHANGED , _increment_int_changed , & changed_emit ) ;
2018-09-07 02:34:37 -07:00
const char * buf = " abcdefghij " ;
efl_text_set ( txt , buf ) ;
2019-12-23 23:34:14 -08:00
ck_assert_int_eq ( strcmp ( efl_text_get ( txt ) , buf ) , 0 ) ;
2018-09-07 02:34:37 -07:00
2020-04-07 04:11:13 -07:00
pos = efl_text_cursor_object_position_get ( cur_obj ) ;
2019-12-26 00:45:29 -08:00
ck_assert_int_eq ( pos , 0 ) ;
2020-04-07 04:11:13 -07:00
ck_assert ( ! efl_text_cursor_object_line_jump_by ( cur_obj , - 1 ) ) ;
pos = efl_text_cursor_object_position_get ( cur_obj ) ;
2018-09-07 02:34:37 -07:00
ck_assert_int_eq ( pos , 0 ) ;
2020-04-07 04:11:13 -07:00
ck_assert ( efl_text_cursor_object_line_jump_by ( cur_obj , 1 ) ) ;
pos = efl_text_cursor_object_position_get ( cur_obj ) ;
2018-09-07 02:34:37 -07:00
ck_assert_int_eq ( pos , 10 ) ;
2019-12-26 00:45:29 -08:00
efl_text_markup_set ( txt , " Hello World<ps/>This is EFL<br/>Enlightenment " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( cur_obj , 0 ) ;
ck_assert_int_eq ( efl_text_cursor_object_line_number_get ( cur_obj ) , 0 ) ;
ck_assert ( efl_text_cursor_object_line_jump_by ( cur_obj , 2 ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 24 ) ;
ck_assert_int_eq ( efl_text_cursor_object_line_number_get ( cur_obj ) , 2 ) ;
ck_assert ( efl_text_cursor_object_line_jump_by ( cur_obj , - 2 ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 0 ) ;
ck_assert_int_eq ( efl_text_cursor_object_line_number_get ( cur_obj ) , 0 ) ;
ck_assert ( efl_text_cursor_object_line_jump_by ( cur_obj , 2 ) ) ;
efl_text_cursor_object_line_number_set ( cur_obj , 2 ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 24 ) ;
efl_text_cursor_object_line_number_set ( cur_obj , 0 ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 0 ) ;
Efl.Text.Cursor
Summary:
Implementation of new cursor text object.
This Patch Contains :
1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor
=> there are some modifications on cursor methods
2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces
3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory
4- Add main cursor property into efl.text.interactive
5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface)
There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement.
```
enum @beta Efl.Text.Cursor_Move_Type
{
[[Text cursor movement types]]
char_next, [[Advances to the next character]]
char_prev, [[Advances to the previous character]]
cluster_next, [[Advances to the next grapheme cluster]]
cluster_prev, [[Advances to the previous grapheme cluster]]
paragraph_start, [[Advances to the first character in this paragraph]]
paragraph_end, [[Advances to the last character in this paragraph]]
word_start, [[Advance to current word start]]
word_end, [[Advance to current word end]]
line_start, [[Advance to current line first character]]
line_end, [[Advance to current line last character]]
paragraph_first, [[Advance to current paragraph first character]]
paragraph_last, [[Advance to current paragraph last character]]
paragraph_next, [[Advances to the start of the next text node]]
paragraph_prev [[Advances to the end of the previous text node]]
}
move {
[[Move the cursor]]
params {
@in type: Efl.Text.Cursor_Move_Type; [[The type of movement]]
}
return: bool; [[True if actually moved]]
}
```
or old way:
```
char_next {
[[Advances to the next character]]
// FIXME: Make the number of characters we moved by? Useful for all the other functions
return: bool; [[True if actually moved]]
}
char_prev {
[[Advances to the previous character]]
return: bool; [[True if actually moved]]
}
char_delete {
[[Deletes a single character from position pointed by given cursor.]]
}
cluster_next {
[[Advances to the next grapheme cluster]]
return: bool; [[True if actually moved]]
}
cluster_prev {
[[Advances to the previous grapheme cluster]]
return: bool; [[True if actually moved]]
}
// FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character.
paragraph_start {
[[Advances to the first character in this paragraph]]
return: bool; [[True if actually moved]]
}
paragraph_end {
[[Advances to the last character in this paragraph]]
return: bool; [[True if actually moved]]
}
word_start {
[[Advance to current word start]]
return: bool; [[True if actually moved]]
}
word_end {
[[Advance to current word end]]
return: bool; [[True if actually moved]]
}
line_start {
[[Advance to current line first character]]
return: bool; [[True if actually moved]]
}
line_end {
[[Advance to current line last character]]
return: bool; [[True if actually moved]]
}
paragraph_first {
[[Advance to current paragraph first character]]
return: bool; [[True if actually moved]]
}
paragraph_last {
[[Advance to current paragraph last character]]
return: bool; [[True if actually moved]]
}
paragraph_next {
[[Advances to the start of the next text node]]
return: bool; [[True if actually moved]]
}
paragraph_prev {
[[Advances to the end of the previous text node]]
return: bool; [[True if actually moved]]
}
```
Reviewers: woohyun, tasn, segfaultxavi
Reviewed By: woohyun
Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
2020-01-09 05:33:07 -08:00
Eo * cursor_temp = efl_duplicate ( cur_obj ) ;
ck_assert_ptr_ne ( cursor_temp , NULL ) ;
efl_del ( cursor_temp ) ;
cursor_temp = NULL ;
Efl.Text.Cursor
Summary:
Implementation of new cursor text object.
This Patch Contains :
1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor
=> there are some modifications on cursor methods
2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces
3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory
4- Add main cursor property into efl.text.interactive
5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface)
There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement.
```
enum @beta Efl.Text.Cursor_Move_Type
{
[[Text cursor movement types]]
char_next, [[Advances to the next character]]
char_prev, [[Advances to the previous character]]
cluster_next, [[Advances to the next grapheme cluster]]
cluster_prev, [[Advances to the previous grapheme cluster]]
paragraph_start, [[Advances to the first character in this paragraph]]
paragraph_end, [[Advances to the last character in this paragraph]]
word_start, [[Advance to current word start]]
word_end, [[Advance to current word end]]
line_start, [[Advance to current line first character]]
line_end, [[Advance to current line last character]]
paragraph_first, [[Advance to current paragraph first character]]
paragraph_last, [[Advance to current paragraph last character]]
paragraph_next, [[Advances to the start of the next text node]]
paragraph_prev [[Advances to the end of the previous text node]]
}
move {
[[Move the cursor]]
params {
@in type: Efl.Text.Cursor_Move_Type; [[The type of movement]]
}
return: bool; [[True if actually moved]]
}
```
or old way:
```
char_next {
[[Advances to the next character]]
// FIXME: Make the number of characters we moved by? Useful for all the other functions
return: bool; [[True if actually moved]]
}
char_prev {
[[Advances to the previous character]]
return: bool; [[True if actually moved]]
}
char_delete {
[[Deletes a single character from position pointed by given cursor.]]
}
cluster_next {
[[Advances to the next grapheme cluster]]
return: bool; [[True if actually moved]]
}
cluster_prev {
[[Advances to the previous grapheme cluster]]
return: bool; [[True if actually moved]]
}
// FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character.
paragraph_start {
[[Advances to the first character in this paragraph]]
return: bool; [[True if actually moved]]
}
paragraph_end {
[[Advances to the last character in this paragraph]]
return: bool; [[True if actually moved]]
}
word_start {
[[Advance to current word start]]
return: bool; [[True if actually moved]]
}
word_end {
[[Advance to current word end]]
return: bool; [[True if actually moved]]
}
line_start {
[[Advance to current line first character]]
return: bool; [[True if actually moved]]
}
line_end {
[[Advance to current line last character]]
return: bool; [[True if actually moved]]
}
paragraph_first {
[[Advance to current paragraph first character]]
return: bool; [[True if actually moved]]
}
paragraph_last {
[[Advance to current paragraph last character]]
return: bool; [[True if actually moved]]
}
paragraph_next {
[[Advances to the start of the next text node]]
return: bool; [[True if actually moved]]
}
paragraph_prev {
[[Advances to the end of the previous text node]]
return: bool; [[True if actually moved]]
}
```
Reviewers: woohyun, tasn, segfaultxavi
Reviewed By: woohyun
Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
2020-01-09 05:33:07 -08:00
Eo * cursor1 = efl_canvas_textblock_cursor_create ( txt ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( cursor1 , 1 ) ;
pos = efl_text_cursor_object_position_get ( cursor1 ) ;
Efl.Text.Cursor
Summary:
Implementation of new cursor text object.
This Patch Contains :
1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor
=> there are some modifications on cursor methods
2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces
3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory
4- Add main cursor property into efl.text.interactive
5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface)
There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement.
```
enum @beta Efl.Text.Cursor_Move_Type
{
[[Text cursor movement types]]
char_next, [[Advances to the next character]]
char_prev, [[Advances to the previous character]]
cluster_next, [[Advances to the next grapheme cluster]]
cluster_prev, [[Advances to the previous grapheme cluster]]
paragraph_start, [[Advances to the first character in this paragraph]]
paragraph_end, [[Advances to the last character in this paragraph]]
word_start, [[Advance to current word start]]
word_end, [[Advance to current word end]]
line_start, [[Advance to current line first character]]
line_end, [[Advance to current line last character]]
paragraph_first, [[Advance to current paragraph first character]]
paragraph_last, [[Advance to current paragraph last character]]
paragraph_next, [[Advances to the start of the next text node]]
paragraph_prev [[Advances to the end of the previous text node]]
}
move {
[[Move the cursor]]
params {
@in type: Efl.Text.Cursor_Move_Type; [[The type of movement]]
}
return: bool; [[True if actually moved]]
}
```
or old way:
```
char_next {
[[Advances to the next character]]
// FIXME: Make the number of characters we moved by? Useful for all the other functions
return: bool; [[True if actually moved]]
}
char_prev {
[[Advances to the previous character]]
return: bool; [[True if actually moved]]
}
char_delete {
[[Deletes a single character from position pointed by given cursor.]]
}
cluster_next {
[[Advances to the next grapheme cluster]]
return: bool; [[True if actually moved]]
}
cluster_prev {
[[Advances to the previous grapheme cluster]]
return: bool; [[True if actually moved]]
}
// FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character.
paragraph_start {
[[Advances to the first character in this paragraph]]
return: bool; [[True if actually moved]]
}
paragraph_end {
[[Advances to the last character in this paragraph]]
return: bool; [[True if actually moved]]
}
word_start {
[[Advance to current word start]]
return: bool; [[True if actually moved]]
}
word_end {
[[Advance to current word end]]
return: bool; [[True if actually moved]]
}
line_start {
[[Advance to current line first character]]
return: bool; [[True if actually moved]]
}
line_end {
[[Advance to current line last character]]
return: bool; [[True if actually moved]]
}
paragraph_first {
[[Advance to current paragraph first character]]
return: bool; [[True if actually moved]]
}
paragraph_last {
[[Advance to current paragraph last character]]
return: bool; [[True if actually moved]]
}
paragraph_next {
[[Advances to the start of the next text node]]
return: bool; [[True if actually moved]]
}
paragraph_prev {
[[Advances to the end of the previous text node]]
return: bool; [[True if actually moved]]
}
```
Reviewers: woohyun, tasn, segfaultxavi
Reviewed By: woohyun
Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
ck_assert_int_eq ( pos , 1 ) ;
2019-12-12 22:10:32 -08:00
efl_text_set ( txt , " " ) ;
efl_text_set ( txt , " " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_text_insert ( cursor1 , " aa " ) ;
2020-01-01 23:25:35 -08:00
ck_assert_int_eq ( changed_emit , 4 ) ;
efl_text_markup_set ( txt , " Hello<br/>Word " ) ;
efl_text_markup_set ( txt , " Hello<br/>Word " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_markup_insert ( cursor1 , " aa " ) ;
2020-01-01 23:25:35 -08:00
ck_assert_int_eq ( changed_emit , 6 ) ;
2019-12-12 22:10:32 -08:00
2019-12-26 00:45:29 -08:00
efl_text_set ( txt , " " ) ;
2020-04-07 04:11:13 -07:00
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_NEXT ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_PREVIOUS ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CLUSTER_NEXT ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CLUSTER_PREVIOUS ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_START ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_END ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_LINE_START ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_LINE_END ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_NEXT ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_PREVIOUS ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_FIRST ) ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_LAST ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 0 ) ;
2019-12-26 00:45:29 -08:00
2020-01-01 23:25:35 -08:00
ck_assert_int_eq ( changed_emit , 7 ) ;
2019-12-24 00:17:31 -08:00
2019-12-26 00:45:29 -08:00
efl_text_markup_set ( txt , " Hello World<ps/>This is EFL<br/>Enlightenment " ) ;
2020-04-07 04:11:13 -07:00
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_NEXT ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 1 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_PREVIOUS ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 0 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CLUSTER_NEXT ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 1 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CLUSTER_PREVIOUS ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 0 ) ;
efl_text_cursor_object_position_set ( cur_obj , 0 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 4 ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 4 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 0 ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 0 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END ) ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_NEXT ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 5 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 10 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_NEXT ) ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END ) ) ;
ck_assert_int_ne ( efl_text_cursor_object_position_get ( cur_obj ) , 10 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_LINE_END ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 23 ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_LINE_END ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 23 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_LINE_START ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 12 ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_LINE_START ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 12 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_PREVIOUS ) ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_LINE_START ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 0 ) ;
2019-12-25 23:05:37 -08:00
2019-12-26 00:45:29 -08:00
# if defined(HAVE_FRIBIDI) && defined(HAVE_HARFBUZZ)
efl_text_markup_set ( txt , " الْبَرْمَجةُ<ps/>مَرْحبَاً " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_cluster_coord_set ( cur_obj , EINA_POSITION2D ( 0 , 0 ) ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CLUSTER_NEXT ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 1 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CLUSTER_NEXT ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 3 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CLUSTER_NEXT ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 5 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_PREVIOUS ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 4 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_NEXT ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 5 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CHARACTER_NEXT ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 6 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_CLUSTER_NEXT ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 7 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_NEXT ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 13 ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_NEXT ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 13 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_END ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 22 ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_END ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 22 ) ;
ck_assert ( ! efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_LAST ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 22 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_START ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 13 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_END ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 22 ) ;
ck_assert ( efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_FIRST ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 0 ) ;
2019-12-26 00:45:29 -08:00
# endif
2020-01-09 05:33:07 -08:00
Eo * nCur = efl_canvas_textblock_cursor_create ( txt ) ;
Eo * nCur2 = efl_canvas_textblock_cursor_create ( txt ) ;
Eo * nCur3 = efl_canvas_textblock_cursor_create ( txt ) ;
2019-12-26 00:45:29 -08:00
efl_text_markup_set ( txt , " Hello World<ps/>This is EFL<br/>Enlightenment " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( cur_obj , 0 ) ;
2019-12-26 00:45:29 -08:00
ck_assert_ptr_ne ( nCur , NULL ) ;
ck_assert_ptr_ne ( nCur2 , NULL ) ;
ck_assert_ptr_ne ( nCur3 , NULL ) ;
2020-04-07 04:11:13 -07:00
ck_assert ( efl_text_cursor_object_equal ( cur_obj , nCur ) ) ;
ck_assert ( efl_text_cursor_object_equal ( cur_obj , nCur2 ) ) ;
ck_assert ( efl_text_cursor_object_equal ( cur_obj , nCur3 ) ) ;
ck_assert ( efl_text_cursor_object_equal ( nCur2 , nCur3 ) ) ;
2019-12-26 00:45:29 -08:00
2020-04-07 04:11:13 -07:00
ck_assert_int_eq ( efl_text_cursor_object_compare ( cur_obj , nCur3 ) , 0 ) ;
ck_assert_int_eq ( efl_text_cursor_object_compare ( nCur2 , nCur3 ) , 0 ) ;
ck_assert_int_eq ( efl_text_cursor_object_compare ( cur_obj , nCur ) , 0 ) ;
2019-12-26 00:45:29 -08:00
2020-04-07 04:11:13 -07:00
ck_assert ( efl_text_cursor_object_move ( nCur , EFL_TEXT_CURSOR_MOVE_TYPE_PARAGRAPH_NEXT ) ) ;
ck_assert_int_lt ( efl_text_cursor_object_compare ( cur_obj , nCur ) , 0 ) ;
ck_assert_int_gt ( efl_text_cursor_object_compare ( nCur , cur_obj ) , 0 ) ;
efl_text_cursor_object_position_set ( nCur2 , efl_text_cursor_object_position_get ( nCur ) ) ;
ck_assert_int_lt ( efl_text_cursor_object_compare ( cur_obj , nCur2 ) , 0 ) ;
ck_assert_int_gt ( efl_text_cursor_object_compare ( nCur2 , cur_obj ) , 0 ) ;
ck_assert ( ! efl_text_cursor_object_equal ( nCur2 , nCur3 ) ) ;
2019-12-26 00:45:29 -08:00
efl_text_set ( txt , " " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_text_insert ( cur_obj , " Hello World " ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 11 ) ;
efl_text_cursor_object_text_insert ( cur_obj , " Hello World " ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 22 ) ;
2019-12-26 00:45:29 -08:00
ck_assert_str_eq ( efl_text_get ( txt ) , " Hello WorldHello World " ) ;
efl_text_set ( txt , " " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_markup_insert ( cur_obj , " Hello World<ps/>Hello World " ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 23 ) ;
efl_text_cursor_object_char_coord_set ( cur_obj , EINA_POSITION2D ( 0 , 0 ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 0 ) ;
efl_text_cursor_object_char_coord_set ( cur_obj , EINA_POSITION2D ( 500 , 500 ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 23 ) ;
efl_text_cursor_object_cluster_coord_set ( cur_obj , EINA_POSITION2D ( 0 , 0 ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 0 ) ;
efl_text_cursor_object_cluster_coord_set ( cur_obj , EINA_POSITION2D ( 500 , 500 ) ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 23 ) ;
efl_text_cursor_object_position_set ( nCur , 0 ) ;
efl_text_cursor_object_position_set ( cur_obj , 5 ) ;
ck_assert_str_eq ( efl_text_cursor_object_range_text_get ( cur_obj , nCur ) , " Hello " ) ;
ck_assert_str_eq ( efl_text_cursor_object_range_text_get ( nCur , cur_obj ) , " Hello " ) ;
efl_text_cursor_object_position_set ( nCur , 0 ) ;
efl_text_cursor_object_position_set ( cur_obj , 17 ) ;
2019-12-26 00:45:29 -08:00
2020-04-07 04:11:13 -07:00
Eina_Iterator * iter = efl_text_cursor_object_range_geometry_get ( cur_obj , nCur ) ;
2019-12-26 00:45:29 -08:00
Eina_Rect * geoRect ;
int x = 0 ;
EINA_ITERATOR_FOREACH ( iter , geoRect )
{
x + + ;
ck_assert_int_ne ( geoRect - > w , 0 ) ;
ck_assert_int_ne ( geoRect - > h , 0 ) ;
}
ck_assert_int_eq ( x , 3 ) ;
2020-04-07 04:11:13 -07:00
iter = efl_text_cursor_object_range_precise_geometry_get ( cur_obj , nCur ) ;
2019-12-26 00:45:29 -08:00
x = 0 ;
EINA_ITERATOR_FOREACH ( iter , geoRect )
{
x + + ;
ck_assert_int_ne ( geoRect - > w , 0 ) ;
ck_assert_int_ne ( geoRect - > h , 0 ) ;
}
ck_assert_int_eq ( x , 2 ) ;
2020-04-07 04:11:13 -07:00
ck_assert_str_eq ( efl_text_cursor_object_range_markup_get ( cur_obj , nCur ) , " Hello World<ps/>Hello " ) ;
ck_assert_str_eq ( efl_text_cursor_object_range_markup_get ( nCur , cur_obj ) , " Hello World<ps/>Hello " ) ;
2019-12-26 00:45:29 -08:00
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( nCur , 0 ) ;
efl_text_cursor_object_position_set ( cur_obj , 5 ) ;
2019-12-26 00:45:29 -08:00
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_range_delete ( nCur , cur_obj ) ;
2019-12-26 00:45:29 -08:00
ck_assert_str_eq ( efl_text_markup_get ( txt ) , " World<ps/>Hello World " ) ;
2020-04-07 04:11:13 -07:00
ck_assert_int_eq ( efl_text_cursor_object_position_get ( cur_obj ) , 0 ) ;
ck_assert_int_eq ( efl_text_cursor_object_position_get ( nCur ) , 0 ) ;
2019-12-26 00:45:29 -08:00
efl_text_markup_set ( txt , " Hello World<ps/>Hello World " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( cur_obj , 6 ) ;
2019-12-26 00:45:29 -08:00
Eina_Unicode str [ 2 ] = { 0 } ;
2020-04-07 04:11:13 -07:00
str [ 0 ] = efl_text_cursor_object_content_get ( cur_obj ) ;
2019-12-26 00:45:29 -08:00
ck_assert_str_eq ( eina_unicode_unicode_to_utf8 ( str , NULL ) , " W " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_char_delete ( cur_obj ) ;
2019-12-26 00:45:29 -08:00
2020-04-07 04:11:13 -07:00
str [ 0 ] = efl_text_cursor_object_content_get ( cur_obj ) ;
2019-12-26 00:45:29 -08:00
ck_assert_str_eq ( eina_unicode_unicode_to_utf8 ( str , NULL ) , " o " ) ;
2020-04-07 04:11:13 -07:00
Eo * cur_txt = efl_text_cursor_object_text_object_get ( cur_obj ) ;
Eo * cur_txt2 = efl_text_cursor_object_text_object_get ( nCur ) ;
2019-12-26 00:45:29 -08:00
ck_assert_ptr_eq ( cur_txt , txt ) ;
ck_assert_ptr_eq ( cur_txt2 , txt ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( cur_obj , 1 ) ;
Eina_Rect rect = efl_text_cursor_object_content_geometry_get ( cur_obj ) ;
2019-12-26 00:45:29 -08:00
ck_assert_int_ne ( rect . w , 0 ) ;
ck_assert_int_ne ( rect . h , 0 ) ;
ck_assert_int_ne ( rect . x , 0 ) ;
2020-04-07 04:11:13 -07:00
rect = efl_text_cursor_object_cursor_geometry_get ( cur_obj , EFL_TEXT_CURSOR_TYPE_BEFORE ) ;
2019-12-26 00:45:29 -08:00
ck_assert_int_eq ( rect . w , 0 ) ;
ck_assert_int_ne ( rect . h , 0 ) ;
ck_assert_int_ne ( rect . x , 0 ) ;
2020-04-07 04:11:13 -07:00
Eina_Rect rect2 = efl_text_cursor_object_cursor_geometry_get ( cur_obj , EFL_TEXT_CURSOR_TYPE_UNDER ) ;
2019-12-26 00:45:29 -08:00
ck_assert_int_ne ( rect2 . w , 0 ) ;
ck_assert_int_ne ( rect2 . h , 0 ) ;
ck_assert_int_ne ( rect2 . x , 0 ) ;
ck_assert_int_ne ( rect2 . w , rect . w ) ;
ck_assert_int_eq ( rect2 . h , rect . h ) ;
ck_assert_int_eq ( rect2 . x , rect . x ) ;
ck_assert_int_eq ( rect2 . y , rect . y ) ;
efl_text_markup_set ( txt , " Hello World " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( cur_obj , 11 ) ;
ck_assert ( ! efl_text_cursor_object_lower_cursor_geometry_get ( cur_obj , & rect2 ) ) ;
2019-12-26 00:45:29 -08:00
# ifdef HAVE_FRIBIDI
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_text_insert ( cur_obj , " مرحباً " ) ;
rect = efl_text_cursor_object_cursor_geometry_get ( cur_obj , EFL_TEXT_CURSOR_TYPE_BEFORE ) ;
ck_assert ( efl_text_cursor_object_lower_cursor_geometry_get ( cur_obj , & rect2 ) ) ;
2019-12-26 00:45:29 -08:00
ck_assert_int_eq ( rect2 . w , 0 ) ;
ck_assert_int_ne ( rect2 . h , 0 ) ;
ck_assert_int_ne ( rect2 . x , 0 ) ;
ck_assert_int_eq ( rect2 . w , rect . w ) ;
ck_assert_int_eq ( rect2 . h , rect . h ) ;
ck_assert_int_ne ( rect2 . x , rect . x ) ;
ck_assert_int_eq ( rect2 . y , rect . y ) ;
# endif
2019-12-25 16:55:28 -08:00
2020-02-05 08:01:52 -08:00
//Efl able to deal with br tab without closing tag "/"
efl_text_markup_set ( txt , " a<br>a<tab>a " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_move ( nCur , EFL_TEXT_CURSOR_MOVE_TYPE_FIRST ) ;
efl_text_cursor_object_move ( cur_obj , EFL_TEXT_CURSOR_MOVE_TYPE_LAST ) ;
efl_text_cursor_object_range_delete ( nCur , cur_obj ) ;
2020-02-05 08:01:52 -08:00
ck_assert_str_eq ( efl_text_markup_get ( txt ) , " " ) ;
2019-12-10 00:39:59 -08:00
END_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
2018-09-07 02:34:37 -07:00
}
EFL_END_TEST
2018-09-12 11:17:53 -07:00
2019-12-10 00:39:59 -08:00
EFL_START_TEST ( efl_canvas_textblock_markup )
2018-09-12 11:17:53 -07:00
{
2019-12-10 00:39:59 -08:00
START_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
2020-04-07 04:11:13 -07:00
Efl_Text_Cursor_Object * start , * end ;
2018-09-12 11:17:53 -07:00
char * res ;
2019-12-10 00:39:59 -08:00
start = efl_canvas_textblock_cursor_create ( txt ) ;
end = efl_canvas_textblock_cursor_create ( txt ) ;
2018-09-12 11:17:53 -07:00
efl_text_set ( txt , " \n \n \n " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( start , 1 ) ;
efl_text_cursor_object_position_set ( end , 2 ) ;
res = efl_text_cursor_object_range_markup_get ( start , end ) ;
2018-09-12 11:17:53 -07:00
ck_assert_str_eq ( res , " <br> " ) ;
free ( res ) ;
efl_text_set ( txt , " a \u2029 bc \n def \n \u2029 " ) ;
2020-04-07 04:11:13 -07:00
efl_text_cursor_object_position_set ( start , 2 ) ;
efl_text_cursor_object_position_set ( end , 5 ) ;
res = efl_text_cursor_object_range_markup_get ( start , end ) ;
2018-09-12 11:17:53 -07:00
ck_assert_str_eq ( res , " bc<br> " ) ;
free ( res ) ;
2019-12-10 00:39:59 -08:00
END_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
2018-09-12 11:17:53 -07:00
}
EFL_END_TEST
2019-12-10 00:39:59 -08:00
EFL_START_TEST ( efl_canvas_textblock_markup_invalid_escape )
2019-08-03 02:19:20 -07:00
{
2019-12-10 00:39:59 -08:00
START_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
2019-08-03 02:19:20 -07:00
char * text1 = " Hello " ;
char * text2 = " Hello&123 " ;
char * text3 = " Hello&123&456 " ;
Efl.Text.Cursor
Summary:
Implementation of new cursor text object.
This Patch Contains :
1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor
=> there are some modifications on cursor methods
2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces
3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory
4- Add main cursor property into efl.text.interactive
5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface)
There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement.
```
enum @beta Efl.Text.Cursor_Move_Type
{
[[Text cursor movement types]]
char_next, [[Advances to the next character]]
char_prev, [[Advances to the previous character]]
cluster_next, [[Advances to the next grapheme cluster]]
cluster_prev, [[Advances to the previous grapheme cluster]]
paragraph_start, [[Advances to the first character in this paragraph]]
paragraph_end, [[Advances to the last character in this paragraph]]
word_start, [[Advance to current word start]]
word_end, [[Advance to current word end]]
line_start, [[Advance to current line first character]]
line_end, [[Advance to current line last character]]
paragraph_first, [[Advance to current paragraph first character]]
paragraph_last, [[Advance to current paragraph last character]]
paragraph_next, [[Advances to the start of the next text node]]
paragraph_prev [[Advances to the end of the previous text node]]
}
move {
[[Move the cursor]]
params {
@in type: Efl.Text.Cursor_Move_Type; [[The type of movement]]
}
return: bool; [[True if actually moved]]
}
```
or old way:
```
char_next {
[[Advances to the next character]]
// FIXME: Make the number of characters we moved by? Useful for all the other functions
return: bool; [[True if actually moved]]
}
char_prev {
[[Advances to the previous character]]
return: bool; [[True if actually moved]]
}
char_delete {
[[Deletes a single character from position pointed by given cursor.]]
}
cluster_next {
[[Advances to the next grapheme cluster]]
return: bool; [[True if actually moved]]
}
cluster_prev {
[[Advances to the previous grapheme cluster]]
return: bool; [[True if actually moved]]
}
// FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character.
paragraph_start {
[[Advances to the first character in this paragraph]]
return: bool; [[True if actually moved]]
}
paragraph_end {
[[Advances to the last character in this paragraph]]
return: bool; [[True if actually moved]]
}
word_start {
[[Advance to current word start]]
return: bool; [[True if actually moved]]
}
word_end {
[[Advance to current word end]]
return: bool; [[True if actually moved]]
}
line_start {
[[Advance to current line first character]]
return: bool; [[True if actually moved]]
}
line_end {
[[Advance to current line last character]]
return: bool; [[True if actually moved]]
}
paragraph_first {
[[Advance to current paragraph first character]]
return: bool; [[True if actually moved]]
}
paragraph_last {
[[Advance to current paragraph last character]]
return: bool; [[True if actually moved]]
}
paragraph_next {
[[Advances to the start of the next text node]]
return: bool; [[True if actually moved]]
}
paragraph_prev {
[[Advances to the end of the previous text node]]
return: bool; [[True if actually moved]]
}
```
Reviewers: woohyun, tasn, segfaultxavi
Reviewed By: woohyun
Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
Eina_Size2D fw1 , fw2 , fw3 ;
2019-08-03 02:19:20 -07:00
efl_text_markup_set ( txt , text1 ) ;
2019-12-10 00:39:59 -08:00
fw1 = efl_canvas_textblock_size_native_get ( txt ) ;
2019-08-03 02:19:20 -07:00
efl_text_markup_set ( txt , text2 ) ;
2019-12-10 00:39:59 -08:00
fw2 = efl_canvas_textblock_size_native_get ( txt ) ;
Efl.Text.Cursor
Summary:
Implementation of new cursor text object.
This Patch Contains :
1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor
=> there are some modifications on cursor methods
2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces
3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory
4- Add main cursor property into efl.text.interactive
5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface)
There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement.
```
enum @beta Efl.Text.Cursor_Move_Type
{
[[Text cursor movement types]]
char_next, [[Advances to the next character]]
char_prev, [[Advances to the previous character]]
cluster_next, [[Advances to the next grapheme cluster]]
cluster_prev, [[Advances to the previous grapheme cluster]]
paragraph_start, [[Advances to the first character in this paragraph]]
paragraph_end, [[Advances to the last character in this paragraph]]
word_start, [[Advance to current word start]]
word_end, [[Advance to current word end]]
line_start, [[Advance to current line first character]]
line_end, [[Advance to current line last character]]
paragraph_first, [[Advance to current paragraph first character]]
paragraph_last, [[Advance to current paragraph last character]]
paragraph_next, [[Advances to the start of the next text node]]
paragraph_prev [[Advances to the end of the previous text node]]
}
move {
[[Move the cursor]]
params {
@in type: Efl.Text.Cursor_Move_Type; [[The type of movement]]
}
return: bool; [[True if actually moved]]
}
```
or old way:
```
char_next {
[[Advances to the next character]]
// FIXME: Make the number of characters we moved by? Useful for all the other functions
return: bool; [[True if actually moved]]
}
char_prev {
[[Advances to the previous character]]
return: bool; [[True if actually moved]]
}
char_delete {
[[Deletes a single character from position pointed by given cursor.]]
}
cluster_next {
[[Advances to the next grapheme cluster]]
return: bool; [[True if actually moved]]
}
cluster_prev {
[[Advances to the previous grapheme cluster]]
return: bool; [[True if actually moved]]
}
// FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character.
paragraph_start {
[[Advances to the first character in this paragraph]]
return: bool; [[True if actually moved]]
}
paragraph_end {
[[Advances to the last character in this paragraph]]
return: bool; [[True if actually moved]]
}
word_start {
[[Advance to current word start]]
return: bool; [[True if actually moved]]
}
word_end {
[[Advance to current word end]]
return: bool; [[True if actually moved]]
}
line_start {
[[Advance to current line first character]]
return: bool; [[True if actually moved]]
}
line_end {
[[Advance to current line last character]]
return: bool; [[True if actually moved]]
}
paragraph_first {
[[Advance to current paragraph first character]]
return: bool; [[True if actually moved]]
}
paragraph_last {
[[Advance to current paragraph last character]]
return: bool; [[True if actually moved]]
}
paragraph_next {
[[Advances to the start of the next text node]]
return: bool; [[True if actually moved]]
}
paragraph_prev {
[[Advances to the end of the previous text node]]
return: bool; [[True if actually moved]]
}
```
Reviewers: woohyun, tasn, segfaultxavi
Reviewed By: woohyun
Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
fail_if ( fw2 . w < = fw1 . w ) ;
2019-08-03 02:19:20 -07:00
efl_text_markup_set ( txt , text3 ) ;
2019-12-10 00:39:59 -08:00
fw3 = efl_canvas_textblock_size_native_get ( txt ) ;
Efl.Text.Cursor
Summary:
Implementation of new cursor text object.
This Patch Contains :
1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor
=> there are some modifications on cursor methods
2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces
3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory
4- Add main cursor property into efl.text.interactive
5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface)
There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement.
```
enum @beta Efl.Text.Cursor_Move_Type
{
[[Text cursor movement types]]
char_next, [[Advances to the next character]]
char_prev, [[Advances to the previous character]]
cluster_next, [[Advances to the next grapheme cluster]]
cluster_prev, [[Advances to the previous grapheme cluster]]
paragraph_start, [[Advances to the first character in this paragraph]]
paragraph_end, [[Advances to the last character in this paragraph]]
word_start, [[Advance to current word start]]
word_end, [[Advance to current word end]]
line_start, [[Advance to current line first character]]
line_end, [[Advance to current line last character]]
paragraph_first, [[Advance to current paragraph first character]]
paragraph_last, [[Advance to current paragraph last character]]
paragraph_next, [[Advances to the start of the next text node]]
paragraph_prev [[Advances to the end of the previous text node]]
}
move {
[[Move the cursor]]
params {
@in type: Efl.Text.Cursor_Move_Type; [[The type of movement]]
}
return: bool; [[True if actually moved]]
}
```
or old way:
```
char_next {
[[Advances to the next character]]
// FIXME: Make the number of characters we moved by? Useful for all the other functions
return: bool; [[True if actually moved]]
}
char_prev {
[[Advances to the previous character]]
return: bool; [[True if actually moved]]
}
char_delete {
[[Deletes a single character from position pointed by given cursor.]]
}
cluster_next {
[[Advances to the next grapheme cluster]]
return: bool; [[True if actually moved]]
}
cluster_prev {
[[Advances to the previous grapheme cluster]]
return: bool; [[True if actually moved]]
}
// FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character.
paragraph_start {
[[Advances to the first character in this paragraph]]
return: bool; [[True if actually moved]]
}
paragraph_end {
[[Advances to the last character in this paragraph]]
return: bool; [[True if actually moved]]
}
word_start {
[[Advance to current word start]]
return: bool; [[True if actually moved]]
}
word_end {
[[Advance to current word end]]
return: bool; [[True if actually moved]]
}
line_start {
[[Advance to current line first character]]
return: bool; [[True if actually moved]]
}
line_end {
[[Advance to current line last character]]
return: bool; [[True if actually moved]]
}
paragraph_first {
[[Advance to current paragraph first character]]
return: bool; [[True if actually moved]]
}
paragraph_last {
[[Advance to current paragraph last character]]
return: bool; [[True if actually moved]]
}
paragraph_next {
[[Advances to the start of the next text node]]
return: bool; [[True if actually moved]]
}
paragraph_prev {
[[Advances to the end of the previous text node]]
return: bool; [[True if actually moved]]
}
```
Reviewers: woohyun, tasn, segfaultxavi
Reviewed By: woohyun
Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
fail_if ( fw3 . w < = fw2 . w ) ;
2019-08-03 02:19:20 -07:00
2019-12-10 00:39:59 -08:00
END_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
2019-08-03 02:19:20 -07:00
}
EFL_END_TEST
2019-07-29 13:18:37 -07:00
EFL_START_TEST ( efl_text_font )
{
2019-12-10 00:39:59 -08:00
START_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
2019-07-29 13:18:37 -07:00
efl_text_set ( txt , " \n \n \n " ) ;
const char * font ;
int font_size ;
2019-11-27 23:55:26 -08:00
efl_text_font_family_set ( txt , " Sans " ) ;
efl_text_font_size_set ( txt , 20 ) ;
efl_text_font_family_set ( txt , NULL ) ;
efl_text_font_size_set ( txt , 0 ) ;
2019-07-29 13:18:37 -07:00
2019-11-27 23:55:26 -08:00
font = efl_text_font_family_get ( txt ) ;
font_size = efl_text_font_size_get ( txt ) ;
2019-07-29 13:18:37 -07:00
fail_if ( 20 ! = font_size ) ;
fail_if ( strcmp ( font , " Sans " ) ) ;
2019-11-27 23:55:26 -08:00
efl_text_font_family_set ( txt , NULL ) ;
efl_text_font_size_set ( txt , 30 ) ;
font = efl_text_font_family_get ( txt ) ;
font_size = efl_text_font_size_get ( txt ) ;
2019-07-29 13:18:37 -07:00
fail_if ( 30 ! = font_size ) ;
fail_if ( strcmp ( font , " Sans " ) ) ;
2019-11-27 23:55:26 -08:00
efl_text_font_family_set ( txt , " arial " ) ;
efl_text_font_size_set ( txt , 0 ) ;
font = efl_text_font_family_get ( txt ) ;
font_size = efl_text_font_size_get ( txt ) ;
2019-07-29 13:18:37 -07:00
fail_if ( 30 ! = font_size ) ;
fail_if ( strcmp ( font , " arial " ) ) ;
2019-12-10 00:39:59 -08:00
END_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
2019-07-29 13:18:37 -07:00
}
EFL_END_TEST
2019-12-10 00:39:59 -08:00
EFL_START_TEST ( efl_canvas_textblock_style )
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
{
2019-12-10 00:39:59 -08:00
START_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
unsigned char r , g , b , a ;
const char * style ;
efl_text_password_set ( txt , EINA_FALSE ) ;
efl_text_underline_type_set ( txt , EFL_TEXT_STYLE_UNDERLINE_TYPE_DOUBLE ) ;
efl_text_font_weight_set ( txt , EFL_TEXT_FONT_WEIGHT_EXTRABOLD ) ;
efl_text_font_slant_set ( txt , EFL_TEXT_FONT_SLANT_OBLIQUE ) ;
2019-12-26 01:01:32 -08:00
efl_text_tab_stops_set ( txt , 20 ) ;
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
2019-12-10 00:39:59 -08:00
efl_canvas_textblock_style_apply ( txt , " color=#90E135 " ) ;
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
2019-12-10 00:39:59 -08:00
style = efl_canvas_textblock_all_styles_get ( txt ) ;
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
// from efl_style_buf
fail_if ( ! strstr ( style , " font=DejaVuSans,UnDotum,malayalam " ) ) ;
// default value
fail_if ( ! strstr ( style , " font_width=normal " ) ) ;
2019-12-16 10:10:36 -08:00
fail_if ( ! strstr ( style , " wrap=none " ) ) ;
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
// from functions
fail_if ( ! strstr ( style , " font_weight=extrabold " ) ) ;
2020-01-09 03:14:22 -08:00
fail_if ( ! strstr ( style , " tab_stops=20 " ) ) ;
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
fail_if ( ! strstr ( style , " color=rgba(144,225,53,255) " ) ) ;
fail_if ( ! strstr ( style , " password=off " ) ) ;
efl_text_password_set ( txt , EINA_TRUE ) ;
2019-12-10 00:39:59 -08:00
style = efl_canvas_textblock_all_styles_get ( txt ) ;
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
fail_if ( ! strstr ( style , " password=on " ) ) ;
2019-12-10 00:39:59 -08:00
efl_canvas_textblock_style_apply ( txt , " font_width=ultracondensed " ) ;
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
ck_assert_int_eq ( efl_text_font_width_get ( txt ) , EFL_TEXT_FONT_WIDTH_ULTRACONDENSED ) ;
2019-12-16 10:10:36 -08:00
efl_canvas_textblock_style_apply ( txt , " wrap=word " ) ;
ck_assert_int_eq ( efl_text_wrap_get ( txt ) , EFL_TEXT_FORMAT_WRAP_WORD ) ;
2019-12-10 00:39:59 -08:00
efl_canvas_textblock_style_apply ( txt , " wrap=none " ) ;
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
ck_assert_int_eq ( efl_text_wrap_get ( txt ) , EFL_TEXT_FORMAT_WRAP_NONE ) ;
2020-02-04 08:45:32 -08:00
efl_canvas_textblock_style_apply ( txt , " background_type=solid " ) ;
2019-12-26 23:10:24 -08:00
ck_assert_int_eq ( efl_text_background_type_get ( txt ) , EFL_TEXT_STYLE_BACKGROUND_TYPE_SOLID_COLOR ) ;
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
2020-02-04 08:45:32 -08:00
efl_canvas_textblock_style_apply ( txt , " background_color=red " ) ;
efl_text_background_color_get ( txt , & r , & g , & b , & a ) ;
ck_assert_int_eq ( r , 0xFF ) ;
ck_assert_int_eq ( g , 0x00 ) ;
ck_assert_int_eq ( b , 0x00 ) ;
ck_assert_int_eq ( a , 0xFF ) ;
efl_canvas_textblock_style_apply ( txt , " effect_type=far_soft_shadow " ) ;
2019-11-27 23:46:30 -08:00
ck_assert_int_eq ( efl_text_effect_type_get ( txt ) , EFL_TEXT_STYLE_EFFECT_TYPE_FAR_SOFT_SHADOW ) ;
2020-02-04 08:45:32 -08:00
efl_canvas_textblock_style_apply ( txt , " shadow_direction=top_right " ) ;
2019-11-27 23:46:30 -08:00
ck_assert_int_eq ( efl_text_shadow_direction_get ( txt ) , EFL_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT ) ;
2020-02-04 08:45:32 -08:00
efl_canvas_textblock_style_apply ( txt , " shadow_direction=top " ) ;
2019-11-27 23:46:30 -08:00
ck_assert_int_eq ( efl_text_shadow_direction_get ( txt ) , EFL_TEXT_STYLE_SHADOW_DIRECTION_TOP ) ;
2020-02-04 08:45:32 -08:00
efl_canvas_textblock_style_apply ( txt , " effect_type=soft_outline " ) ;
2019-11-27 23:46:30 -08:00
ck_assert_int_eq ( efl_text_effect_type_get ( txt ) , EFL_TEXT_STYLE_EFFECT_TYPE_SOFT_OUTLINE ) ;
2020-02-04 08:45:32 -08:00
efl_canvas_textblock_style_apply ( txt , " underline_type=none " ) ;
ck_assert_int_eq ( efl_text_underline_type_get ( txt ) , EFL_TEXT_STYLE_UNDERLINE_TYPE_NONE ) ;
efl_canvas_textblock_style_apply ( txt , " strikethrough_type=single " ) ;
ck_assert_int_eq ( efl_text_strikethrough_type_get ( txt ) , EFL_TEXT_STYLE_STRIKETHROUGH_TYPE_SINGLE ) ;
2019-11-27 23:46:30 -08:00
2019-12-10 00:39:59 -08:00
efl_canvas_textblock_style_apply ( txt , " color=#EF596C " ) ;
2019-12-20 00:49:41 -08:00
efl_text_color_get ( txt , & r , & g , & b , & a ) ;
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
ck_assert_int_eq ( r , 0xEF ) ;
ck_assert_int_eq ( g , 0x59 ) ;
ck_assert_int_eq ( b , 0x6C ) ;
ck_assert_int_eq ( a , 0xFF ) ;
2019-12-10 00:39:59 -08:00
END_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
Efl Canvas Text : Modify Style Property
Summary:
This patch defines the way style property will work at canvas_text object
1- Changing canvas_text style property using Font/Format/Style interfaces or with efl_canvas_text style property are the same.
Example:
```
efl_text_font_set(tb, "Arial", 30);
//is same as
efl_canvas_text_style_set(tb, "font=Arial font_size=30");
//which means calling
char * font;
int size;
int font_size;
efl_text_font_get(tb, &font, &size);
// calling this after any of the top two functions will return same result
```
2- style_get_property
Will return string that contains full details about all the current applied style at canvas_text level.
3- style_set_property
Will only override passed styles and leave everything else as it is
```
efl_canvas_text_style_set(tb, "font=Arial"); // overrider font name to Arial and leave everthing else
efl_canvas_text_style_set(tb, "font_size=30"); // overrider font size to 30 and leave everthing else (font name will stay arial)
```
Reviewers: ali.alzyod, woohyun, tasn, segfaultxavi, bu5hm4n, zmike
Reviewed By: woohyun
Subscribers: zmike, bu5hm4n, segfaultxavi, a.srour, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10607
2019-11-27 20:14:15 -08:00
}
EFL_END_TEST
2019-12-29 20:27:13 -08:00
EFL_START_TEST ( efl_text_style )
{
START_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
2020-02-11 03:03:00 -08:00
Eina_Size2D size1 , size2 ;
2019-12-29 20:27:13 -08:00
2020-01-07 00:32:19 -08:00
int changed_emit = 0 ;
efl_event_callback_add ( txt , EFL_CANVAS_TEXTBLOCK_EVENT_CHANGED , _increment_int_changed , & changed_emit ) ;
efl_text_set ( txt , " Hello " ) ;
ck_assert_int_eq ( changed_emit , 1 ) ;
efl_text_set ( txt , " " ) ;
ck_assert_int_eq ( changed_emit , 2 ) ;
efl_text_set ( txt , " " ) ;
ck_assert_int_eq ( changed_emit , 2 ) ;
changed_emit = 0 ;
efl_text_markup_set ( txt , " "Hello" " ) ;
ck_assert_int_eq ( changed_emit , 1 ) ;
efl_text_markup_set ( txt , " " ) ;
ck_assert_int_eq ( changed_emit , 2 ) ;
efl_text_markup_set ( txt , " " ) ;
ck_assert_int_eq ( changed_emit , 2 ) ;
2020-02-11 03:03:00 -08:00
// Style Applying
efl_text_set ( txt , " A " ) ;
efl_canvas_textblock_style_apply ( txt , " \t font_size=2 \t " ) ;
size1 = efl_canvas_textblock_size_native_get ( txt ) ;
efl_canvas_textblock_style_apply ( txt , " \n font_size=20 \n " ) ;
size2 = efl_canvas_textblock_size_native_get ( txt ) ;
ck_assert ( size1 . w < size2 . w ) ;
ck_assert ( size1 . h < size2 . h ) ;
2020-01-07 00:32:19 -08:00
END_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
}
EFL_END_TEST
EFL_START_TEST ( efl_text_markup )
{
START_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
2019-12-29 20:27:13 -08:00
efl_text_underline_type_set ( txt , EFL_TEXT_STYLE_UNDERLINE_TYPE_NONE ) ;
ck_assert_int_eq ( efl_text_underline_type_get ( txt ) , EFL_TEXT_STYLE_UNDERLINE_TYPE_NONE ) ;
efl_text_underline_type_set ( txt , EFL_TEXT_STYLE_UNDERLINE_TYPE_SINGLE ) ;
ck_assert_int_eq ( efl_text_underline_type_get ( txt ) , EFL_TEXT_STYLE_UNDERLINE_TYPE_SINGLE ) ;
efl_text_underline_type_set ( txt , EFL_TEXT_STYLE_UNDERLINE_TYPE_DOUBLE ) ;
ck_assert_int_eq ( efl_text_underline_type_get ( txt ) , EFL_TEXT_STYLE_UNDERLINE_TYPE_DOUBLE ) ;
efl_text_underline_type_set ( txt , EFL_TEXT_STYLE_UNDERLINE_TYPE_DASHED ) ;
ck_assert_int_eq ( efl_text_underline_type_get ( txt ) , EFL_TEXT_STYLE_UNDERLINE_TYPE_DASHED ) ;
END_EFL_CANVAS_TEXTBLOCK_TEST ( ) ;
}
EFL_END_TEST
2012-11-14 12:12:53 -08:00
void evas_test_textblock ( TCase * tc )
{
tcase_add_test ( tc , evas_textblock_simple ) ;
tcase_add_test ( tc , evas_textblock_cursor ) ;
2013-04-11 09:47:51 -07:00
# ifdef HAVE_FRIBIDI
2013-04-10 04:54:37 -07:00
tcase_add_test ( tc , evas_textblock_split_cursor ) ;
2013-04-10 06:59:33 -07:00
# endif
2012-11-14 12:12:53 -08:00
tcase_add_test ( tc , evas_textblock_size ) ;
tcase_add_test ( tc , evas_textblock_editing ) ;
tcase_add_test ( tc , evas_textblock_style ) ;
2018-05-05 12:15:54 -07:00
tcase_add_test ( tc , evas_textblock_style_user ) ;
2012-11-14 12:12:53 -08:00
tcase_add_test ( tc , evas_textblock_evas ) ;
tcase_add_test ( tc , evas_textblock_text_getters ) ;
tcase_add_test ( tc , evas_textblock_formats ) ;
tcase_add_test ( tc , evas_textblock_format_removal ) ;
tcase_add_test ( tc , evas_textblock_escaping ) ;
tcase_add_test ( tc , evas_textblock_set_get ) ;
tcase_add_test ( tc , evas_textblock_geometries ) ;
tcase_add_test ( tc , evas_textblock_various ) ;
tcase_add_test ( tc , evas_textblock_wrapping ) ;
tcase_add_test ( tc , evas_textblock_items ) ;
2014-06-17 03:09:26 -07:00
tcase_add_test ( tc , evas_textblock_delete ) ;
2015-07-01 08:24:31 -07:00
tcase_add_test ( tc , evas_textblock_obstacle ) ;
evas_textblock: content fit feature
Summary:
**Content Fit Feature for Evas_Object_Textblock**
This Feature is available at **Evas **object level. And **Edje **level (where it is internally use evas functionality)
This feature will allow text block to fit its content font size to proper size to fit its area.
**Main Properties:**
Fit Modes : None=Default, Width, Height, All [Width+Height]
Fit Size Range : Contains maximum and minimum font size to be used (and in between).
Fit Step Size : Step(Jump) value when trying fonts sizes between Size_Range max and min.
Fit Size Array : Other way to resize font, where you explicitly select font sizes to be uses (for example [20, 50, 100] it will try 3 sizes only)
Text Fit feature was available in Edje but:
1- It doesn't effected by ellipsis or warping in font style (or do not handle the in right way)
2- Accuracy is not good (specially if you have fix pixel size elements (spaces,tabs,items))
3- No (Step size, Size Array) available.
Test Plan:
To check the Feature
> elementary_test
> fit
> textbock fit
You can modify all the modes and properties
These are two examples, One using Evas other uses Edje
**Evas**
```
#include <Elementary.h>
enum BUTTON{
BUTTON_MODE = 0,
BUTTON_MAX = 1,
BUTTON_MIN = 2,
BUTTON_STEP = 3,
BUTTON_ARRAY = 4,
BUTTON_CONTENT = 5,
BUTTON_STYLE = 6,
BUTTON_ALL = BUTTON_STYLE+1,
};
char* BUTTON_STR[BUTTON_ALL] ={
"MODE",
"MAX",
"MIN",
"STEP",
"ARRAY",
"CONTENT",
"STYLE",
};
char *contents[] = {
"Hello World",
"This is Line<br>THis is other Line",
"This text contains <font_size=20 color=#F00>SPECIFIC SIZE</font_size> that does not effected by fit mode"
};
char *styles[] = {
"DEFAULT='font=sans font_size=30 color=#000 wrap=mixed ellipsis=1.0'",
"DEFAULT='font=sans font_size=30 color=#000 wrap=mixed'",
"DEFAULT='font=sans font_size=30 color=#000 ellipsis=1.0'",
"DEFAULT='font=sans font_size=30 color=#000'",
};
char *styles_names[] = {
"wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>1.0</color>",
"wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>NONE</color>",
"wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>1.0</color>",
"wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>NONE</color>",
};
typedef struct _APP
{
Evas_Object *win, *box, *txtblock,*bg, *boxHor, *boxHor2;
Eo *btn[BUTTON_ALL];
Eo *lbl_status;
char * str;
unsigned int i_contnet, i_style;
} APP;
APP *app;
char * get_fit_status(Eo * textblock);
static void _btn_clicked(void *data EINA_UNUSED, Eo *obj, void *eventInfo EINA_UNUSED){
if (obj == app->btn[BUTTON_MODE])
{
unsigned int options;
evas_textblock_fit_options_get(app->txtblock, &options);
if (options == TEXTBLOCK_FIT_MODE_NONE)
evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_HEIGHT);
else if (options == TEXTBLOCK_FIT_MODE_HEIGHT)
evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_WIDTH);
else if (options == TEXTBLOCK_FIT_MODE_WIDTH)
evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_ALL);
else if (options == TEXTBLOCK_FIT_MODE_ALL)
evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_NONE);
}
else if (obj == app->btn[BUTTON_MAX])
{
unsigned int min, max;
evas_textblock_fit_size_range_get(app->txtblock, &min, &max);
max -= 5;
evas_textblock_fit_size_range_set(app->txtblock, min, max);
}
else if (obj == app->btn[BUTTON_MIN])
{
unsigned int min, max;
evas_textblock_fit_size_range_get(app->txtblock, &min, &max);
min += 5;
evas_textblock_fit_size_range_set(app->txtblock, min, max);
}
else if (obj == app->btn[BUTTON_STEP])
{
unsigned int step;
evas_textblock_fit_step_size_get(app->txtblock, &step);
step++;
evas_textblock_fit_step_size_set(app->txtblock, step);
}
else if (obj == app->btn[BUTTON_ARRAY])
{
unsigned int font_size[] = {10, 50, 100 ,150};
evas_textblock_fit_size_array_set(app->txtblock,font_size,4);
}
else if (obj == app->btn[BUTTON_CONTENT])
{
app->i_contnet++;
if(app->i_contnet>=sizeof(contents)/sizeof(char*))
app->i_contnet=0;
evas_object_textblock_text_markup_set(app->txtblock,contents[app->i_contnet]);
}
else if (obj == app->btn[BUTTON_STYLE])
{
app->i_style++;
if(app->i_style>=sizeof(styles)/sizeof(char*))
app->i_style=0;
Evas_Textblock_Style *style = evas_object_textblock_style_get(app->txtblock);
evas_textblock_style_set(style,styles[app->i_style]);
}
elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock));
}
char * get_fit_status(Eo * textblock)
{
static char status[0xFFF];
unsigned int options,min,max,step,size_array[256];
size_t size_array_len;
evas_textblock_fit_options_get(textblock,&options);
evas_textblock_fit_size_range_get(textblock,&min,&max);
evas_textblock_fit_step_size_get(textblock,&step);
evas_textblock_fit_size_array_get(textblock,NULL,&size_array_len,0);
if (size_array_len>255)
size_array_len = 255;
evas_textblock_fit_size_array_get(textblock,size_array,NULL,size_array_len);
strcpy(status,"Mode : ");
if (options == TEXTBLOCK_FIT_MODE_NONE)
strcat(status,"MODE_NONE");
else if (options == TEXTBLOCK_FIT_MODE_HEIGHT)
strcat(status,"MODE_HEIGHT");
else if (options == TEXTBLOCK_FIT_MODE_WIDTH)
strcat(status,"MODE_WIDTH");
else if (options == TEXTBLOCK_FIT_MODE_ALL)
strcat(status,"MODE_ALL");
strcat(status,"<br>");
sprintf(status + strlen(status),"Max : %d<br>",max);
sprintf(status + strlen(status),"Min : %d<br>",min);
sprintf(status + strlen(status),"Step : %d<br>",step);
sprintf(status + strlen(status),"Array : [ ");
for (size_t i = 0 ; i < 10 ; i++)
{
if(i<size_array_len)
sprintf(status + strlen(status)," %d,",size_array[i]);
}
if(10<size_array_len)
sprintf(status + strlen(status)," ... ");
sprintf(status + strlen(status)," ]");
sprintf(status + strlen(status),"<br>");
sprintf(status + strlen(status),"%s",styles_names[app->i_style]);
return status;
}
int elm_main(int argc, char **argv)
{
app = calloc(sizeof(APP), 1);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
app->win = elm_win_util_standard_add("Main", "App");
elm_win_autodel_set(app->win, EINA_TRUE);
app->box = elm_box_add(app->win);
app->boxHor = elm_box_add(app->box);
app->boxHor2 = elm_box_add(app->box);
app->txtblock = evas_object_textblock_add(app->box);
app->bg = elm_bg_add(app->box);
elm_bg_color_set(app->bg,255,255,255);
Evas_Textblock_Style *style = evas_textblock_style_new();
evas_textblock_style_set(style,styles[0]);
evas_object_textblock_style_set(app->txtblock,style);
evas_object_textblock_text_markup_set(app->txtblock,contents[0]);
elm_box_horizontal_set(app->boxHor, EINA_TRUE);
elm_box_horizontal_set(app->boxHor2, EINA_TRUE);
evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(app->txtblock);
evas_object_show(app->bg);
evas_object_show(app->box);
evas_object_show(app->boxHor);
evas_object_show(app->boxHor2);
elm_box_pack_end(app->box, app->bg);
elm_box_pack_end(app->box, app->boxHor);
elm_box_pack_end(app->box, app->boxHor2);
elm_object_content_set(app->bg,app->txtblock);
elm_win_resize_object_add(app->win, app->box);
evas_object_resize(app->win, 320, 480);
for(int i = 0 ; i < BUTTON_ALL ; i++)
{
app->btn[i] = elm_button_add(app->boxHor);
evas_object_smart_callback_add(app->btn[i], "clicked", _btn_clicked, NULL);
elm_object_text_set(app->btn[i], BUTTON_STR[i]);
elm_box_pack_end(app->boxHor, app->btn[i]);
evas_object_show(app->btn[i]);
}
app->lbl_status = elm_label_add(app->boxHor2);
elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock));
elm_box_pack_end(app->boxHor2, app->lbl_status);
evas_object_show(app->lbl_status);
evas_object_size_hint_weight_set(app->txtblock, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(app->txtblock, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(app->bg, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(app->bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(app->win);
elm_run();
return 0;
}
ELM_MAIN()
```
**Edje**
```
// compile: edje_cc source.edc
// run: edje_player source.edje
collections {
styles
{
style
{
name: "text_style";
base: "font=sans font_size=30 color=#FFF wrap=mixed ellipsis=1.0";
tag: "br" "\n";
tag: "ps" "ps";
tag: "tab" "\t";
tag: "b" "+ font_weight=Bold";
}
}
group {
name: "my_group"; // must be the same as in source.c
parts {
part
{
name: "background";
type: RECT;
scale: 1;
description
{
color: 0 0 0 0;
rel1.relative: 0.0 0.0;
rel2.relative: 1.0 1.0;
}
}
part
{
name: "text";
type: TEXTBLOCK;
scale: 1;
entry_mode: NONE;
effect: OUTLINE_SHADOW;
description
{
state: "default" 0.0;
rel1.to : "background";
rel1.relative: 0.0 0.0;
rel2.to : "background";
rel2.relative: 1.0 1.0;
text
{
style: "text_style";
align: 0.0 0.0;
text: "Hello World This is Me";
fit: 1 1;
fit_step: 1;
size_range: 30 200;
//fit_size_array: 20 40 60 80 100 200;
}
}
}
}
}
}
```
Found Task T5724 relative to this Feature
Reviewers: woohyun, bowonryu, cedric, raster
Reviewed By: woohyun
Subscribers: a.srour, #committers, #reviewers, cedric
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D9280
2019-12-11 21:22:45 -08:00
tcase_add_test ( tc , evas_textblock_fit ) ;
2016-02-12 04:12:00 -08:00
# ifdef HAVE_HYPHEN
2015-11-11 23:49:08 -08:00
tcase_add_test ( tc , evas_textblock_hyphenation ) ;
2016-02-12 04:12:00 -08:00
# endif
2016-05-24 06:11:03 -07:00
tcase_add_test ( tc , evas_textblock_text_iface ) ;
tcase_add_test ( tc , evas_textblock_annotation ) ;
2019-12-10 00:39:59 -08:00
tcase_add_test ( tc , efl_canvas_textblock_simple ) ;
2018-09-07 02:34:37 -07:00
tcase_add_test ( tc , efl_text ) ;
2019-12-10 00:39:59 -08:00
tcase_add_test ( tc , efl_canvas_textblock_cursor ) ;
tcase_add_test ( tc , efl_canvas_textblock_markup ) ;
tcase_add_test ( tc , efl_canvas_textblock_markup_invalid_escape ) ;
2019-07-29 13:18:37 -07:00
tcase_add_test ( tc , efl_text_font ) ;
2019-12-10 00:39:59 -08:00
tcase_add_test ( tc , efl_canvas_textblock_style ) ;
2019-12-29 20:27:13 -08:00
tcase_add_test ( tc , efl_text_style ) ;
2020-01-07 00:32:19 -08:00
tcase_add_test ( tc , efl_text_markup ) ;
2012-11-14 12:12:53 -08:00
}