hermet pushed a commit to branch master. http://git.enlightenment.org/tools/enventor.git/commit/?id=eda850d9dbfea1f050f966aae6f5ef34b9cd7a53
commit eda850d9dbfea1f050f966aae6f5ef34b9cd7a53 Author: Hermet Park <[email protected]> Date: Thu Jul 21 20:53:13 2016 +0900 multi-file: support edc navigator. --- src/bin/edc_navigator.c | 5 +- src/lib/Enventor_Legacy.h | 2 +- src/lib/edc_editor.c | 10 +++ src/lib/edc_parser.c | 162 ++++++++++++++++++++++++++++++++++++++++++++- src/lib/enventor_private.h | 2 + src/lib/enventor_smart.c | 7 ++ 6 files changed, 184 insertions(+), 4 deletions(-) diff --git a/src/bin/edc_navigator.c b/src/bin/edc_navigator.c index 46eb281..65db5d6 100644 --- a/src/bin/edc_navigator.c +++ b/src/bin/edc_navigator.c @@ -1368,8 +1368,9 @@ edc_navigator_group_update(const char *cur_group) //Cancel item selection if group was not indicated. if (!cur_group) navigator_item_deselect(nd); + Eina_List *group_list = + enventor_item_group_list_get(file_mgr_focused_item_get()); - Eina_List *group_list = edje_file_collection_list(config_output_path_get()); unsigned int cur_group_len = 0; group_it *git; Eina_List *l, *ll; @@ -1449,7 +1450,7 @@ edc_navigator_group_update(const char *cur_group) group_update(nd, git); } - edje_file_collection_list_free(group_list); + EINA_LIST_FREE(group_list, name) eina_stringshare_del(name); } Evas_Object * diff --git a/src/lib/Enventor_Legacy.h b/src/lib/Enventor_Legacy.h index 979efe0..ab0f67e 100644 --- a/src/lib/Enventor_Legacy.h +++ b/src/lib/Enventor_Legacy.h @@ -31,6 +31,6 @@ Eina_Bool enventor_item_template_insert(Enventor_Item *it, char *syntax, size_t Eina_Bool enventor_item_template_part_insert(Enventor_Item *it, Edje_Part_Type part, Enventor_Template_Insert_Type insert_type, Eina_Bool fixed_w, Eina_Bool fixed_h, char *rel1_x_to, char *rel1_y_to, char *rel2_x_to, char *rel2_y_to, float align_x, float align_y, int min_w, int min_h, float rel1_x, float rel1_y, float rel2_x,float rel2_y, char *syntax, size_t n); EAPI Eina_Bool enventor_item_redo(Enventor_Item *it); EAPI Eina_Bool enventor_item_undo(Enventor_Item *it); - +EAPI Eina_List *enventor_item_group_list_get(Enventor_Item *it); #include "enventor_object.eo.legacy.h" diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c index 249d8b6..fbd109c 100644 --- a/src/lib/edc_editor.c +++ b/src/lib/edc_editor.c @@ -1861,3 +1861,13 @@ edit_focus_get(edit_data *ed) { return elm_object_focus_get(ed->en_edit); } + +Eina_List * +edit_group_list_get(edit_data *ed) +{ + if (!ed) return NULL; + + return parser_group_list_get(ed->pd, ed->en_edit); +} + + diff --git a/src/lib/edc_parser.c b/src/lib/edc_parser.c index 58f07a7..63fba09 100644 --- a/src/lib/edc_parser.c +++ b/src/lib/edc_parser.c @@ -67,6 +67,7 @@ typedef struct bracket_thread_data_s } bracket_td; + struct parser_s { Eina_Inarray *attrs; @@ -1981,6 +1982,7 @@ parser_first_group_name_get(parser_data *pd, Evas_Object *entry) { const char *markup = elm_entry_entry_get(entry); char *utf8 = elm_entry_markup_to_utf8(markup); + int utf8_len = strlen(utf8); char *p = utf8; const char *quot = QUOT_UTF8; @@ -1995,7 +1997,7 @@ parser_first_group_name_get(parser_data *pd, Evas_Object *entry) parser_macro_list_set(pd, (const char *) utf8); Eina_List *macro_list = parser_macro_list_get(pd); - while (p < (utf8 + strlen(utf8))) + while (p < (utf8 + utf8_len)) { if (*p == '\n') cur_line++; @@ -2013,6 +2015,54 @@ parser_first_group_name_get(parser_data *pd, Evas_Object *entry) continue; } + //Skip comments: /* ~ */ + if ((*p == '/') && (*(++p) == '*')) + { + p = strstr(p, "*/"); + if (!p) goto end; + p += 2; + continue; + } + + //Skip comments: // + if ((*p == '/') && (*(++p) == '/')) + { + p = strstr(p, "\n"); + if (!p) goto end; + p++; + continue; + } + + //Skip #if ~ #endif + if (!strncmp(p, "#if", 3)) + { + p = strstr(p, "#endif"); + if (!p) goto end; + p++; + continue; + } + + //Skip #define + if (!strncmp(p, "#define", 7)) + { + //escape "\", "ie, #define .... \" + p += 7; //strlen(#define) + + while (p < (utf8 + utf8_len)) + { + char *slash = strstr(p, "\\"); + if (!slash) break; + + char *eol = strstr(p, "\""); + if (!eol) goto end; + + if (eol < slash) break; + + p = eol + 1; + } + } + + //group? if (!strncmp(p, group, group_len)) { p += group_len; @@ -2269,3 +2319,113 @@ parser_bracket_find(parser_data *pd, Evas_Object *entry, bracket_thread_cancel, btd); } + +Eina_List * +parser_group_list_get(parser_data *pd, Evas_Object *entry) +{ + const char *markup = elm_entry_entry_get(entry); + char *utf8 = elm_entry_markup_to_utf8(markup); + int utf8_len = strlen(utf8); + char *p = utf8; + + const char *quot = QUOT_UTF8; + const char *group = "group"; + const int quot_len = QUOT_UTF8_LEN; + const int group_len = 5; //strlen("group"); + const char *group_name = NULL; + Eina_List *group_list = NULL; + + while (p < (utf8 + utf8_len)) + { + //Skip "" range + if (!strncmp(p, quot, quot_len)) + { + p += quot_len; + p = strstr(p, quot); + if (!p) goto end; + p += quot_len; + continue; + } + + //Skip comments: /* ~ */ + if ((*p == '/') && (*(++p) == '*')) + { + p = strstr(p, "*/"); + if (!p) goto end; + p += 2; + continue; + } + + //Skip comments: // + if ((*p == '/') && (*(++p) == '/')) + { + p = strstr(p, "\n"); + if (!p) goto end; + p++; + continue; + } + + //Skip #if ~ #endif + if (!strncmp(p, "#if", 3)) + { + p = strstr(p, "#endif"); + if (!p) goto end; + p++; + continue; + } + + //Skip #define + if (!strncmp(p, "#define", 7)) + { + //escape "\", "ie, #define .... \" + p += 7; //strlen(#define) + + while (p < (utf8 + utf8_len)) + { + char *slash = strstr(p, "\\"); + if (!slash) break; + + char *eol = strstr(p, "\""); + if (!eol) goto end; + + if (eol < slash) break; + + p = eol + 1; + } + } + + //group? + if (!strncmp(p, group, group_len)) + { + p += group_len; + + if (((*p != ' ') && (*p != '{') && (*p != '\n') && (*p != '\t'))) + continue; + + p++; + + //We found a group + p = strstr(p, quot); + if (!p) goto end; + + p++; + char *name_begin = p; + + p = strstr(p, quot); + if (!p) goto end; + + char *name_end = p; + + group_name = eina_stringshare_add_length(name_begin, + name_end - name_begin); + if (group_name) + group_list = eina_list_append(group_list, group_name); + } + p++; + } + +end: + free(utf8); + + return group_list; +} diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h index 4b6d70c..f308910 100644 --- a/src/lib/enventor_private.h +++ b/src/lib/enventor_private.h @@ -127,6 +127,7 @@ void parser_macro_update(parser_data *pd, Eina_Bool macro_update); typedef void (*Bracket_Update_Cb)(void *data, int left, int right); void parser_bracket_find(parser_data *pd, Evas_Object *entry, Bracket_Update_Cb func, void *data); void parser_bracket_cancel(parser_data *pd); +Eina_List *parser_group_list_get(parser_data *pd, Evas_Object *entry); /* syntax helper */ syntax_helper *syntax_init(edit_data *ed); @@ -285,6 +286,7 @@ const char *edit_selection_get(edit_data *ed); Eina_Bool edit_is_main_file(edit_data *ed); Eina_Bool edit_focus_get(edit_data *ed); void edit_focus_set(edit_data *ed, Eina_Bool focus); +Eina_List *edit_group_list_get(edit_data *ed); /* util */ void mem_fail_msg(void); diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c index d1f058c..c6b78ac 100644 --- a/src/lib/enventor_smart.c +++ b/src/lib/enventor_smart.c @@ -1173,5 +1173,12 @@ enventor_item_undo(Enventor_Item *it) return edit_redoundo(it->ed, EINA_TRUE); } +EAPI Eina_List * +enventor_item_group_list_get(Enventor_Item *it) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(it, NULL); + + return edit_group_list_get(it->ed); +} #include "enventor_object.eo.c" --
