hermet pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=047c9ff238265d74150bfcfb21e467c4665303d7

commit 047c9ff238265d74150bfcfb21e467c4665303d7
Author: Hermet Park <her...@hermet.pe.kr>
Date:   Sat May 7 17:35:07 2016 +0900

    refactoring for multiple edc editor.
    
    move editor attributes out of edc_edit.
    since those attributes should be applied through editors.
---
 src/lib/edc_editor.c       | 77 +++++++---------------------------------------
 src/lib/edj_mgr.c          |  4 +--
 src/lib/edj_viewer.c       |  4 +--
 src/lib/enventor_private.h | 15 +++------
 src/lib/enventor_smart.c   | 51 +++++++++++++++++++++---------
 src/lib/redoundo.c         | 16 +++++-----
 6 files changed, 65 insertions(+), 102 deletions(-)

diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c
index 1191891..5fe219d 100644
--- a/src/lib/edc_editor.c
+++ b/src/lib/edc_editor.c
@@ -28,7 +28,7 @@ struct editor_s
    Evas_Object *scroller;
    Evas_Object *layout;
    Evas_Object *ctxpopup;
-   Evas_Object *enventor;
+   Enventor_Object *enventor;
 
    syntax_helper *sh;
    parser_data *pd;
@@ -55,17 +55,13 @@ struct editor_s
                         Eina_Stringshare *part_name, Eina_Stringshare 
*group_name);
    void *view_sync_cb_data;
    int select_pos;
-   double font_scale;
    const char *font_name;
    const char *font_style;
    const char *error_target;
 
    Eina_Bool edit_changed : 1;
-   Eina_Bool linenumber : 1;
    Eina_Bool ctrl_pressed : 1;
    Eina_Bool on_select_recover : 1;
-   Eina_Bool auto_indent : 1;
-   Eina_Bool part_highlight : 1;
    Eina_Bool ctxpopup_enabled : 1;
    Eina_Bool on_save : 1;
    Eina_Bool smart_undo_redo : 1;
@@ -440,7 +436,7 @@ edit_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, 
void *event_info)
                 parser_line_cnt_get(ed->pd, info->change.insert.content);
           }
 
