multi-file: support syntax_colors.

a# Please enter the commit message for your changes. Lines starting
This commit is contained in:
Hermet Park 2016-07-27 15:37:46 +09:00
parent 21dac2992c
commit 3db26261f7
5 changed files with 44 additions and 14 deletions

View File

@ -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);

View File

@ -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)
{

View File

@ -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);

View File

@ -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;
}

View File

@ -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)
{