From fbc8111b5679aa6a658f752e2648a92a9602ab36 Mon Sep 17 00:00:00 2001 From: Mykyta Biliavskyi Date: Wed, 30 Dec 2015 14:35:25 +0900 Subject: [PATCH] Template: fix indention for generated "styles" block. @fix T2973 --- src/lib/template.c | 24 ++++++++++++++++++++++-- src/lib/template_code.h | 12 ++++++------ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/lib/template.c b/src/lib/template.c index 2463d69..995260f 100644 --- a/src/lib/template.c +++ b/src/lib/template.c @@ -81,17 +81,37 @@ textblock_style_add(edit_data *ed, const char *style_name) elm_entry_cursor_line_begin_set(edit_entry); int cursor_pos1 = elm_entry_cursor_pos_get(edit_entry); + int space = edit_cur_indent_depth_get(ed); + if (styles_block) + space -= TAB_SPACE; + + //Alloc Empty spaces + char *p = alloca(space + 1); + memset(p, ' ', space); + p[space] = '\0'; + if (!styles_block) - elm_entry_entry_insert(edit_entry, TEMPLATE_TEXTBLOCK_STYLE_BLOCK[0]); + { + elm_entry_entry_insert(edit_entry, p); + elm_entry_entry_insert(edit_entry, TEMPLATE_TEXTBLOCK_STYLE_BLOCK[0]); + } int buf_len = strlen(TEMPLATE_TEXTBLOCK_STYLE_BLOCK[1]) + strlen(style_name); char *buf = malloc(buf_len); snprintf(buf, buf_len, TEMPLATE_TEXTBLOCK_STYLE_BLOCK[1], style_name); + elm_entry_entry_insert(edit_entry, p); elm_entry_entry_insert(edit_entry, buf); + elm_entry_entry_insert(edit_entry, p); + elm_entry_entry_insert(edit_entry, TEMPLATE_TEXTBLOCK_STYLE_BLOCK[2]); + elm_entry_entry_insert(edit_entry, p); + elm_entry_entry_insert(edit_entry, TEMPLATE_TEXTBLOCK_STYLE_BLOCK[3]); free(buf); if (!styles_block) - elm_entry_entry_insert(edit_entry, TEMPLATE_TEXTBLOCK_STYLE_BLOCK[2]); + { + elm_entry_entry_insert(edit_entry, p); + elm_entry_entry_insert(edit_entry, TEMPLATE_TEXTBLOCK_STYLE_BLOCK[4]); + } int line_inc = TEMPLATE_TEXTBLOCK_STYLE_LINE_CNT; if (!styles_block) line_inc += 2; diff --git a/src/lib/template_code.h b/src/lib/template_code.h index 1cfea21..68eca54 100644 --- a/src/lib/template_code.h +++ b/src/lib/template_code.h @@ -173,14 +173,14 @@ const char *TEMPLATE_IMG_BLOCK[TEMPLATE_IMG_BLOCK_LINE_CNT] = "}
" }; -#define TEMPLATE_TEXTBLOCK_STYLE_LINE_CNT 3 +#define TEMPLATE_TEXTBLOCK_STYLE_LINE_CNT 5 const char *TEMPLATE_TEXTBLOCK_STYLE_BLOCK[TEMPLATE_TEXTBLOCK_STYLE_LINE_CNT] = { - " styles {
", - " style { \"%s\";
" - " base: \"font=\"Sans\" font_size=30 text_class=entry color=#0088AA style=shadow,bottom shadow_color=#00000080 valign=0.5 ellipsis=1.0 wrap=none align=center\";
" - " }
", - " }
" + "styles {
", + " style { \"%s\";
", + " base: \"font=\"Sans\" font_size=30 text_class=entry color=#0088AA style=shadow,bottom shadow_color=#00000080 valign=0.5 ellipsis=1.0 wrap=none align=center\";
", + " }
", + "}
" };