-        if (edit_auto_indent_get(ed))
+        if (enventor_obj_auto_indent_get(ed->enventor))
           {
              increase =
                 indent_insert_apply(syntax_indent_data_get(ed->sh),
@@ -451,7 +447,7 @@ edit_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, 
void *event_info)
      }
    else
      {
-        if (edit_auto_indent_get(ed))
+        if (enventor_obj_auto_indent_get(ed->enventor))
           {
              indent_delete_apply(syntax_indent_data_get(ed->sh),
                                  info->change.del.content, ed->cur_line);
@@ -1026,7 +1022,7 @@ edit_edc_load(edit_data *ed, const char *file_path)
       = indent_text_check(id, (const char *)utf8_edit);
 
    //Set edc text to entry.
-   if (edit_auto_indent_get(ed) && !indent_correct)
+   if (enventor_obj_auto_indent_get(ed->enventor) && !indent_correct)
      //Create indented markup text from utf8 text of EDC file.
      markup_edit = indent_text_create(id, (const char *)utf8_edit,
                                       &line_num);
@@ -1034,13 +1030,13 @@ edit_edc_load(edit_data *ed, const char *file_path)
      markup_edit = elm_entry_utf8_to_markup(utf8_edit);
    if (!markup_edit) goto err;
    elm_entry_entry_set(ed->en_edit, markup_edit);
-   if (edit_auto_indent_get(ed) && !indent_correct)
+   if (enventor_obj_auto_indent_get(ed->enventor) && !indent_correct)
      edit_changed_set(ed, EINA_TRUE);
    free(markup_edit);
 
    //Append line numbers.
    if (!eina_strbuf_append_char(strbuf_line, '1')) goto err;
-   if (edit_auto_indent_get(ed) && !indent_correct)
+   if (enventor_obj_auto_indent_get(ed->enventor) && !indent_correct)
      {
         int num = 2;
         //Use line_num given by indent_text_create().
@@ -1396,7 +1392,7 @@ edit_cur_indent_depth_get(edit_data *ed)
 }
 
 edit_data *
-edit_init(Evas_Object *enventor)
+edit_init(Enventor_Object *enventor)
 {
    edit_data *ed = calloc(1, sizeof(edit_data));
    if (!ed)
@@ -1475,21 +1471,19 @@ edit_init(Evas_Object *enventor)
    elm_object_focus_set(en_edit, EINA_TRUE);
    elm_object_part_content_set(layout, "elm.swallow.edit", en_edit);
 
+   evas_object_smart_member_add(scroller, enventor);
+
    ed->scroller = scroller;
    ed->en_line = en_line;
    ed->en_edit = en_edit;
    ed->layout = layout;
    ed->enventor = enventor;
-   ed->linenumber = EINA_TRUE;
-   ed->auto_indent = EINA_TRUE;
-   ed->part_highlight = EINA_TRUE;
    ed->ctxpopup_enabled = EINA_TRUE;
    ed->smart_undo_redo = EINA_FALSE;
    ed->cur_line = -1;
    ed->select_pos = -1;
-   ed->font_scale = 1;
    ed->pd = parser_init();
-   ed->rd = redoundo_init(ed);
+   ed->rd = redoundo_init(ed, enventor);
    ed->sh = syntax_init(ed);
 
    return ed;
@@ -1539,18 +1533,9 @@ edit_changed_set(edit_data *ed, Eina_Bool changed)
    ed->edit_changed = changed;
 }
 
-Eina_Bool
-edit_linenumber_get(edit_data *ed)
-{
-   return ed->linenumber;
-}
-
 void
 edit_linenumber_set(edit_data *ed, Eina_Bool linenumber)
 {
-   if (ed->linenumber == linenumber) return;
-   ed->linenumber = !!linenumber;
-
    if (linenumber)
      elm_object_signal_emit(ed->layout, "elm,state,linenumber,show", "");
    else
@@ -1560,16 +1545,8 @@ edit_linenumber_set(edit_data *ed, Eina_Bool linenumber)
 void
 edit_font_scale_set(edit_data *ed, double font_scale)
 {
-   if (ed->font_scale == font_scale) return;
    elm_object_scale_set(ed->layout, font_scale);
    syntax_color_partial_update(ed, 0);
-   ed->font_scale = font_scale;
-}
-
-double
-edit_font_scale_get(edit_data *ed)
-{
-   return ed->font_scale;
 }
 
 void
@@ -1587,25 +1564,6 @@ edit_font_get(edit_data *ed, const char **font_name, 
const char **font_style)
    if (font_style) *font_style = ed->font_style;
 }
 
-void
-edit_part_highlight_set(edit_data *ed, Eina_Bool part_highlight)
-{
-   part_highlight = !!part_highlight;
-
-   if (ed->part_highlight == part_highlight) return;
-
-   ed->part_highlight = part_highlight;
-
-   if (part_highlight) edit_view_sync(ed);
-   else view_part_highlight_set(VIEW_DATA, NULL);
-}
-
-Eina_Bool
-edit_part_highlight_get(edit_data *ed)
-{
-   return ed->part_highlight;
-}
-
 Eina_Bool
 edit_load(edit_data *ed, const char *edc_path)
 {
@@ -1789,7 +1747,7 @@ edit_disabled_set(edit_data *ed, Eina_Bool disabled)
 
    //Turn off the part highlight in case of disable.
    if (disabled) view_part_highlight_set(VIEW_DATA, NULL);
-   else if (ed->part_highlight) edit_view_sync(ed);
+   else if (enventor_obj_part_highlight_get(ed->enventor)) edit_view_sync(ed);
 }
 
 void
@@ -1807,19 +1765,6 @@ edit_smart_undo_redo_get(edit_data *ed)
 }
 
 void
-edit_auto_indent_set(edit_data *ed, Eina_Bool auto_indent)
-{
-   auto_indent = !!auto_indent;
-   ed->auto_indent = auto_indent;
-}
-
-Eina_Bool
-edit_auto_indent_get(edit_data *ed)
-{
-   return ed->auto_indent;
-}
-
-void
 edit_error_set(edit_data *ed, int line, const char *target)
 {
    ed->error_line = line;
diff --git a/src/lib/edj_mgr.c b/src/lib/edj_mgr.c
index 055eb38..e621233 100644
--- a/src/lib/edj_mgr.c
+++ b/src/lib/edj_mgr.c
@@ -17,7 +17,7 @@ typedef struct edj_mgr_s
 {
    Eina_List *edjs;
    edj_data *edj;
-   Evas_Object *enventor;
+   Enventor_Object *enventor;
    Evas_Object *layout;
    double view_scale;
 
@@ -73,7 +73,7 @@ edj_mgr_clear(void)
 }
 
 void
-edj_mgr_init(Evas_Object *enventor)
+edj_mgr_init(Enventor_Object *enventor)
 {
    edj_mgr *em = calloc(1, sizeof(edj_mgr));
    if (!em)
diff --git a/src/lib/edj_viewer.c b/src/lib/edj_viewer.c
index 0e24117..6886ceb 100644
--- a/src/lib/edj_viewer.c
+++ b/src/lib/edj_viewer.c
@@ -15,7 +15,7 @@ struct viewer_s
    Evas_Object *base;
    Evas_Object *scroller;
    Evas_Object *event_rect;
-   Evas_Object *enventor;
+   Enventor_Object *enventor;
 
    Evas_Object *part_obj;
    Evas_Object *part_highlight;
@@ -591,7 +591,7 @@ view_dummy_set(view_data *vd, Eina_Bool dummy_parts)
 }
 
 view_data *
-view_init(Evas_Object *enventor, const char *group,
+view_init(Enventor_Object *enventor, const char *group,
           void (*del_cb)(void *data), void *data)
 {
    view_data *vd = calloc(1, sizeof(view_data));
diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h
index 18ad8ef..ecb8f87 100644
--- a/src/lib/enventor_private.h
+++ b/src/lib/enventor_private.h
@@ -163,7 +163,7 @@ void dummy_obj_update(Evas_Object *layout);
 
 
 /* edj_mgr */
-void edj_mgr_init(Evas_Object *enventor);
+void edj_mgr_init(Enventor_Object *enventor);
 void edj_mgr_term(void);
 view_data * edj_mgr_view_new(const char *group);
 view_data *edj_mgr_view_get(Eina_Stringshare *group);
@@ -179,7 +179,7 @@ void edj_mgr_all_views_reload(void);
 
 
 /* redoundo */
-redoundo_data *redoundo_init(edit_data *ed);
+redoundo_data *redoundo_init(edit_data *ed, Enventor_Object *enventor);
 void redoundo_term(redoundo_data *rd);
 void redoundo_clear(redoundo_data *rd);
 void redoundo_text_push(redoundo_data *rd, const char *text, int pos, int 
length, Eina_Bool insert);
@@ -193,7 +193,7 @@ void redoundo_diff_buildable(redoundo_data *rd, Eina_Bool 
buildable);
 
 
 /* edj_viewer */
-view_data * view_init(Evas_Object *enventor, const char *group, void 
(*del_cb)(void *data), void *data);
+view_data * view_init(Enventor_Object *enventor, const char *group, void 
(*del_cb)(void *data), void *data);
 void view_term(view_data *vd);
 Evas_Object *view_obj_get(view_data *vd);
 void view_new(view_data *vd, const char *group);
@@ -228,13 +228,12 @@ Evas_Object *ctxpopup_img_preview_create(edit_data*ed, 
const char *imgpath, Evas
 void ctxpopup_img_preview_reload(Evas_Object *ctxpopup, const char *imgpath);
 
 /* edc_editor */
-edit_data *edit_init(Evas_Object *enventor);
+edit_data *edit_init(Enventor_Object *enventor);
 void edit_term(edit_data *ed);
 Evas_Object *edit_obj_get(edit_data *ed);
 Eina_Bool edit_changed_get(edit_data *ed);
 void edit_changed_set(edit_data *ed, Eina_Bool changed);
 void edit_linenumber_set(edit_data *ed, Eina_Bool linenumber);
-Eina_Bool edit_linenumber_get(edit_data *ed);
 Eina_Bool edit_saved_get(edit_data *ed);
 void edit_saved_set(edit_data *ed, Eina_Bool saved);
 Eina_Bool edit_save(edit_data *ed, const char *file);
@@ -242,10 +241,8 @@ void edit_new(edit_data* ed);
 void edit_view_sync_cb_set(edit_data *ed, void (*cb)(void *data, 
Eina_Stringshare *state_name, double state_value, Eina_Stringshare *part_name, 
Eina_Stringshare *group_name), void *data);
 void edit_view_sync(edit_data *ed);
 void edit_font_scale_set(edit_data *ed, double font_scale);
-double edit_font_scale_get(edit_data *ed);
 void edit_font_set(edit_data *ed, const char *font_name, const char 
*font_style);
 void edit_font_get(edit_data *ed, const char **font_name, const char 
**font_style);
-void edit_part_highlight_toggle(edit_data *ed, Eina_Bool msg);
 void edit_line_delete(edit_data *ed);
 Eina_Stringshare *edit_cur_prog_name_get(edit_data *ed);
 Eina_Stringshare *edit_cur_part_name_get(edit_data *ed);
@@ -261,10 +258,6 @@ void edit_line_increase(edit_data *ed, int cnt);
 void edit_line_decrease(edit_data *ed, int cnt);
 int edit_cur_indent_depth_get(edit_data *ed);
 void edit_redoundo_region_push(edit_data *ed, int cursor_pos1, int 
cursor_pos2);
-void edit_auto_indent_set(edit_data *ed, Eina_Bool auto_indent);
-Eina_Bool edit_auto_indent_get(edit_data *ed);
-void edit_part_highlight_set(edit_data *ed, Eina_Bool part_highlight);
-Eina_Bool edit_part_highlight_get(edit_data *ed);
 void edit_ctxpopup_enabled_set(edit_data *ed, Eina_Bool enabled);
 Eina_Bool edit_ctxpopup_enabled_get(edit_data *ed);
 Eina_Bool edit_ctxpopup_visible_get(edit_data *ed);
diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c
index 23d5a14..3c9c6b6 100644
--- a/src/lib/enventor_smart.c
+++ b/src/lib/enventor_smart.c
@@ -17,7 +17,10 @@
 
 #define MY_CLASS ENVENTOR_OBJECT_CLASS
 
-typedef struct _Enventor_Object_Data
+typedef struct _Enventor_Object_Data Enventor_Object_Data;
+typedef struct _Enventor_Item_Data Enventor_Item_Data;
+
+struct _Enventor_Object_Data
 {
    Evas_Object *obj;
    Eina_List *items;
@@ -28,18 +31,21 @@ typedef struct _Enventor_Object_Data
    Ecore_Event_Handler *key_down_handler;
    Ecore_Event_Handler *key_up_handler;
 
+   double font_scale;
+
    Eina_Bool dummy_parts : 1;
    Eina_Bool key_down : 1;
    Eina_Bool part_cursor_jump : 1;
    Eina_Bool mirror_mode : 1;
+   Eina_Bool linenumber : 1;
+   Eina_Bool auto_indent : 1;
+   Eina_Bool part_highlight : 1;
+};
 
-} Enventor_Object_Data;
-
-typedef struct _Enventor_Item_Data
+struct _Enventor_Item_Data
 {
    Enventor_Object *enventor;
-
-} Enventor_Item_Data;
+};
 
 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
    {SIG_CURSOR_LINE_CHANGED, ""},
@@ -116,7 +122,7 @@ edit_view_sync_cb(void *data, Eina_Stringshare *state_name, 
double state_value,
         evas_object_smart_callback_call(pd->obj, SIG_CURSOR_GROUP_CHANGED,
                                         (void *) group_name);
      }
-   if (edit_part_highlight_get(pd->ed))
+   if (pd->part_highlight)
      view_part_highlight_set(VIEW_DATA, part_name);
    else
      view_part_highlight_set(VIEW_DATA, NULL);
@@ -218,7 +224,6 @@ _enventor_object_evas_object_smart_add(Eo *obj, 
Enventor_Object_Data *pd)
    edit_view_sync_cb_set(pd->ed, edit_view_sync_cb, pd);
    build_err_noti_cb_set(build_err_noti_cb, pd);
 
-   evas_object_smart_member_add(edit_obj_get(pd->ed), obj);
    elm_widget_can_focus_set(obj, EINA_FALSE);
 
    pd->key_down_handler =
@@ -229,7 +234,11 @@ _enventor_object_evas_object_smart_add(Eo *obj, 
Enventor_Object_Data *pd)
    evas_object_smart_callback_add(pd->obj, "part,clicked",
                                   _enventor_part_clicked_cb, pd);
 
+   pd->font_scale = 1;
    pd->part_cursor_jump = EINA_TRUE;
+   pd->linenumber = EINA_TRUE;
+   pd->auto_indent = EINA_TRUE;
+   pd->part_highlight = EINA_TRUE;
 }
 
 EOLIAN static void
@@ -369,13 +378,19 @@ EOLIAN static void
 _enventor_object_linenumber_set(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd,
                                 Eina_Bool linenumber)
 {
+   linenumber = !!linenumber;
+
+   if (pd->linenumber == linenumber) return;
+
    edit_linenumber_set(pd->ed, linenumber);
+
+   pd->linenumber = linenumber;
 }
 
 EOLIAN static Eina_Bool
 _enventor_object_linenumber_get(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd)
 {
-   return edit_linenumber_get(pd->ed);
+   return pd->linenumber;
 }
 
 EOLIAN static void
@@ -395,13 +410,13 @@ EOLIAN static void
 _enventor_object_auto_indent_set(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd,
                                  Eina_Bool auto_indent)
 {
-   edit_auto_indent_set(pd->ed, auto_indent);
+   pd->auto_indent = !!auto_indent;
 }
 
 EOLIAN static Eina_Bool
 _enventor_object_auto_indent_get(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd)
 {
-   return edit_auto_indent_get(pd->ed);
+   return pd->auto_indent;
 }
 
 EOLIAN static void
@@ -550,14 +565,19 @@ _enventor_object_part_highlight_set(Eo *obj EINA_UNUSED,
                                     Enventor_Object_Data *pd,
                                     Eina_Bool part_highlight)
 {
-   edit_part_highlight_set(pd->ed, part_highlight);
+   part_highlight = !!part_highlight;
+   if (pd->part_highlight == part_highlight) return;
+   pd->part_highlight = part_highlight;
+
+   if (part_highlight) edit_view_sync(pd->ed);
+   else view_part_highlight_set(VIEW_DATA, NULL);
 }
 
 EOLIAN static Eina_Bool
 _enventor_object_part_highlight_get(Eo *obj EINA_UNUSED,
                                     Enventor_Object_Data *pd)
 {
-   return edit_part_highlight_get(pd->ed);
+   return pd->part_highlight;
 }
 
 EOLIAN static void
@@ -649,13 +669,16 @@ EOLIAN static void
 _enventor_object_font_scale_set(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd,
                                 double font_scale)
 {
+   if (pd->font_scale == font_scale) return;
+   pd->font_scale = font_scale;
+
    edit_font_scale_set(pd->ed, font_scale);
 }
 
 EOLIAN static double
 _enventor_object_font_scale_get(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd)
 {
-   return edit_font_scale_get(pd->ed);
+   return pd->font_scale;
 }
 
 EOLIAN static void
diff --git a/src/lib/redoundo.c b/src/lib/redoundo.c
index a79494f..cf0ec6c 100644
--- a/src/lib/redoundo.c
+++ b/src/lib/redoundo.c
@@ -22,13 +22,14 @@ struct redoundo_s
 {
    Evas_Object *entry;
    Evas_Object *textblock;
+   Enventor_Object *enventor;
    Evas_Textblock_Cursor *cursor;
    Eina_List *queue;
    Eina_List *current_node;
    diff_data *last_diff;
    unsigned int queue_max;        //Maximum queuing data count 0: unlimited
    Eina_Bool internal_change : 1; //Entry change by redoundo
-   edit_data *edit_data;
+   edit_data *ed;
    struct {
       Eina_Bool enable;
       Ecore_Timer *timer;
@@ -64,7 +65,7 @@ smart_analyser(redoundo_data *rd, diff_data *diff)
 
    if (!diff) return diff;
 
-   if (diff->length == 1 && edit_auto_indent_get(rd->edit_data))
+   if (diff->length == 1 && enventor_obj_auto_indent_get(rd->enventor))
      {
        if (strstr(diff->text, "<br/>")) diff->relative = EINA_TRUE;
          else diff->relative = EINA_FALSE;
@@ -186,7 +187,7 @@ redoundo_undo(redoundo_data *rd, Eina_Bool *changed)
 
    if (!rd->last_diff)
      {
-        edit_save(rd->edit_data, build_edc_path_get());
+        edit_save(rd->ed, build_edc_path_get());
         build_edc();
         return 0;
      }
@@ -249,7 +250,7 @@ redoundo_undo(redoundo_data *rd, Eina_Bool *changed)
 
    if (rd->last_diff && rd->last_diff->buildable)
      {
-        edit_save(rd->edit_data, build_edc_path_get());
+        edit_save(rd->ed, build_edc_path_get());
         build_edc();
      }
 
@@ -334,7 +335,7 @@ redoundo_redo(redoundo_data *rd, Eina_Bool *changed)
 
    if (rd->last_diff && rd->last_diff->buildable)
      {
-        edit_save(rd->edit_data, build_edc_path_get());
+        edit_save(rd->ed, build_edc_path_get());
         build_edc();
      }
 
@@ -382,7 +383,7 @@ redoundo_text_push(redoundo_data *rd, const char *text, int 
pos, int length,
 }
 
 redoundo_data *
-redoundo_init(edit_data *ed)
+redoundo_init(edit_data *ed, Enventor_Object *enventor)
 {
    Evas_Object *entry = edit_entry_get(ed);
    if (!entry)
@@ -399,12 +400,13 @@ redoundo_init(edit_data *ed)
      }
 
    rd->entry = entry;
+   rd->enventor = enventor;
    rd->textblock = elm_entry_textblock_get(entry);
    rd->cursor = evas_object_textblock_cursor_new(rd->textblock);
    rd->queue_max = DEFAULT_QUEUE_SIZE;
    rd->smart.enable = EINA_FALSE;
    rd->smart.input_delay = INPUT_SPEED;
-   rd->edit_data = ed;
+   rd->ed = ed;
 
    //FIXME: Why signal callback? not smart callback?
    elm_object_signal_callback_add(rd->entry, "entry,changed,user", "*",

-- 


Reply via email to