multi-file: support edc navigator.

This commit is contained in:
Hermet Park 2016-07-21 20:53:13 +09:00
parent 505ea04e28
commit eda850d9db
6 changed files with 184 additions and 4 deletions

View File

@ -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 *

View File

@ -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"

View File

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

View File

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

View File

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

View File

@ -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"