2016-06-08 08:37:35 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
#define EO_BETA_API
|
2019-03-07 07:39:06 -08:00
|
|
|
#include <Efl_Ui.h>
|
2016-06-08 08:37:35 -07:00
|
|
|
#include <Elementary.h>
|
2019-09-27 08:07:17 -07:00
|
|
|
#include "elm_priv.h" //FIXME remove this once efl.ui.text doesn't need elm_general.h
|
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
|
|
|
|
2016-12-01 03:25:11 -08:00
|
|
|
static void
|
|
|
|
_apply_style(Eo *obj, size_t start_pos, size_t end_pos, const char *style)
|
|
|
|
{
|
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 *start, *end;
|
2016-12-01 03:25:11 -08:00
|
|
|
|
2019-12-10 16:47:50 -08:00
|
|
|
start = efl_ui_textbox_cursor_create(obj);
|
|
|
|
end = efl_ui_textbox_cursor_create(obj);
|
2016-12-01 03:25:11 -08:00
|
|
|
|
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_position_set(start, start_pos);
|
|
|
|
efl_text_cursor_position_set(end, end_pos);
|
2016-12-01 03:25:11 -08:00
|
|
|
|
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_text_attribute_factory_attribute_insert(start, end, style);
|
2017-06-08 04:31:42 -07:00
|
|
|
|
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(start);
|
|
|
|
efl_del(end);
|
2016-12-01 03:25:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eo *
|
|
|
|
_create_label(Eo *win, Eo *bx)
|
|
|
|
{
|
|
|
|
Eo *en;
|
2019-12-10 16:47:50 -08:00
|
|
|
en = efl_add(EFL_UI_TEXTBOX_CLASS, win);
|
|
|
|
printf("Added Efl.Ui.Textbox object\n");
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_editable_set(en, EINA_FALSE);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_pack(bx, en);
|
2016-12-01 03:25:11 -08:00
|
|
|
return en;
|
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
|
2016-12-01 03:25:11 -08:00
|
|
|
void
|
|
|
|
test_efl_ui_text_label(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Evas_Object *win, *bx;
|
|
|
|
Eo *en;
|
2017-09-28 09:26:41 -07:00
|
|
|
char *markup;
|
2016-12-01 03:25:11 -08:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
win = efl_add_ref(EFL_UI_WIN_CLASS, NULL,
|
2019-09-20 05:57:09 -07:00
|
|
|
efl_text_set(efl_added, "Efl Canvas_Layout"),
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
|
2016-12-01 03:25:11 -08:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
bx = efl_add(EFL_UI_BOX_CLASS, win);
|
|
|
|
efl_content_set(win, bx);
|
2016-12-01 03:25:11 -08:00
|
|
|
|
|
|
|
en = _create_label(win, bx);
|
2017-06-22 08:03:45 -07:00
|
|
|
efl_text_set(en, "This is a\t small label");
|
2016-12-01 03:25:11 -08:00
|
|
|
// 012345678901234567890
|
|
|
|
_apply_style(en, 0, 21, "font_size=12 font_weight=bold");
|
2017-06-22 08:03:45 -07:00
|
|
|
efl_text_font_weight_set(en, EFL_TEXT_FONT_WEIGHT_BOLD);
|
2016-12-01 03:25:11 -08:00
|
|
|
|
|
|
|
en = _create_label(win, bx);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_set(en, "This is a text. It is longer but its size is taken as the"
|
|
|
|
" min size so that it shows in whole");
|
2016-12-01 03:25:11 -08:00
|
|
|
_apply_style(en, 40, 45, "font_weight=bold color=#ff0");
|
|
|
|
_apply_style(en, 52, 58, "font_weight=italic color=#f00");
|
2017-06-22 08:03:45 -07:00
|
|
|
|
|
|
|
en = _create_label(win, bx);
|
|
|
|
efl_text_set(en, "By default 'multiline' is disabled.\n"
|
|
|
|
"So, \\n would only work if you enable it.");
|
2016-12-01 03:25:11 -08:00
|
|
|
|
2017-09-28 09:26:41 -07:00
|
|
|
en = _create_label(win, bx);
|
|
|
|
efl_text_markup_set(en, "You can also <b>ENTER</b> markup!");
|
2019-11-27 23:55:26 -08:00
|
|
|
efl_text_font_family_set(en, "Sans");
|
|
|
|
efl_text_font_size_set(en, 14);
|
2017-09-28 09:26:41 -07:00
|
|
|
efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD);
|
|
|
|
efl_text_multiline_set(en, EINA_TRUE);
|
|
|
|
|
|
|
|
en = _create_label(win, bx);
|
2019-02-09 09:45:27 -08:00
|
|
|
markup = efl_text_markup_util_text_to_markup(
|
2017-09-28 09:26:41 -07:00
|
|
|
"You can use the text -> markup helper\nto make coding easier.");
|
|
|
|
efl_text_markup_set(en, markup);
|
|
|
|
free(markup);
|
2019-11-27 23:55:26 -08:00
|
|
|
efl_text_font_family_set(en, "Sans");
|
|
|
|
efl_text_font_size_set(en, 14);
|
2017-09-28 09:26:41 -07:00
|
|
|
efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD);
|
|
|
|
efl_text_multiline_set(en, EINA_TRUE);
|
|
|
|
|
|
|
|
en = _create_label(win, bx);
|
2019-02-09 09:45:27 -08:00
|
|
|
markup = efl_text_markup_util_markup_to_text(
|
2017-09-28 09:26:41 -07:00
|
|
|
"You can use markup -> text helpers<ps>to make coding easier.");
|
|
|
|
efl_text_set(en, markup);
|
|
|
|
free(markup);
|
2019-11-27 23:55:26 -08:00
|
|
|
efl_text_font_family_set(en, "Sans");
|
|
|
|
efl_text_font_size_set(en, 14);
|
2017-09-28 09:26:41 -07:00
|
|
|
efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD);
|
|
|
|
efl_text_multiline_set(en, EINA_TRUE);
|
2016-12-01 03:25:11 -08:00
|
|
|
}
|
2016-12-08 02:03:02 -08:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char *wrap_mode[4];
|
|
|
|
size_t cur_wrap;
|
|
|
|
} Test_Data;
|
|
|
|
|
|
|
|
static void
|
2018-09-13 02:45:29 -07:00
|
|
|
_on_bt3_clicked(void *data, const Efl_Event *event EINA_UNUSED)
|
2016-12-08 02:03:02 -08:00
|
|
|
{
|
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 *sel_start, *sel_end;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *en = data;
|
2016-12-08 02:03:02 -08:00
|
|
|
|
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_interactive_selection_cursors_get(en, &sel_start, &sel_end);
|
|
|
|
const char *s = efl_text_cursor_range_text_get(sel_start, sel_end);
|
2016-12-08 02:03:02 -08:00
|
|
|
|
|
|
|
printf("SELECTION REGION: %d - %d\n",
|
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_position_get( sel_start),
|
|
|
|
efl_text_cursor_position_get(sel_end));
|
2016-12-08 02:03:02 -08:00
|
|
|
printf("SELECTION:\n");
|
|
|
|
if (s) printf("%s\n", s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-09-13 02:45:29 -07:00
|
|
|
_on_bt6_clicked(void *data, const Efl_Event *event EINA_UNUSED)
|
2016-12-08 02:03:02 -08:00
|
|
|
{
|
2017-05-23 06:04:04 -07:00
|
|
|
Eo *text_obj = data;
|
|
|
|
|
2017-06-11 14:16:40 -07:00
|
|
|
Efl_Text_Format_Wrap wrap = efl_text_wrap_get(text_obj);
|
2017-05-23 06:04:04 -07:00
|
|
|
|
|
|
|
switch(wrap)
|
|
|
|
{
|
|
|
|
case EFL_TEXT_FORMAT_WRAP_NONE:
|
|
|
|
wrap = EFL_TEXT_FORMAT_WRAP_CHAR;
|
|
|
|
break;
|
|
|
|
case EFL_TEXT_FORMAT_WRAP_CHAR:
|
|
|
|
wrap = EFL_TEXT_FORMAT_WRAP_WORD;
|
|
|
|
break;
|
|
|
|
case EFL_TEXT_FORMAT_WRAP_WORD:
|
|
|
|
wrap = EFL_TEXT_FORMAT_WRAP_MIXED;
|
|
|
|
break;
|
|
|
|
case EFL_TEXT_FORMAT_WRAP_MIXED:
|
|
|
|
wrap = EFL_TEXT_FORMAT_WRAP_NONE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-06-11 14:16:40 -07:00
|
|
|
efl_text_wrap_set(text_obj, wrap);
|
2016-12-08 02:03:02 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
test_efl_ui_text(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *win, *bx, *bx2, *en;
|
|
|
|
Eo *bt;
|
2016-12-08 02:03:02 -08:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
|
2019-09-20 05:57:09 -07:00
|
|
|
efl_text_set(efl_added, "Efl Ui Text"),
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
|
2016-12-08 02:03:02 -08:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
bx = efl_add(EFL_UI_BOX_CLASS, win);
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(bx, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_content_set(win, bx);
|
2016-12-08 02:03:02 -08:00
|
|
|
|
2019-12-10 16:47:50 -08:00
|
|
|
en = efl_add(EFL_UI_TEXTBOX_CLASS, bx,
|
2017-06-11 14:16:40 -07:00
|
|
|
efl_text_multiline_set(efl_added, EINA_TRUE));
|
2016-12-08 02:03:02 -08:00
|
|
|
|
2019-12-10 16:47:50 -08:00
|
|
|
printf("Added Efl.Ui.Textbox object\n");
|
2016-12-08 02:03:02 -08:00
|
|
|
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_editable_set(en, EINA_TRUE);
|
2019-12-10 16:47:50 -08:00
|
|
|
efl_ui_textbox_scrollable_set(en, EINA_TRUE);
|
2016-12-08 02:03:02 -08:00
|
|
|
|
2019-11-27 23:55:26 -08:00
|
|
|
efl_text_font_family_set(en, "Sans");
|
|
|
|
efl_text_font_size_set(en, 12);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_font_width_set(en, EFL_TEXT_FONT_WIDTH_ULTRACONDENSED);
|
|
|
|
efl_text_normal_color_set(en, 255, 255, 255, 255);
|
2016-12-08 02:03:02 -08:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_set(en,
|
|
|
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n"
|
|
|
|
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim\n"
|
|
|
|
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\n"
|
|
|
|
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate\n"
|
|
|
|
"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint\n"
|
|
|
|
"occaecat cupidatat non proident, sunt in culpa qui officia deserunt\n"
|
|
|
|
"mollit anim id est laborum");
|
|
|
|
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_size_min_set(en, EINA_SIZE2D(300, 100));
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_pack(bx, en);
|
|
|
|
|
|
|
|
bx2 = efl_add(EFL_UI_BOX_CLASS, bx);
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(bx2, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND);
|
2019-05-24 09:30:31 -07:00
|
|
|
efl_ui_layout_orientation_set(bx2, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL);
|
2018-09-13 02:45:29 -07:00
|
|
|
|
|
|
|
bt = efl_add(EFL_UI_BUTTON_CLASS, bx2);
|
|
|
|
efl_text_set(bt, "Sel");
|
2019-07-29 02:42:34 -07:00
|
|
|
efl_event_callback_add(bt, EFL_INPUT_EVENT_CLICKED, _on_bt3_clicked, en);
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(bt, EFL_GFX_HINT_EXPAND, 0.0);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_pack(bx2, bt);
|
|
|
|
elm_object_focus_allow_set(bt, EINA_FALSE);
|
2016-12-08 02:03:02 -08:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
bt = efl_add(EFL_UI_BUTTON_CLASS, bx2);
|
|
|
|
efl_text_set(bt, "Wr");
|
2019-07-29 02:42:34 -07:00
|
|
|
efl_event_callback_add(bt, EFL_INPUT_EVENT_CLICKED, _on_bt6_clicked, en);
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(bt, EFL_GFX_HINT_EXPAND, 0.0);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_pack(bx2, bt);
|
|
|
|
elm_object_focus_allow_set(bt, EINA_FALSE);
|
2016-12-08 02:03:02 -08:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_pack(bx, bx2);
|
2016-12-08 02:03:02 -08:00
|
|
|
}
|
2017-09-11 22:38:51 -07:00
|
|
|
|
|
|
|
void
|
2018-09-13 02:45:29 -07:00
|
|
|
test_efl_ui_text_inputfield(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2017-09-11 22:38:51 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *win, *bx, *en;
|
|
|
|
|
|
|
|
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
|
2019-09-20 05:57:09 -07:00
|
|
|
efl_text_set(efl_added, "Efl Ui Text Input Field"),
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
|
2017-09-11 22:38:51 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
bx = efl_add(EFL_UI_BOX_CLASS, win);
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(bx, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_content_set(win, bx);
|
2017-09-11 22:38:51 -07:00
|
|
|
|
2019-12-10 16:47:50 -08:00
|
|
|
en = efl_add(EFL_UI_TEXTBOX_CLASS, bx,
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_multiline_set(efl_added, EINA_FALSE));
|
2017-09-11 22:38:51 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_interactive_editable_set(en, EINA_TRUE);
|
2019-12-10 16:47:50 -08:00
|
|
|
efl_ui_textbox_scrollable_set(en, EINA_TRUE);
|
2017-09-11 22:38:51 -07:00
|
|
|
|
2019-12-10 16:47:50 -08:00
|
|
|
printf("Added Efl.Ui.Textbox object\n");
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_font_width_set(en, EFL_TEXT_FONT_WIDTH_ULTRACONDENSED);
|
2018-11-12 08:57:42 -08:00
|
|
|
efl_text_set(efl_part(en, "efl.text_guide"), "Enter you name here");
|
2017-09-11 22:38:51 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_pack(bx, en);
|
2017-09-11 22:38:51 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
en = _create_label(win, bx);
|
2018-11-13 05:17:28 -08:00
|
|
|
efl_text_set(en, "This is a multiline input.\n"
|
2018-09-13 02:45:29 -07:00
|
|
|
"Enter multiline here");
|
|
|
|
efl_text_interactive_editable_set(en, EINA_TRUE);
|
|
|
|
efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD);
|
|
|
|
efl_text_multiline_set(en, EINA_TRUE);
|
2019-12-10 16:47:50 -08:00
|
|
|
efl_ui_textbox_scrollable_set(en, EINA_TRUE);
|
2018-09-13 02:45:29 -07:00
|
|
|
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.5);
|
|
|
|
efl_pack(bx, en);
|
2017-09-11 22:38:51 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 200));
|
2017-09-11 22:38:51 -07:00
|
|
|
|
|
|
|
}
|