hermet pushed a commit to branch master. http://git.enlightenment.org/tools/enventor.git/commit/?id=afbf2db73a39f817d0fd937117d3521c887e53b8
commit afbf2db73a39f817d0fd937117d3521c887e53b8 Author: ChunEon Park <[email protected]> Date: Wed Aug 13 23:12:51 2014 +0900 template: fix to not insert empty line in editor template insert. --- src/bin/live_edit.c | 15 +++++----- src/bin/main.c | 33 +++++++++++---------- src/bin/template.c | 71 +++++++++++++++++---------------------------- src/include/template.h | 16 ++++++++-- src/include/template_code.h | 4 +-- 5 files changed, 67 insertions(+), 72 deletions(-) diff --git a/src/bin/live_edit.c b/src/bin/live_edit.c index 7fa8e26..1b604ba 100644 --- a/src/bin/live_edit.c +++ b/src/bin/live_edit.c @@ -184,13 +184,14 @@ key_down_cb(void *data, int type EINA_UNUSED, void *ev) if (!strcmp(event->key, "Return")) { - template_live_edit_part_insert(ld->ed, - MENU_ITEMS[ld->cur_part_data->type].type, - ld->cur_part_data->rel1_x, - ld->cur_part_data->rel1_y, - ld->cur_part_data->rel2_x, - ld->cur_part_data->rel2_y, - view_group_name_get(VIEW_DATA)); + template_part_insert(ld->ed, + MENU_ITEMS[ld->cur_part_data->type].type, + TEMPLATE_INSERT_LIVE_EDIT, + ld->cur_part_data->rel1_x, + ld->cur_part_data->rel1_y, + ld->cur_part_data->rel2_x, + ld->cur_part_data->rel2_y, + view_group_name_get(VIEW_DATA)); } else if (strcmp(event->key, "Delete")) return EINA_TRUE; diff --git a/src/bin/main.c b/src/bin/main.c index b7388d5..4c85a56 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -71,7 +71,7 @@ auto_indentation_toggle() static Eina_Bool template_insert_patch(app_data *ad, const char *key) { - Edje_Part_Type type; + Edje_Part_Type part_type; if (config_live_edit_get()) { stats_info_msg_update("Insertion of template code is disabled " @@ -80,33 +80,34 @@ template_insert_patch(app_data *ad, const char *key) } if (!strcmp(key, "a") || !strcmp(key, "A")) - type = EDJE_PART_TYPE_TABLE; + part_type = EDJE_PART_TYPE_TABLE; else if (!strcmp(key, "b") || !strcmp(key, "B")) - type = EDJE_PART_TYPE_TEXTBLOCK; + part_type = EDJE_PART_TYPE_TEXTBLOCK; else if (!strcmp(key, "e") || !strcmp(key, "E")) - type = EDJE_PART_TYPE_EXTERNAL; + part_type = EDJE_PART_TYPE_EXTERNAL; else if (!strcmp(key, "g") || !strcmp(key, "G")) - type = EDJE_PART_TYPE_GRADIENT; + part_type = EDJE_PART_TYPE_GRADIENT; else if (!strcmp(key, "i") || !strcmp(key, "I")) - type = EDJE_PART_TYPE_IMAGE; + part_type = EDJE_PART_TYPE_IMAGE; else if (!strcmp(key, "o") || !strcmp(key, "O")) - type = EDJE_PART_TYPE_GROUP; + part_type = EDJE_PART_TYPE_GROUP; else if (!strcmp(key, "p") || !strcmp(key, "P")) - type = EDJE_PART_TYPE_PROXY; + part_type = EDJE_PART_TYPE_PROXY; else if (!strcmp(key, "r") || !strcmp(key, "R")) - type = EDJE_PART_TYPE_RECTANGLE; + part_type = EDJE_PART_TYPE_RECTANGLE; else if (!strcmp(key, "t") || !strcmp(key, "T")) - type = EDJE_PART_TYPE_TEXT; + part_type = EDJE_PART_TYPE_TEXT; else if (!strcmp(key, "s") || !strcmp(key, "S")) - type = EDJE_PART_TYPE_SPACER; + part_type = EDJE_PART_TYPE_SPACER; else if (!strcmp(key, "w") || !strcmp(key, "W")) - type = EDJE_PART_TYPE_SWALLOW; + part_type = EDJE_PART_TYPE_SWALLOW; else if (!strcmp(key, "x") || !strcmp(key, "X")) - type = EDJE_PART_TYPE_BOX; + part_type = EDJE_PART_TYPE_BOX; else - type = EDJE_PART_TYPE_NONE; + part_type = EDJE_PART_TYPE_NONE; - template_part_insert(ad->ed, type); + template_part_insert(ad->ed, part_type, TEMPLATE_INSERT_DEFAULT, + REL1_X, REL1_Y, REL2_X, REL2_Y, NULL); return ECORE_CALLBACK_DONE; } @@ -161,7 +162,7 @@ ctrl_func(app_data *ad, const char *key) "while in Live Edit mode"); return ECORE_CALLBACK_DONE; } - template_insert(ad->ed); + template_insert(ad->ed, TEMPLATE_INSERT_DEFAULT); return ECORE_CALLBACK_DONE; } //Full Edit View diff --git a/src/bin/template.c b/src/bin/template.c index 2b1d8bc..59d887a 100644 --- a/src/bin/template.c +++ b/src/bin/template.c @@ -2,11 +2,6 @@ #include "common.h" #include "template_code.h" -typedef enum { - TEMPLATE_PART_INSERT_DEFAULT, - TEMPLATE_PART_INSERT_LIVE_EDIT -} Template_Part_Insert_Type; - const char *NAME_SEED = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; const int NAME_SEED_LEN = 52; @@ -36,7 +31,7 @@ image_description_add(edit_data *ed) if (images_block) { elm_entry_cursor_pos_set(edit_entry, cursor_pos); - template_insert(ed); + template_insert(ed, TEMPLATE_INSERT_LIVE_EDIT); } else { @@ -53,12 +48,12 @@ image_description_add(edit_data *ed) static int template_part_insert_cursor_pos_set(edit_data *ed, - Template_Part_Insert_Type insert_type, + Template_Insert_Type insert_type, const Eina_Stringshare *group_name) { int cursor_pos = -1; Evas_Object *edit_entry = edit_entry_get(ed); - if (insert_type == TEMPLATE_PART_INSERT_LIVE_EDIT) + if (insert_type == TEMPLATE_INSERT_LIVE_EDIT) { cursor_pos = parser_end_of_parts_block_pos_get(edit_entry, group_name); if (cursor_pos != -1) @@ -72,16 +67,14 @@ template_part_insert_cursor_pos_set(edit_data *ed, return cursor_pos; } -static void -internal_template_part_insert(edit_data *ed, - Edje_Part_Type type, - float rel1_x, float rel1_y, - float rel2_x, float rel2_y, - Template_Part_Insert_Type insert_type, - const Eina_Stringshare *group_name) +void +template_part_insert(edit_data *ed, Edje_Part_Type part_type, + Template_Insert_Type insert_type, float rel1_x, + float rel1_y, float rel2_x, float rel2_y, + const Eina_Stringshare *group_name) { - if ((type == EDJE_PART_TYPE_IMAGE) && - (insert_type == TEMPLATE_PART_INSERT_LIVE_EDIT)) + if ((part_type == EDJE_PART_TYPE_IMAGE) && + (insert_type == TEMPLATE_INSERT_LIVE_EDIT)) image_description_add(ed); Evas_Object *edit_entry = edit_entry_get(ed); @@ -101,7 +94,7 @@ internal_template_part_insert(edit_data *ed, char buf[64]; char part[20]; - switch(type) + switch(part_type) { case EDJE_PART_TYPE_RECTANGLE: line_cnt = TEMPLATE_PART_RECT_LINE_CNT; @@ -148,7 +141,6 @@ internal_template_part_insert(edit_data *ed, elm_entry_entry_insert(edit_entry, p); template_part_first_line_get(first_line, 40); elm_entry_entry_insert(edit_entry, first_line); - edit_line_increase(ed, 1); //Insert part body int i; @@ -176,9 +168,16 @@ internal_template_part_insert(edit_data *ed, elm_entry_entry_insert(edit_entry, t[i]); } + //add new line only in live edit mode + if (insert_type == TEMPLATE_INSERT_LIVE_EDIT) + elm_entry_entry_insert(edit_entry, "<br/>"); + /* Increase (part name + body + relatives + tail) line. But line increase - count should be -1 because the cursor position would be taken one line. */ - edit_line_increase(ed, (1 + line_cnt + 2 + TEMPLATE_PART_TALE_LINE_CNT) - 1); + count should be -1 in entry template insertion because the + cursor position would be taken one line additionally. */ + int line_inc = 1 + line_cnt + 2 + TEMPLATE_PART_TALE_LINE_CNT; + if (insert_type == TEMPLATE_INSERT_DEFAULT) line_inc--; + edit_line_increase(ed, line_inc); int cursor_pos2 = elm_entry_cursor_pos_get(edit_entry); edit_redoundo_region_push(ed, cursor_pos1, cursor_pos2); @@ -193,24 +192,7 @@ internal_template_part_insert(edit_data *ed, } void -template_live_edit_part_insert(edit_data *ed, Edje_Part_Type type, float rel1_x, - float rel1_y, float rel2_x, float rel2_y, - const Eina_Stringshare *group_name) -{ - internal_template_part_insert(ed, type, rel1_x, rel1_y, rel2_x, rel2_y, - TEMPLATE_PART_INSERT_LIVE_EDIT, group_name); -} - -void -template_part_insert(edit_data *ed, Edje_Part_Type type) -{ - internal_template_part_insert(ed, type, TEMPLATE_PART_INSERT_DEFAULT, - 0.25, 0.25, 0.75, 0.75, NULL); -} - - -void -template_insert(edit_data *ed) +template_insert(edit_data *ed, Template_Insert_Type insert_type) { const char *EXCEPT_MSG = "Can't insert template code here. Move the cursor" " inside the \"Collections,Images,Parts,Part," "Programs\" scope."; @@ -225,7 +207,8 @@ template_insert(edit_data *ed) if (!strcmp(paragh, "parts")) { - template_part_insert(ed, EDJE_PART_TYPE_IMAGE); + template_part_insert(ed, EDJE_PART_TYPE_IMAGE, TEMPLATE_INSERT_DEFAULT, + REL1_X, REL1_Y, REL2_X, REL2_Y, NULL); goto end; } @@ -264,7 +247,6 @@ template_insert(edit_data *ed) stats_info_msg_update(EXCEPT_MSG); goto end; } - int cursor_pos = elm_entry_cursor_pos_get(entry); elm_entry_cursor_line_begin_set(entry); int cursor_pos1 = elm_entry_cursor_pos_get(entry); @@ -284,9 +266,10 @@ template_insert(edit_data *ed) elm_entry_entry_insert(entry, p); elm_entry_entry_insert(entry, t[i]); - /* Line increase count should be -1 because the cursor position would be - taken one line. */ - edit_line_increase(ed, (line_cnt - 1)); + /* Line increase count should be -1 in entry template insertion because the + cursor position would be taken one line additionally. */ + if (insert_type == TEMPLATE_INSERT_DEFAULT) line_cnt--; + edit_line_increase(ed, line_cnt); int cursor_pos2 = elm_entry_cursor_pos_get(entry); edit_redoundo_region_push(ed, cursor_pos1, cursor_pos2); diff --git a/src/include/template.h b/src/include/template.h index 071de95..ea58703 100644 --- a/src/include/template.h +++ b/src/include/template.h @@ -1,3 +1,13 @@ -void template_insert(edit_data *ed); -void template_part_insert(edit_data *ed, Edje_Part_Type type); -void template_live_edit_part_insert(edit_data *ed, Edje_Part_Type type, float rel1_x, float rel1_y, float rel2_x, float rel2_y, const Eina_Stringshare *group_name); +#define REL1_X 0.25f +#define REL1_Y 0.25f +#define REL2_X 0.75f +#define REL2_Y 0.75f + +typedef enum { + TEMPLATE_INSERT_DEFAULT, + TEMPLATE_INSERT_LIVE_EDIT +} Template_Insert_Type; + +void template_part_insert(edit_data *ed, Edje_Part_Type part_type, Template_Insert_Type insert_type, float rel1_x, float rel1_y, float rel2_x, float rel2_y, const Eina_Stringshare *group_name); +void template_insert(edit_data *ed, Template_Insert_Type insert_type); + diff --git a/src/include/template_code.h b/src/include/template_code.h index 7f8fb9c..e377cab 100644 --- a/src/include/template_code.h +++ b/src/include/template_code.h @@ -34,10 +34,10 @@ const char *TEMPLATE_GROUP[TEMPLATE_GROUP_LINE_CNT] = #define TEMPLATE_PART_TALE_LINE_CNT 2 -const char *TEMPLATE_PART_TALE[TEMPLATE_PART_TALE_LINE_CNT] = +const char *TEMPLATE_PART_TALE[TEMPLATE_PART_TALE_LINE_CNT] = { " }<br/>", - "}<br/>" + "}" }; #define TEMPLATE_PART_IMAGE_LINE_CNT 10 --
