summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-01-14 19:39:39 +0000
committerAndy Williams <andy@andywilliams.me>2017-01-15 22:41:48 +0000
commitd86143212a26d7dda5df27f758a2d610435c1bb8 (patch)
tree1357a86580017465829c1b898f2a4110330195a7 /src
parent262f8dae34fde0246f452d81b79ccb77a0c906f8 (diff)
elm_code: Fix selection when moving around with cursor keys
Also fix the handling of newlines in our selections @fix
Diffstat (limited to 'src')
-rw-r--r--src/lib/elementary/elm_code_widget.c17
-rw-r--r--src/lib/elementary/elm_code_widget_selection.c3
2 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/elementary/elm_code_widget.c b/src/lib/elementary/elm_code_widget.c
index 7ce76de4e6..6131fcad80 100644
--- a/src/lib/elementary/elm_code_widget.c
+++ b/src/lib/elementary/elm_code_widget.c
@@ -1542,7 +1542,7 @@ _elm_code_widget_key_down_cb(void *data, Evas *evas EINA_UNUSED,
1542{ 1542{
1543 Elm_Code_Widget *widget; 1543 Elm_Code_Widget *widget;
1544 Elm_Code_Widget_Data *pd; 1544 Elm_Code_Widget_Data *pd;
1545 Eina_Bool shift; 1545 Eina_Bool shift, adjust, backwards = EINA_FALSE;
1546 1546
1547 widget = (Elm_Code_Widget *)data; 1547 widget = (Elm_Code_Widget *)data;
1548 pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); 1548 pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
@@ -1571,8 +1571,11 @@ _elm_code_widget_key_down_cb(void *data, Evas *evas EINA_UNUSED,
1571 { 1571 {
1572 if (shift) 1572 if (shift)
1573 { 1573 {
1574 backwards = !strcmp(ev->key, "Up") || !strcmp(ev->key, "Left") ||
1575 !strcmp(ev->key, "Home") || !strcmp(ev->key, "Prior");
1576
1574 if (!pd->selection) 1577 if (!pd->selection)
1575 elm_code_widget_selection_start(widget, pd->cursor_line, pd->cursor_col); 1578 elm_code_widget_selection_start(widget, pd->cursor_line, pd->cursor_col - (backwards?1:0));
1576 } 1579 }
1577 else 1580 else
1578 elm_code_widget_selection_clear(widget); 1581 elm_code_widget_selection_clear(widget);
@@ -1595,7 +1598,15 @@ _elm_code_widget_key_down_cb(void *data, Evas *evas EINA_UNUSED,
1595 _elm_code_widget_cursor_move_pagedown(widget); 1598 _elm_code_widget_cursor_move_pagedown(widget);
1596 1599
1597 if (shift) 1600 if (shift)
1598 elm_code_widget_selection_end(widget, pd->cursor_line, pd->cursor_col); 1601 {
1602 if (pd->selection->start_line == pd->selection->end_line)
1603 adjust = (pd->selection->end_col > pd->selection->start_col) ||
1604 (!backwards && (pd->selection->end_col == pd->selection->start_col));
1605 else
1606 adjust = (pd->selection->end_line > pd->selection->start_line);
1607
1608 elm_code_widget_selection_end(widget, pd->cursor_line, pd->cursor_col - (adjust?1:0));
1609 }
1599 } 1610 }
1600 1611
1601 else if (!strcmp(ev->key, "KP_Enter") || !strcmp(ev->key, "Return")) 1612 else if (!strcmp(ev->key, "KP_Enter") || !strcmp(ev->key, "Return"))
diff --git a/src/lib/elementary/elm_code_widget_selection.c b/src/lib/elementary/elm_code_widget_selection.c
index 9c73bdc729..4a92b49eba 100644
--- a/src/lib/elementary/elm_code_widget_selection.c
+++ b/src/lib/elementary/elm_code_widget_selection.c
@@ -36,8 +36,6 @@ _elm_code_widget_selection_limit(Evas_Object *widget EINA_UNUSED, Elm_Code_Widge
36 36
37 if (*col > width + 1) 37 if (*col > width + 1)
38 *col = width + 1; 38 *col = width + 1;
39 if (*col < 1)
40 *col = 1;
41} 39}
42 40
43EAPI void 41EAPI void
@@ -63,7 +61,6 @@ elm_code_widget_selection_start(Evas_Object *widget,
63 pd->selection->start_line = line; 61 pd->selection->start_line = line;
64 pd->selection->start_col = col; 62 pd->selection->start_col = col;
65 efl_event_callback_legacy_call(widget, ELM_OBJ_CODE_WIDGET_EVENT_SELECTION_CHANGED, widget); 63 efl_event_callback_legacy_call(widget, ELM_OBJ_CODE_WIDGET_EVENT_SELECTION_CHANGED, widget);
66 elm_obj_code_widget_cursor_position_set(widget, line, col);
67} 64}
68 65
69EAPI void 66EAPI void