ajwillia-ms pushed a commit to branch master. http://git.enlightenment.org/tools/edi.git/commit/?id=ce2545db25e9474b850b71b316c8b00e419770bf
commit ce2545db25e9474b850b71b316c8b00e419770bf Author: Andy Williams <a...@andywilliams.me> Date: Thu Apr 2 22:48:23 2015 +0100 editor: Fix performance of loading large files --- elm_code/src/lib/elm_code_widget.c | 21 +++++++++++++++++++++ elm_code/src/lib/elm_code_widget.eo | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/elm_code/src/lib/elm_code_widget.c b/elm_code/src/lib/elm_code_widget.c index c0fc9ea..0d131e5 100644 --- a/elm_code/src/lib/elm_code_widget.c +++ b/elm_code/src/lib/elm_code_widget.c @@ -414,10 +414,17 @@ static Eina_Bool _elm_code_widget_line_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) { + Elm_Code_Line *line; Elm_Code_Widget *widget; + Eina_Bool visible; + line = (Elm_Code_Line *)event_info; widget = (Elm_Code_Widget *)data; + eo_do(widget, visible = elm_code_widget_line_visible_get(line)); + if (!visible) + return EO_CALLBACK_CONTINUE; + // FIXME refresh just the row unless we have resized (by being the result of a row append) _elm_code_widget_fill(widget); @@ -1121,6 +1128,20 @@ _elm_code_widget_line_refresh(Eo *obj, Elm_Code_Widget_Data *pd EINA_UNUSED, Elm _elm_code_widget_fill_line(obj, line); } +EOAPI Eina_Bool +_elm_code_widget_line_visible_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd, Elm_Code_Line *line) +{ + Evas_Coord cellh, viewy, viewh; + + elm_scroller_region_get(pd->scroller, NULL, &viewy, NULL, &viewh); + evas_object_textgrid_cell_size_get(pd->grid, NULL, &cellh); + + if (((int)line->number - 1) * cellh > viewy + viewh || (int)line->number * cellh < viewy) + return EINA_FALSE; + + return EINA_TRUE;; +} + EOLIAN static void _elm_code_widget_font_size_set(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd, Evas_Font_Size font_size) { diff --git a/elm_code/src/lib/elm_code_widget.eo b/elm_code/src/lib/elm_code_widget.eo index f8b8c6c..ae7fdcf 100644 --- a/elm_code/src/lib/elm_code_widget.eo +++ b/elm_code/src/lib/elm_code_widget.eo @@ -187,6 +187,12 @@ class Elm_Code_Widget (Elm_Layout, Elm_Interface_Atspi_Text) Elm_Code_Line *line; /*@ @in The line to refresh. */ } } + line_visible_get { + params { + Elm_Code_Line *line; /*@ @in The line to test for visibility. */ + } + return: bool (visible); /*@ true if the line specified is currently visible within the scroll region. */ + } } implements { class.constructor; --