hermet pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=3db26261f7747337519d3eb705ed0464e21c87da

commit 3db26261f7747337519d3eb705ed0464e21c87da
Author: Hermet Park <[email protected]>
Date:   Wed Jul 27 15:37:46 2016 +0900

    multi-file: support syntax_colors.
    
    a# Please enter the commit message for your changes. Lines starting
---
 src/bin/main.c             |  2 +-
 src/lib/edc_editor.c       |  7 +------
 src/lib/enventor_private.h |  3 +--
 src/lib/enventor_smart.c   | 41 ++++++++++++++++++++++++++++++++++++++---
 src/lib/syntax_color.c     |  5 +++--
 5 files changed, 44 insertions(+), 14 deletions(-)

diff --git a/src/bin/main.c b/src/bin/main.c
index 32e832d..9f8ff57 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -71,7 +71,7 @@ syntax_color_update(Enventor_Object *enventor)
           {
              enventor_color = enventor_object_syntax_color_get(enventor,
                                                                color_type);
-             if (strcmp(config_color, enventor_color))
+             if (!enventor_color || strcmp(config_color, enventor_color))
                {
                   enventor_object_syntax_color_set(enventor, color_type,
                                                    config_color);
diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c
index 07c7848..343c783 100644
--- a/src/lib/edc_editor.c
+++ b/src/lib/edc_editor.c
@@ -1309,15 +1309,10 @@ void
 edit_syntax_color_set(edit_data *ed, Enventor_Syntax_Color_Type color_type,
                       const char *val)
 {
+   if (!ed) return;
    color_set(syntax_color_data_get(ed->sh), color_type, val);
 }
 
-const char *
-edit_syntax_color_get(edit_data *ed, Enventor_Syntax_Color_Type color_type)
-{
-   return color_get(syntax_color_data_get(ed->sh), color_type);
-}
-
 void
 edit_syntax_color_full_apply(edit_data *ed, Eina_Bool force)
 {
diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h
index fcd1089..7bec4fb 100644
--- a/src/lib/enventor_private.h
+++ b/src/lib/enventor_private.h
@@ -95,7 +95,7 @@ const char **autocomp_current_context_get(int *name_count);
 color_data *color_init(Eina_Strbuf *strbuf);
 void color_term(color_data *cd);
 void color_set(color_data *cd, Enventor_Syntax_Color_Type color_type, const 
char *val);
-const char *color_get(color_data *cd, Enventor_Syntax_Color_Type color_type);
+const char *color_value_get(Enventor_Syntax_Color_Type color_type);
 const char *color_cancel(color_data *cd, const char *str, int length, int 
from_pos, int to_pos, char **from, char **to);
 const char *color_apply(color_data *cd, const char *str, int length, char 
*from, char *to);
 Eina_Bool color_ready(color_data *cd);
@@ -255,7 +255,6 @@ Eina_Stringshare *edit_cur_paragh_get(edit_data *ed);
 int edit_max_line_get(edit_data *ed);
 void edit_goto(edit_data *ed, int line);
 void edit_syntax_color_set(edit_data *ed, Enventor_Syntax_Color_Type 
color_type, const char *val);
-const char *edit_syntax_color_get(edit_data *ed, Enventor_Syntax_Color_Type 
color_type);
 void edit_syntax_color_full_apply(edit_data *ed, Eina_Bool force);
 void edit_syntax_color_partial_apply(edit_data *ed, double interval);
 Evas_Object *edit_entry_get(edit_data *ed);
diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c
index 1d1f89b..744fab0 100644
--- a/src/lib/enventor_smart.c
+++ b/src/lib/enventor_smart.c
@@ -48,6 +48,7 @@ struct _Enventor_Object_Data
    double font_scale;
    Eina_Stringshare *font_name;
    Eina_Stringshare *font_style;
+   const char *text_color_val[ENVENTOR_SYNTAX_COLOR_LAST];
 
    Eina_Bool dummy_parts : 1;
    Eina_Bool wireframes : 1;
@@ -275,6 +276,10 @@ _enventor_object_efl_canvas_group_group_add(Eo *obj, 
Enventor_Object_Data *pd)
 EOLIAN static void
 _enventor_object_efl_canvas_group_group_del(Eo *obj EINA_UNUSED, 
Enventor_Object_Data *pd)
 {
+   int i;
+   for (i = ENVENTOR_SYNTAX_COLOR_STRING; i < ENVENTOR_SYNTAX_COLOR_LAST; i++)
+     eina_stringshare_del(pd->text_color_val[i]);
+
    eina_stringshare_del(pd->font_name);
    eina_stringshare_del(pd->font_style);
    eina_stringshare_del(pd->group_name);
@@ -726,8 +731,23 @@ _enventor_object_syntax_color_set(Eo *obj EINA_UNUSED,
                                   Enventor_Syntax_Color_Type color_type,
                                   const char *val)
 {
-   //TODO: Might need for items
+   EINA_SAFETY_ON_NULL_RETURN(val);
+
+   if ((color_type < ENVENTOR_SYNTAX_COLOR_STRING) ||
+       (color_type >= ENVENTOR_SYNTAX_COLOR_LAST))
+     EINA_LOG_ERR("Invalid color_type(%d)", color_type);
+
+   eina_stringshare_del(pd->text_color_val[color_type]);
+   pd->text_color_val[color_type] = eina_stringshare_add(val);
+
+   //Main Item
    edit_syntax_color_set(pd->main_it->ed, color_type, val);
+
+   //Sub Items
+   Eina_List *l;
+   Enventor_Item *it;
+   EINA_LIST_FOREACH(pd->sub_its, l, it)
+     edit_syntax_color_set(it->ed, color_type, val);
 }
 
 EOLIAN static const char *
@@ -735,8 +755,15 @@ _enventor_object_syntax_color_get(Eo *obj EINA_UNUSED,
                                   Enventor_Object_Data *pd,
                                   Enventor_Syntax_Color_Type color_type)
 {
-   //TODO: Might need for items
-   return edit_syntax_color_get(pd->main_it->ed, color_type);
+   if ((color_type < ENVENTOR_SYNTAX_COLOR_STRING) ||
+       (color_type >= ENVENTOR_SYNTAX_COLOR_LAST))
+     EINA_LOG_ERR("Invalid color_type(%d)", color_type);
+
+   //Return overriden color values or defaults.
+   if (pd->text_color_val[color_type])
+     return pd->text_color_val[color_type];
+   else
+     return color_value_get(color_type);
 }
 
 EOLIAN static Eo *
@@ -825,6 +852,14 @@ enventor_object_sub_item_add(Enventor_Object *obj, const 
char *file)
 
    pd->sub_its = eina_list_append(pd->sub_its, it);
 
+   //Update Syntax Color Here.
+   int i;
+   for (i = ENVENTOR_SYNTAX_COLOR_STRING; i < ENVENTOR_SYNTAX_COLOR_LAST; i++)
+     {
+        if (!pd->text_color_val[i]) continue;
+        edit_syntax_color_set(it->ed, i, pd->text_color_val[i]);
+     }
+
    return it;
 }
 
diff --git a/src/lib/syntax_color.c b/src/lib/syntax_color.c
index 17d0d5a..a9c114d 100644
--- a/src/lib/syntax_color.c
+++ b/src/lib/syntax_color.c
@@ -874,9 +874,10 @@ color_set(color_data *cd, Enventor_Syntax_Color_Type 
color_type,
 }
 
 const char *
-color_get(color_data *cd, Enventor_Syntax_Color_Type color_type)
+color_value_get(Enventor_Syntax_Color_Type color_type)
 {
-   syntax_color_source *col_src = cd->col_src;
+   syntax_color_source *col_src = &g_color_src;
+   if (!col_src) return NULL;
 
    switch (color_type)
      {

-- 


Reply via email to