summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Poole <netstar@gmail.com>2018-07-24 10:02:30 +0100
committerAndy Williams <andy@andywilliams.me>2018-07-24 10:04:28 +0100
commit08d23ea58201756e59367c184c1a3ff9e274670c (patch)
treefac48d49dd8b3a1ed2ee66d21add4c05b7d34ce0
parent132ef5e2244067c819c6700fb3e01283f570efd8 (diff)
elm_code_widget: fix select and drag (scrolling).
Summary: Currently when selecting with the mouse and scrollling, the selection will only continue in one direction. With this patch, the selection can move freely between "pages". Test Plan: select text and drag up and down in elm_code widget (Edi). Reviewers: #committers, ajwillia.ms Reviewed By: ajwillia.ms Subscribers: cedric, zmike Tags: #efl Differential Revision: https://phab.enlightenment.org/D6632
-rw-r--r--src/lib/elementary/elm_code_widget.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/lib/elementary/elm_code_widget.c b/src/lib/elementary/elm_code_widget.c
index d34b40379e..a8fb499160 100644
--- a/src/lib/elementary/elm_code_widget.c
+++ b/src/lib/elementary/elm_code_widget.c
@@ -438,6 +438,23 @@ _elm_code_widget_fill_line(Elm_Code_Widget *widget, Elm_Code_Line *line)
438} 438}
439 439
440static void 440static void
441_elm_code_widget_cursor_selection_set(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd)
442{
443 unsigned int end_line, end_col;
444
445 end_line = pd->selection->end_line;
446 end_col = pd->selection->end_col;
447
448 if ((pd->selection->start_line == pd->selection->end_line && pd->selection->end_col > pd->selection->start_col) ||
449 (pd->selection->start_line < pd->selection->end_line))
450 {
451 end_col++;
452 }
453
454 elm_code_widget_cursor_position_set(widget, end_line, end_col);
455}
456
457static void
441_elm_code_widget_fill_range(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd, 458_elm_code_widget_fill_range(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd,
442 unsigned int first_row, unsigned int last_row, 459 unsigned int first_row, unsigned int last_row,
443 Elm_Code_Line *newline) 460 Elm_Code_Line *newline)
@@ -462,7 +479,11 @@ _elm_code_widget_fill_range(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd,
462 if (line) 479 if (line)
463 _elm_code_widget_fill_line(widget, line); 480 _elm_code_widget_fill_line(widget, line);
464 } 481 }
482
483 if (pd->selection)
484 _elm_code_widget_cursor_selection_set(widget, pd);
465} 485}
486
466static void 487static void
467_elm_code_widget_fill_update(Elm_Code_Widget *widget, unsigned int first_row, unsigned int last_row, 488_elm_code_widget_fill_update(Elm_Code_Widget *widget, unsigned int first_row, unsigned int last_row,
468 Elm_Code_Line *newline) 489 Elm_Code_Line *newline)
@@ -570,17 +591,9 @@ static void
570_elm_code_widget_selection_cb(void *data, const Efl_Event *event EINA_UNUSED) 591_elm_code_widget_selection_cb(void *data, const Efl_Event *event EINA_UNUSED)
571{ 592{
572 Elm_Code_Widget *widget; 593 Elm_Code_Widget *widget;
573 Elm_Code_Widget_Selection_Data *selection;
574 594
575 widget = (Elm_Code_Widget *)data; 595 widget = (Elm_Code_Widget *)data;
576 596
577 if (!elm_code_widget_selection_is_empty(widget))
578 {
579 selection = elm_code_widget_selection_normalized_get(widget);
580 elm_code_widget_cursor_position_set(widget, selection->start_line, selection->start_col);
581 free(selection);
582 }
583
584 _elm_code_widget_refresh(widget, NULL); 597 _elm_code_widget_refresh(widget, NULL);
585} 598}
586 599