summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/evas_object_textblock.c
diff options
context:
space:
mode:
authorDaniel Hirt <hirt.danny@gmail.com>2018-09-07 12:34:37 +0300
committerDaniel Hirt <hirt.danny@gmail.com>2018-11-05 17:31:06 +0200
commit2caa38f1664ea4729d0b0ac7c4f8d1b96d475d9b (patch)
treeb18c4d69dfa4dae90cf10c7318e50d292293e4b4 /src/lib/evas/canvas/evas_object_textblock.c
parentedae5021bc21944568de18367607fcbe8ee89aaf (diff)
Canvas text: fix line_jump_by logic
Some cases of line_jump_by did not emit "cursor,changed" when it should have. @fix
Diffstat (limited to 'src/lib/evas/canvas/evas_object_textblock.c')
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c55
1 files changed, 35 insertions, 20 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index c0f9637..788c7c3 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -10201,11 +10201,19 @@ _efl_canvas_text_efl_text_cursor_cursor_line_jump_by(Eo *eo_obj EINA_UNUSED, Efl
10201{ 10201{
10202 ASYNC_BLOCK; 10202 ASYNC_BLOCK;
10203 int ln; 10203 int ln;
10204
10205 ln = evas_textblock_cursor_line_geometry_get(cur, NULL, NULL, NULL, NULL) + by;
10206 Evas_Coord cx, cw; 10204 Evas_Coord cx, cw;
10207 Evas_Coord lx, ly, lw, lh; 10205 Evas_Coord lx, ly, lw, lh;
10208 int last; 10206 int last;
10207 Evas_Object_Textblock_Node_Text *pnode;
10208 size_t ppos;
10209
10210
10211 ln = evas_textblock_cursor_line_geometry_get(cur, NULL, NULL, NULL, NULL) + by;
10212
10213 if (!cur) return;
10214
10215 pnode = cur->node;
10216 ppos = cur->pos;
10209 10217
10210 evas_textblock_cursor_geometry_get(cur, &cx, NULL, &cw, NULL, NULL, EVAS_TEXTBLOCK_CURSOR_UNDER); 10218 evas_textblock_cursor_geometry_get(cur, &cx, NULL, &cw, NULL, NULL, EVAS_TEXTBLOCK_CURSOR_UNDER);
10211 cx += (cw / 2); 10219 cx += (cw / 2);
@@ -10215,33 +10223,40 @@ _efl_canvas_text_efl_text_cursor_cursor_line_jump_by(Eo *eo_obj EINA_UNUSED, Efl
10215 if (ln < 0) 10223 if (ln < 0)
10216 { 10224 {
10217 evas_textblock_cursor_paragraph_first(cur); 10225 evas_textblock_cursor_paragraph_first(cur);
10218 return;
10219 } 10226 }
10220 if (ln > last) 10227
10228 else if (ln > last)
10221 { 10229 {
10222 evas_textblock_cursor_paragraph_last(cur); 10230 evas_textblock_cursor_paragraph_last(cur);
10223 return;
10224 } 10231 }
10225 10232
10226 if (!evas_object_textblock_line_number_geometry_get(cur->obj, ln, &lx, &ly, &lw, &lh))
10227 return;
10228 if (evas_textblock_cursor_char_coord_set(cur, cx, ly + (lh / 2)))
10229 return;
10230 evas_textblock_cursor_line_set(cur, ln);
10231 if (cx < (lx + (lw / 2)))
10232 {
10233 if (ln == last) evas_textblock_cursor_paragraph_last(cur);
10234 evas_textblock_cursor_line_char_first(cur);
10235 }
10236 else 10233 else
10237 { 10234 {
10238 if (ln == last) 10235 if (evas_object_textblock_line_number_geometry_get(cur->obj,
10239 evas_textblock_cursor_paragraph_last(cur); 10236 ln, &lx, &ly, &lw, &lh) &&
10240 else 10237 (!evas_textblock_cursor_char_coord_set(cur, cx, ly + (lh / 2))))
10241 evas_textblock_cursor_line_char_last(cur); 10238 {
10239 evas_textblock_cursor_line_set(cur, ln);
10240 if (cx < (lx + (lw / 2)))
10241 {
10242 if (ln == last) evas_textblock_cursor_paragraph_last(cur);
10243 evas_textblock_cursor_line_char_first(cur);
10244 }
10245 else
10246 {
10247 if (ln == last)
10248 evas_textblock_cursor_paragraph_last(cur);
10249 else
10250 evas_textblock_cursor_line_char_last(cur);
10251 }
10252 }
10242 } 10253 }
10243 10254
10244 efl_event_callback_legacy_call(eo_obj, EFL_CANVAS_TEXT_EVENT_CURSOR_CHANGED, NULL); 10255 if ((pnode != cur->node) || (ppos != cur->pos))
10256 {
10257 efl_event_callback_legacy_call(eo_obj,
10258 EFL_CANVAS_TEXT_EVENT_CURSOR_CHANGED, NULL);
10259 }
10245} 10260}
10246 10261
10247EAPI int 10262EAPI int