hermet pushed a commit to branch master. http://git.enlightenment.org/tools/enventor.git/commit/?id=89a65c680c31e406542bb67df2ea226f74188af2
commit 89a65c680c31e406542bb67df2ea226f74188af2 Author: ChunEon Park <her...@hermet.pe.kr> Date: Thu Aug 7 22:32:27 2014 +0900 template: refactoring. revise the code. --- src/bin/Makefile.am | 3 ++- src/bin/edc_editor.c | 21 ++------------------- src/bin/template.c | 20 ++++++++++++++++++++ src/include/Makefile.am | 3 ++- src/include/common.h | 1 + src/include/template.h | 1 + src/include/template_code.h | 3 --- 7 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 03c049c..6f90d0f 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -33,7 +33,8 @@ enventor_SOURCES = \ auto_comp.c \ setting.c \ globals.c \ - redoundo.c + redoundo.c \ + template.c enventor_LDADD = @ENVENTOR_LIBS@ enventor_LDFLAGS = $(LTLIBINTL) diff --git a/src/bin/edc_editor.c b/src/bin/edc_editor.c index 10bc611..b44ab5c 100644 --- a/src/bin/edc_editor.c +++ b/src/bin/edc_editor.c @@ -8,12 +8,6 @@ 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; @@ -469,14 +463,6 @@ 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) { @@ -539,13 +525,10 @@ 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); + const char *first_line = template_part_first_line_get(); + elm_entry_entry_insert(ed->en_edit, first_line); edit_line_increase(ed, 1); - free(part_name_line); int i; for (i = 0; i < (line_cnt - 1); i++) diff --git a/src/bin/template.c b/src/bin/template.c new file mode 100644 index 0000000..d44a396 --- /dev/null +++ b/src/bin/template.c @@ -0,0 +1,20 @@ +#include <Elementary.h> +#include "common.h" + +const char *NAME_SEED = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +const int NAME_SEED_LEN = 52; + +const char * +template_part_first_line_get(void) +{ + static char buf[40]; + char name[8]; + int i; + + for (i = 0; i < 8; i++) + name[i] = NAME_SEED[(rand() % NAME_SEED_LEN)]; + + snprintf(buf, sizeof(buf), "part { name: \"%s\";<br/>", name); + + return (const char *) buf; +} diff --git a/src/include/Makefile.am b/src/include/Makefile.am index e7548d8..3d86423 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -25,4 +25,5 @@ EXTRA_DIST = common.h \ goto.h \ setting.h \ search.h \ - redoundo.h + redoundo.h \ + template.h diff --git a/src/include/common.h b/src/include/common.h index f56a3df..c88afd0 100644 --- a/src/include/common.h +++ b/src/include/common.h @@ -33,5 +33,6 @@ typedef struct redoundo_s redoundo_data; #include "auto_comp.h" #include "setting.h" #include "redoundo.h" +#include "template.h" #endif diff --git a/src/include/template.h b/src/include/template.h new file mode 100644 index 0000000..61c4216 --- /dev/null +++ b/src/include/template.h @@ -0,0 +1 @@ +const char *template_part_first_line_get(void); diff --git a/src/include/template_code.h b/src/include/template_code.h index 77338a1..c5ac93a 100644 --- a/src/include/template_code.h +++ b/src/include/template_code.h @@ -32,9 +32,6 @@ 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] = --