forked from enlightenment/efl
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
This commit is contained in:
parent
132ef5e224
commit
08d23ea582
|
@ -437,6 +437,23 @@ _elm_code_widget_fill_line(Elm_Code_Widget *widget, Elm_Code_Line *line)
|
|||
evas_object_textgrid_update_add(grid, 0, 0, w, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_cursor_selection_set(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd)
|
||||
{
|
||||
unsigned int end_line, end_col;
|
||||
|
||||
end_line = pd->selection->end_line;
|
||||
end_col = pd->selection->end_col;
|
||||
|
||||
if ((pd->selection->start_line == pd->selection->end_line && pd->selection->end_col > pd->selection->start_col) ||
|
||||
(pd->selection->start_line < pd->selection->end_line))
|
||||
{
|
||||
end_col++;
|
||||
}
|
||||
|
||||
elm_code_widget_cursor_position_set(widget, end_line, end_col);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_fill_range(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd,
|
||||
unsigned int first_row, unsigned int last_row,
|
||||
|
@ -462,7 +479,11 @@ _elm_code_widget_fill_range(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd,
|
|||
if (line)
|
||||
_elm_code_widget_fill_line(widget, line);
|
||||
}
|
||||
|
||||
if (pd->selection)
|
||||
_elm_code_widget_cursor_selection_set(widget, pd);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_fill_update(Elm_Code_Widget *widget, unsigned int first_row, unsigned int last_row,
|
||||
Elm_Code_Line *newline)
|
||||
|
@ -570,17 +591,9 @@ static void
|
|||
_elm_code_widget_selection_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
||||
{
|
||||
Elm_Code_Widget *widget;
|
||||
Elm_Code_Widget_Selection_Data *selection;
|
||||
|
||||
widget = (Elm_Code_Widget *)data;
|
||||
|
||||
if (!elm_code_widget_selection_is_empty(widget))
|
||||
{
|
||||
selection = elm_code_widget_selection_normalized_get(widget);
|
||||
elm_code_widget_cursor_position_set(widget, selection->start_line, selection->start_col);
|
||||
free(selection);
|
||||
}
|
||||
|
||||
_elm_code_widget_refresh(widget, NULL);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue