{
Elm_Code_Widget *widget;
Elm_Code_Widget_Data *pd;
- Eina_Bool shift;
+ Eina_Bool shift, adjust, backwards = EINA_FALSE;
widget = (Elm_Code_Widget *)data;
pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
{
if (shift)
{
+ backwards = !strcmp(ev->key, "Up") || !strcmp(ev->key, "Left") ||
+ !strcmp(ev->key, "Home") || !strcmp(ev->key, "Prior");
+
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
elm_code_widget_selection_clear(widget);
_elm_code_widget_cursor_move_pagedown(widget);
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"))
if (*col > width + 1)
*col = width + 1;
- if (*col < 1)
- *col = 1;
}
EAPI void
pd->selection->start_line = line;
pd->selection->start_col = col;
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