From 899551a20c7d3ae66d661b989ec6c279f7251a9c Mon Sep 17 00:00:00 2001 From: Jaehyun Cho Date: Tue, 3 Feb 2015 15:21:01 +0900 Subject: [PATCH] config: Add config_syntax_color_set()/get() functions. Add config_syntax_color_set()/get() functions to save and load --- src/bin/config_data.c | 36 +++++++++++++++++++++++++ src/bin/main.c | 56 +++++++++++++++++++++++++++++++++++++++ src/include/config_data.h | 2 ++ 3 files changed, 94 insertions(+) diff --git a/src/bin/config_data.c b/src/bin/config_data.c index 75f2edb..27dd93d 100644 --- a/src/bin/config_data.c +++ b/src/bin/config_data.c @@ -14,6 +14,8 @@ typedef struct config_s Eina_Strbuf *edc_fnt_path_buf; //pre-stored font paths for edc compile. Eina_Strbuf *edc_dat_path_buf; //pre-stored data paths for edc compile. + Eina_List *syntax_color_list; + float font_scale; double view_scale; double console_size; @@ -36,6 +38,7 @@ typedef struct config_s static config_data *g_cd = NULL; static Eet_Data_Descriptor *edd_base = NULL; +static Eet_Data_Descriptor *edd_color = NULL; static void config_edj_path_update(config_data *cd) @@ -186,6 +189,13 @@ config_load(void) else cd->edc_dat_path_buf = config_paths_buf_set(cd->edc_dat_path_list, " -dd "); + if (!cd->syntax_color_list) + { + Enventor_Syntax_Color_Type color_type = ENVENTOR_SYNTAX_COLOR_STRING; + for (; color_type < ENVENTOR_SYNTAX_COLOR_LAST; color_type++) + cd->syntax_color_list = eina_list_append(cd->syntax_color_list, NULL); + } + return cd; } @@ -205,6 +215,8 @@ eddc_init(void) "edc_fnt_path_list", edc_fnt_path_list); EET_DATA_DESCRIPTOR_ADD_LIST_STRING(edd_base, config_data, "edc_dat_path_list", edc_dat_path_list); + EET_DATA_DESCRIPTOR_ADD_LIST_STRING(edd_base, config_data, + "syntax_color_list", syntax_color_list); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_base, config_data, "font_scale", font_scale, EET_T_FLOAT); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_base, config_data, "view_scale", @@ -279,6 +291,8 @@ config_term(void) EINA_LIST_FREE(cd->edc_fnt_path_list, str) eina_stringshare_del(str); EINA_LIST_FREE(cd->edc_dat_path_list, str) eina_stringshare_del(str); + EINA_LIST_FREE(cd->syntax_color_list, str) eina_stringshare_del(str); + if (cd->edc_img_path_buf) eina_strbuf_free(cd->edc_img_path_buf); if (cd->edc_snd_path_buf) eina_strbuf_free(cd->edc_snd_path_buf); if (cd->edc_fnt_path_buf) eina_strbuf_free(cd->edc_fnt_path_buf); @@ -537,6 +551,28 @@ config_edj_path_get(void) return cd->edj_path; } +void +config_syntax_color_set(Enventor_Syntax_Color_Type color_type, + const char *val) +{ + config_data *cd = g_cd; + Eina_List *target_list; + + target_list = eina_list_nth_list(cd->syntax_color_list, color_type); + if (!target_list) return; + + eina_stringshare_del(eina_list_data_get(target_list)); + if (val) + eina_list_data_set(target_list, eina_stringshare_add(val)); +} + +const char * +config_syntax_color_get(Enventor_Syntax_Color_Type color_type) +{ + config_data *cd = g_cd; + return (const char *) eina_list_nth(cd->syntax_color_list, color_type); +} + Eina_Bool config_linenumber_get(void) { diff --git a/src/bin/main.c b/src/bin/main.c index 1b68e55..82b8a37 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -109,6 +109,56 @@ template_insert_patch(app_data *ad, const char *key) return ECORE_CALLBACK_DONE; } +static void +syntax_color_update(Evas_Object *enventor) +{ + const char *config_color; + const char *enventor_color; + Eina_Bool color_changed = EINA_FALSE; + Enventor_Syntax_Color_Type color_type; + + color_type = ENVENTOR_SYNTAX_COLOR_STRING; + for (; color_type < ENVENTOR_SYNTAX_COLOR_LAST; color_type++) + { + config_color = config_syntax_color_get(color_type); + if (config_color) + { + enventor_color = enventor_object_syntax_color_get(enventor, + color_type); + if (strcmp(config_color, enventor_color)) + { + enventor_object_syntax_color_set(enventor, color_type, + config_color); + color_changed = EINA_TRUE; + } + } + } + + if (color_changed) + enventor_object_syntax_color_full_apply(enventor, EINA_TRUE); +} + +static void +syntax_color_init(Evas_Object *enventor) +{ + const char *config_color; + const char *enventor_color; + Eina_Bool color_changed = EINA_FALSE; + Enventor_Syntax_Color_Type color_type; + + color_type = ENVENTOR_SYNTAX_COLOR_STRING; + for (; color_type < ENVENTOR_SYNTAX_COLOR_LAST; color_type++) + { + config_color = config_syntax_color_get(color_type); + if (!config_color) + { + enventor_color = enventor_object_syntax_color_get(enventor, + color_type); + config_syntax_color_set(color_type, enventor_color); + } + } +} + static void config_update_cb(void *data) { @@ -133,6 +183,8 @@ config_update_cb(void *data) enventor_object_part_highlight_set(enventor, config_part_highlight_get()); enventor_object_live_view_scale_set(enventor, config_view_scale_get()); + syntax_color_update(enventor); + Evas_Coord w, h; if (config_view_size_configurable_get()) config_view_size_get(&w, &h); @@ -840,6 +892,10 @@ init(app_data *ad, int argc, char **argv) template_show(ad); + //Initialize syntax color. + syntax_color_init(ad->enventor); + syntax_color_update(ad->enventor); + return EINA_TRUE; } diff --git a/src/include/config_data.h b/src/include/config_data.h index 3d6e521..f40ac65 100644 --- a/src/include/config_data.h +++ b/src/include/config_data.h @@ -19,6 +19,8 @@ Eina_List *config_edc_img_path_list_get(void); Eina_List *config_edc_snd_path_list_get(void); Eina_List *config_edc_fnt_path_list_get(void); Eina_List *config_edc_dat_path_list_get(void); +void config_syntax_color_set(Enventor_Syntax_Color_Type color_type, const char *val); +const char *config_syntax_color_get(Enventor_Syntax_Color_Type color_type); void config_update_cb_set(void (*cb)(void *data), void *data); void config_stats_bar_set(Eina_Bool enabled); void config_linenumber_set(Eina_Bool enabled);