[EDC-Editor] Make template of parts to use unique names on insertion

Summary:
To create templates with unique name the counter of created parts is added to the Configure Data.
The line with the name of the part is placed in separate template because it is the same for each part template.

Reviewers: Hermet

Projects: #enventor

Differential Revision: https://phab.enlightenment.org/D1278
This commit is contained in:
Kateryna Fesyna 2014-08-07 21:59:51 +09:00 committed by ChunEon Park
parent e9950a2869
commit 7d24fc8a3c
2 changed files with 25 additions and 6 deletions

View File

@ -8,6 +8,12 @@ const int SYNTAX_COLOR_SPARE_LINES = 42;
const double SYNTAX_COLOR_DEFAULT_TIME = 0.25;
const double SYNTAX_COLOR_SHORT_TIME = 0.025;
static const char ALPHA_STRING[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
static const char ALPHA_STRING_LEN = 52;
typedef struct syntax_color_thread_data_s
{
edit_data *ed;
@ -463,6 +469,14 @@ edit_cur_indent_depth_get(edit_data *ed)
return indent_space_get(syntax_indent_data_get(ed->sh), ed->en_edit);
}
static void
part_name_string_generate(char *part_name_line)
{
char *pos = strstr(part_name_line, QUOT);
while (*(++pos) != QUOT_C)
*pos = ALPHA_STRING[rand() % ALPHA_STRING_LEN];
}
void
edit_template_part_insert(edit_data *ed, Edje_Part_Type type)
{
@ -525,6 +539,14 @@ edit_template_part_insert(edit_data *ed, Edje_Part_Type type)
break;
}
char *part_name_line = strdup(TEMPLATE_PART_NAME_FORMAT);
part_name_string_generate(part_name_line);
elm_entry_entry_insert(ed->en_edit, p);
elm_entry_entry_insert(ed->en_edit, part_name_line);
edit_line_increase(ed, 1);
free(part_name_line);
int i;
for (i = 0; i < (line_cnt - 1); i++)
{
@ -982,6 +1004,7 @@ scroller_vbar_unpress_cb(void *data, Evas_Object *obj EINA_UNUSED,
edit_data *
edit_init(Evas_Object *parent)
{
srand(time(NULL));
parser_data *pd = parser_init();
syntax_helper *sh = syntax_init();

View File

@ -32,12 +32,13 @@ const char *TEMPLATE_GROUP[TEMPLATE_GROUP_LINE_CNT] =
"}"
};
const char * TEMPLATE_PART_NAME_FORMAT =
"part { name: \"PartName\";<br/>";
#define TEMPLATE_PART_IMAGE_LINE_CNT 15
const char *TEMPLATE_PART_IMAGE[TEMPLATE_PART_IMAGE_LINE_CNT] =
{
"part { name: \"XXX\";<br/>",
" type: IMAGE;<br/>",
" scale: 1;<br/>",
" mouse_events: 1;<br/>",
@ -58,7 +59,6 @@ const char *TEMPLATE_PART_IMAGE[TEMPLATE_PART_IMAGE_LINE_CNT] =
const char *TEMPLATE_PART_RECT[TEMPLATE_PART_RECT_LINE_CNT] =
{
"part { name: \"XXX\";<br/>",
" type: RECT;<br/>",
" scale: 1;<br/>",
" mouse_events: 1;<br/>",
@ -78,7 +78,6 @@ const char *TEMPLATE_PART_RECT[TEMPLATE_PART_RECT_LINE_CNT] =
const char *TEMPLATE_PART_SWALLOW[TEMPLATE_PART_SWALLOW_LINE_CNT] =
{
"part { name: \"XXX\";<br/>",
" type: SWALLOW;<br/>",
" scale: 1;<br/>",
" mouse_events: 1;<br/>",
@ -97,7 +96,6 @@ const char *TEMPLATE_PART_SWALLOW[TEMPLATE_PART_SWALLOW_LINE_CNT] =
const char *TEMPLATE_PART_SPACER[TEMPLATE_PART_SPACER_LINE_CNT] =
{
"part { name: \"XXX\";<br/>",
" type: SPACER;<br/>",
" scale: 1;<br/>",
" description { state: \"default\" 0.0;<br/>",
@ -114,7 +112,6 @@ const char *TEMPLATE_PART_SPACER[TEMPLATE_PART_SPACER_LINE_CNT] =
const char *TEMPLATE_PART_TEXT[TEMPLATE_PART_TEXT_LINE_CNT] =
{
"part { name: \"XXX\";<br/>",
" type: TEXT;<br/>",
" scale: 1;<br/>",
" mouse_events: 1;<br/>",
@ -144,7 +141,6 @@ const char *TEMPLATE_PART_TEXT[TEMPLATE_PART_TEXT_LINE_CNT] =
const char *TEMPLATE_PART_TEXTBLOCK[TEMPLATE_PART_TEXTBLOCK_LINE_CNT] =
{
"part { name: \"XXX\";<br/>",
" type: TEXTBLOCK;<br/>",
" description { state: \"default\" 0.0;<br/>",
" rel1 { relative: 0.0 0.0; offset: 0 0; /*to: \"XXX\";*/ }<br/>",