forked from enlightenment/efl
elm_code: Fix crash with long lines
Also fixes issue where widget would sometimes blank when scrolling @fix
This commit is contained in:
parent
83a249baa1
commit
292e9e9ecf
|
@ -1890,28 +1890,11 @@ _elm_code_widget_resize(Elm_Code_Widget *widget, Elm_Code_Line *newline)
|
||||||
w = 0;
|
w = 0;
|
||||||
h = elm_code_file_lines_get(pd->code->file);
|
h = elm_code_file_lines_get(pd->code->file);
|
||||||
|
|
||||||
if (newline)
|
EINA_LIST_FOREACH(pd->code->file->lines, item, line)
|
||||||
{
|
{
|
||||||
line = eina_list_data_get(pd->code->file->lines);
|
|
||||||
if (line)
|
|
||||||
{
|
|
||||||
line_width = elm_code_widget_line_text_column_width_get(widget, newline);
|
|
||||||
w = (int) line_width + gutter + 1;
|
|
||||||
}
|
|
||||||
line_width = elm_code_widget_line_text_column_width_get(widget, line);
|
line_width = elm_code_widget_line_text_column_width_get(widget, line);
|
||||||
if ((int) line_width + gutter + 1 > w)
|
if ((int) line_width + gutter + 1 > w)
|
||||||
{
|
w = (int) line_width + gutter + 1;
|
||||||
w = (int) line_width + gutter + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EINA_LIST_FOREACH(pd->code->file->lines, item, line)
|
|
||||||
{
|
|
||||||
line_width = elm_code_widget_line_text_column_width_get(widget, line);
|
|
||||||
if ((int) line_width + gutter + 1 > w)
|
|
||||||
w = (int) line_width + gutter + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_elm_code_widget_ensure_n_grid_rows(widget, h);
|
_elm_code_widget_ensure_n_grid_rows(widget, h);
|
||||||
|
@ -1920,13 +1903,16 @@ _elm_code_widget_resize(Elm_Code_Widget *widget, Elm_Code_Line *newline)
|
||||||
ww = w*cw;
|
ww = w*cw;
|
||||||
if (h*ch > wh)
|
if (h*ch > wh)
|
||||||
wh = h*ch;
|
wh = h*ch;
|
||||||
if (cw > 0)
|
|
||||||
pd->col_count = ww/cw + 1;
|
if (cw > 0 && ww/cw > w)
|
||||||
|
pd->col_count = ww/cw;
|
||||||
|
else
|
||||||
|
pd->col_count = w;
|
||||||
|
|
||||||
EINA_LIST_FOREACH(pd->grids, item, grid)
|
EINA_LIST_FOREACH(pd->grids, item, grid)
|
||||||
{
|
{
|
||||||
evas_object_textgrid_size_set(grid, pd->col_count, 1);
|
evas_object_textgrid_size_set(grid, pd->col_count, 1);
|
||||||
evas_object_size_hint_min_set(grid, w*cw, ch);
|
evas_object_size_hint_min_set(grid, ww, ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newline)
|
if (!newline)
|
||||||
|
@ -1940,7 +1926,6 @@ _elm_code_widget_resize(Elm_Code_Widget *widget, Elm_Code_Line *newline)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_elm_code_widget_fill_line(widget, line);
|
|
||||||
|
|
||||||
if (pd->gravity_x == 1.0 || pd->gravity_y == 1.0)
|
if (pd->gravity_x == 1.0 || pd->gravity_y == 1.0)
|
||||||
_elm_code_widget_scroll_by(widget,
|
_elm_code_widget_scroll_by(widget,
|
||||||
|
|
|
@ -199,14 +199,21 @@ static void
|
||||||
_elm_code_widget_text_insert_single(Elm_Code_Widget *widget, Elm_Code *code,
|
_elm_code_widget_text_insert_single(Elm_Code_Widget *widget, Elm_Code *code,
|
||||||
unsigned int col, unsigned int row, const char *text, unsigned int len)
|
unsigned int col, unsigned int row, const char *text, unsigned int len)
|
||||||
{
|
{
|
||||||
|
Elm_Code_Widget_Data *pd;
|
||||||
Elm_Code_Line *line;
|
Elm_Code_Line *line;
|
||||||
unsigned int position, newcol;
|
unsigned int position, newcol;
|
||||||
|
|
||||||
|
pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||||
line = elm_code_file_line_get(code->file, row);
|
line = elm_code_file_line_get(code->file, row);
|
||||||
position = elm_code_widget_line_text_position_for_column_get(widget, line, col);
|
position = elm_code_widget_line_text_position_for_column_get(widget, line, col);
|
||||||
elm_code_line_text_insert(line, position, text, len);
|
elm_code_line_text_insert(line, position, text, len);
|
||||||
|
|
||||||
newcol = elm_code_widget_line_text_column_width_to_position(widget, line, position + len);
|
newcol = elm_code_widget_line_text_column_width_to_position(widget, line, position + len);
|
||||||
|
|
||||||
|
// if we are making a line longer than before then we need to resize
|
||||||
|
if (newcol > pd->col_count)
|
||||||
|
_elm_code_widget_resize(widget, line);
|
||||||
|
|
||||||
elm_obj_code_widget_cursor_position_set(widget, row, newcol);
|
elm_obj_code_widget_cursor_position_set(widget, row, newcol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,8 +293,6 @@ _elm_code_widget_text_at_cursor_insert_do(Elm_Code_Widget *widget, const char *t
|
||||||
_elm_code_widget_text_insert_multi(widget, code, col, row, text, length);
|
_elm_code_widget_text_insert_multi(widget, code, col, row, text, length);
|
||||||
elm_obj_code_widget_cursor_position_get(widget, &end_row, &end_col);
|
elm_obj_code_widget_cursor_position_get(widget, &end_row, &end_col);
|
||||||
|
|
||||||
// a workaround for when the cursor position would be off the line width
|
|
||||||
_elm_code_widget_resize(widget, line);
|
|
||||||
efl_event_callback_legacy_call(widget, ELM_OBJ_CODE_WIDGET_EVENT_CHANGED_USER, NULL);
|
efl_event_callback_legacy_call(widget, ELM_OBJ_CODE_WIDGET_EVENT_CHANGED_USER, NULL);
|
||||||
|
|
||||||
if (undo)
|
if (undo)
|
||||||
|
|
Loading…
Reference in New Issue