summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-07-23 21:30:35 +0100
committerAndy Williams <andy@andywilliams.me>2017-07-23 21:30:35 +0100
commit292e9e9ecf456cda79b287fe65c16d90f14da325 (patch)
treeeb23b479808bad3e32a1653c6b3defe138e5b5f4
parent83a249baa1743399f97cfe03e0d4f83aec787199 (diff)
downloadefl-292e9e9ecf456cda79b287fe65c16d90f14da325.tar.gz
elm_code: Fix crash with long lines
Also fixes issue where widget would sometimes blank when scrolling @fix
-rw-r--r--src/lib/elementary/elm_code_widget.c31
-rw-r--r--src/lib/elementary/elm_code_widget_text.c9
2 files changed, 15 insertions, 25 deletions
diff --git a/src/lib/elementary/elm_code_widget.c b/src/lib/elementary/elm_code_widget.c
index c0b4da73ff..04f20edcd6 100644
--- a/src/lib/elementary/elm_code_widget.c
+++ b/src/lib/elementary/elm_code_widget.c
@@ -1890,28 +1890,11 @@ _elm_code_widget_resize(Elm_Code_Widget *widget, Elm_Code_Line *newline)
w = 0;
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);
if ((int) line_width + gutter + 1 > w)
- {
- 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;
- }
+ w = (int) line_width + gutter + 1;
}
_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;
if (h*ch > wh)
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)
{
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)
@@ -1940,7 +1926,6 @@ _elm_code_widget_resize(Elm_Code_Widget *widget, Elm_Code_Line *newline)
return;
}
- _elm_code_widget_fill_line(widget, line);
if (pd->gravity_x == 1.0 || pd->gravity_y == 1.0)
_elm_code_widget_scroll_by(widget,
diff --git a/src/lib/elementary/elm_code_widget_text.c b/src/lib/elementary/elm_code_widget_text.c
index 879a0a7ecf..43cce43a97 100644
--- a/src/lib/elementary/elm_code_widget_text.c
+++ b/src/lib/elementary/elm_code_widget_text.c
@@ -199,14 +199,21 @@ static void
_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)
{
+ Elm_Code_Widget_Data *pd;
Elm_Code_Line *line;
unsigned int position, newcol;
+ pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
line = elm_code_file_line_get(code->file, row);
position = elm_code_widget_line_text_position_for_column_get(widget, line, col);
elm_code_line_text_insert(line, position, text, 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);
}
@@ -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_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);
if (undo)