hermet pushed a commit to branch master. http://git.enlightenment.org/tools/enventor.git/commit/?id=86d07222f66b19810e6527282bded7726e0224ce
commit 86d07222f66b19810e6527282bded7726e0224ce Author: Hermet Park <[email protected]> Date: Sat Feb 13 03:32:29 2016 +0900 Revert "indent: Apply indentation for newly loaded edc file" This reverts commit 66328e75f31008c84a7b3dda029f0e463e49ffe4. This patch broke enventor :-( please test with games/etypers/data/themes/etyers.edc --- data/templates/basic.edc | 4 +- src/lib/edc_editor.c | 29 +------------ src/lib/enventor_private.h | 1 - src/lib/indent.c | 100 +++------------------------------------------ 4 files changed, 9 insertions(+), 125 deletions(-) diff --git a/data/templates/basic.edc b/data/templates/basic.edc index e862d16..36b3ded 100644 --- a/data/templates/basic.edc +++ b/data/templates/basic.edc @@ -52,7 +52,7 @@ collections { } } } - /* +/* programs { program { "mouse_down"; signal: "mouse,down,1"; @@ -67,6 +67,6 @@ collections { target: "rect"; } } - */ +*/ } } diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c index eac23c7..9c4e062 100644 --- a/src/lib/edc_editor.c +++ b/src/lib/edc_editor.c @@ -1086,23 +1086,6 @@ err: } static void -edit_indent_full_apply(edit_data *ed) -{ - int old_max_line = edit_max_line_get(ed); - int new_max_line = - indent_full_apply(syntax_indent_data_get(ed->sh), ed->en_edit); - - //Correct indentation case - if (new_max_line < 0) return; - - elm_entry_calc_force(ed->en_edit); - syntax_color_partial_update(ed, SYNTAX_COLOR_DEFAULT_TIME); - - line_init(ed); - edit_line_increase(ed, new_max_line); -} - -static void edit_focused_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { @@ -1553,11 +1536,7 @@ edit_load(edit_data *ed, const char *edc_path) elm_entry_entry_set(ed->en_edit, ""); elm_entry_entry_set(ed->en_line, ""); Eina_Bool ret = edit_edc_load(ed, edc_path); - if (ret) - { - if (edit_auto_indent_get(ed)) edit_indent_full_apply(ed); - edit_changed_set(ed, EINA_TRUE); - } + if (ret) edit_changed_set(ed, EINA_TRUE); edj_mgr_reload_need_set(EINA_TRUE); redoundo_clear(ed->rd); @@ -1750,12 +1729,6 @@ edit_auto_indent_set(edit_data *ed, Eina_Bool auto_indent) { auto_indent = !!auto_indent; ed->auto_indent = auto_indent; - - if (ed->auto_indent) - { - edit_indent_full_apply(ed); - edit_changed_set(ed, EINA_TRUE); - } } Eina_Bool diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h index c9a095a..f71a473 100644 --- a/src/lib/enventor_private.h +++ b/src/lib/enventor_private.h @@ -157,7 +157,6 @@ void indent_term(indent_data *id); int indent_space_get(indent_data *id, Evas_Object *entry); int indent_insert_apply(indent_data *id, Evas_Object *entry, const char *insert, int cur_line); Eina_Bool indent_delete_apply(indent_data *id, Evas_Object *entry, const char *del, int cur_line); -int indent_full_apply(indent_data *id, Evas_Object *entry); /* build */ diff --git a/src/lib/indent.c b/src/lib/indent.c index 63e8cbb..f0b04d8 100644 --- a/src/lib/indent.c +++ b/src/lib/indent.c @@ -148,63 +148,6 @@ indent_insert_bracket_case(indent_data *id, Evas_Object *entry, int cur_line) free(utf8); } -static Eina_Bool -indent_error_check(indent_data *id EINA_UNUSED, Evas_Object *entry) -{ - const char *text = elm_entry_entry_get(entry); - char *utf8 = elm_entry_markup_to_utf8(text); - char *utf8_ptr = NULL; - char *utf8_end = NULL; - int utf8_size = strlen(utf8); - int depth = 0; - int space = 0; - Eina_Bool space_valid = EINA_TRUE; - - utf8_ptr = utf8; - utf8_end = utf8 + utf8_size; - while (utf8_ptr < utf8_end) - { - if (*utf8_ptr == ' ') - { - if (space_valid) space++; - } - else if (*utf8_ptr == '\n') - { - space = 0; - space_valid = EINA_TRUE; - } - else - { - if (*utf8_ptr == '}') - { - depth--; - if (depth < 0) return EINA_TRUE; - - char *utf8_next_ptr = utf8_ptr + 1; - if ((utf8_next_ptr < utf8_end) && (*utf8_next_ptr != '\n')) - return EINA_TRUE; - } - else if (*utf8_ptr == ';') - { - char *utf8_next_ptr = utf8_ptr + 1; - if ((utf8_next_ptr < utf8_end) && (*utf8_next_ptr != '\n')) - return EINA_TRUE; - } - - if (space_valid) - { - if (space != depth * TAB_SPACE) return EINA_TRUE; - space_valid = EINA_FALSE; - } - - if (*utf8_ptr == '{') depth++; - } - utf8_ptr++; - } - - return EINA_FALSE; -} - /*****************************************************************************/ /* Externally accessible calls */ /*****************************************************************************/ @@ -295,8 +238,7 @@ indent_delete_apply(indent_data *id EINA_UNUSED, Evas_Object *entry, static int indent_text_auto_format(indent_data *id EINA_UNUSED, - Evas_Object *entry, const char *insert, - Eina_Bool paste) + Evas_Object *entry, const char *insert) { int line_cnt = 0; char *utf8 = evas_textblock_text_markup_to_utf8(NULL, insert); @@ -343,25 +285,9 @@ indent_text_auto_format(indent_data *id EINA_UNUSED, if (!code_lines) return line_cnt; tb_cur_pos = evas_textblock_cursor_pos_get(cur_end); evas_textblock_cursor_pos_set(cur_start, tb_cur_pos - utf8_size); - - char *frmt_buf = NULL; - - /* Insert string by pasting string to entry. - Cancel added data about pasted string without indentation. */ - if (paste) redoundo_n_diff_cancel(rd, 1); - /* Insert string by replacing string to textblock of entry. - Add data about replaced string into the redoundo queue. */ - else - { - frmt_buf = - evas_textblock_cursor_range_text_get(cur_start, cur_end, - EVAS_TEXTBLOCK_TEXT_MARKUP); - redoundo_text_push(rd, frmt_buf, tb_cur_pos - utf8_size, 0, EINA_FALSE); - free(frmt_buf); - } - //Delete replaced string. evas_textblock_cursor_range_delete(cur_start, cur_end); + char *frmt_buf = NULL; Eina_List *l = NULL; Eina_Stringshare *line; evas_textblock_cursor_line_char_first(cur_start); @@ -410,10 +336,11 @@ indent_text_auto_format(indent_data *id EINA_UNUSED, tb_cur_pos = evas_textblock_cursor_pos_get(cur_start); evas_textblock_cursor_pos_set(cur_end, tb_cur_pos); - //Insert formatted string. evas_object_textblock_text_markup_prepend(cur_start, frmt_buf); - //Add data about inserted string into the redoundo queue. + // Cancel last added diff, that was created when text pasted into entry. + redoundo_n_diff_cancel(rd, 1); + //Add data about formatted change into the redoundo queue. redoundo_text_push(rd, frmt_buf, tb_cur_pos, 0, EINA_TRUE); eina_strbuf_free(buf); @@ -441,21 +368,6 @@ indent_insert_apply(indent_data *id, Evas_Object *entry, const char *insert, return 1; } else - return indent_text_auto_format(id, entry, insert, EINA_TRUE); + return indent_text_auto_format(id, entry, insert); } } - -int -indent_full_apply(indent_data *id, Evas_Object *entry) -{ - //Correct indentation case - if (!indent_error_check(id, entry)) return -1; - - const char *text = elm_entry_entry_get(entry); - Evas_Object *tb = elm_entry_textblock_get(entry); - Evas_Textblock_Cursor *cur = evas_object_textblock_cursor_get(tb); - - //Move cursor to the last position to replace whole edc text. - evas_textblock_cursor_paragraph_last(cur); - return indent_text_auto_format(id, entry, text, EINA_FALSE); -} --
