forked from enlightenment/efl
elm_code: Fix selection when moving around with cursor keys
Also fix the handling of newlines in our selections @fix
This commit is contained in:
parent
262f8dae34
commit
d86143212a
|
@ -1542,7 +1542,7 @@ _elm_code_widget_key_down_cb(void *data, Evas *evas EINA_UNUSED,
|
||||||
{
|
{
|
||||||
Elm_Code_Widget *widget;
|
Elm_Code_Widget *widget;
|
||||||
Elm_Code_Widget_Data *pd;
|
Elm_Code_Widget_Data *pd;
|
||||||
Eina_Bool shift;
|
Eina_Bool shift, adjust, backwards = EINA_FALSE;
|
||||||
|
|
||||||
widget = (Elm_Code_Widget *)data;
|
widget = (Elm_Code_Widget *)data;
|
||||||
pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
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,
|
||||||
{
|
{
|
||||||
if (shift)
|
if (shift)
|
||||||
{
|
{
|
||||||
|
backwards = !strcmp(ev->key, "Up") || !strcmp(ev->key, "Left") ||
|
||||||
|
!strcmp(ev->key, "Home") || !strcmp(ev->key, "Prior");
|
||||||
|
|
||||||
if (!pd->selection)
|
if (!pd->selection)
|
||||||
elm_code_widget_selection_start(widget, pd->cursor_line, pd->cursor_col);
|
elm_code_widget_selection_start(widget, pd->cursor_line, pd->cursor_col - (backwards?1:0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
elm_code_widget_selection_clear(widget);
|
elm_code_widget_selection_clear(widget);
|
||||||
|
@ -1595,7 +1598,15 @@ _elm_code_widget_key_down_cb(void *data, Evas *evas EINA_UNUSED,
|
||||||
_elm_code_widget_cursor_move_pagedown(widget);
|
_elm_code_widget_cursor_move_pagedown(widget);
|
||||||
|
|
||||||
if (shift)
|
if (shift)
|
||||||
elm_code_widget_selection_end(widget, pd->cursor_line, pd->cursor_col);
|
{
|
||||||
|
if (pd->selection->start_line == pd->selection->end_line)
|
||||||
|
adjust = (pd->selection->end_col > pd->selection->start_col) ||
|
||||||
|
(!backwards && (pd->selection->end_col == pd->selection->start_col));
|
||||||
|
else
|
||||||
|
adjust = (pd->selection->end_line > pd->selection->start_line);
|
||||||
|
|
||||||
|
elm_code_widget_selection_end(widget, pd->cursor_line, pd->cursor_col - (adjust?1:0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strcmp(ev->key, "KP_Enter") || !strcmp(ev->key, "Return"))
|
else if (!strcmp(ev->key, "KP_Enter") || !strcmp(ev->key, "Return"))
|
||||||
|
|
|
@ -36,8 +36,6 @@ _elm_code_widget_selection_limit(Evas_Object *widget EINA_UNUSED, Elm_Code_Widge
|
||||||
|
|
||||||
if (*col > width + 1)
|
if (*col > width + 1)
|
||||||
*col = width + 1;
|
*col = width + 1;
|
||||||
if (*col < 1)
|
|
||||||
*col = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
@ -63,7 +61,6 @@ elm_code_widget_selection_start(Evas_Object *widget,
|
||||||
pd->selection->start_line = line;
|
pd->selection->start_line = line;
|
||||||
pd->selection->start_col = col;
|
pd->selection->start_col = col;
|
||||||
efl_event_callback_legacy_call(widget, ELM_OBJ_CODE_WIDGET_EVENT_SELECTION_CHANGED, widget);
|
efl_event_callback_legacy_call(widget, ELM_OBJ_CODE_WIDGET_EVENT_SELECTION_CHANGED, widget);
|
||||||
elm_obj_code_widget_cursor_position_set(widget, line, col);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
|
Loading…
Reference in New Issue