diff options
author | Thomas White <taw@bitwiz.me.uk> | 2019-03-22 00:42:04 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2019-03-22 00:42:04 +0100 |
commit | bf89dce60e148cd7eb12c17984417a18496661da (patch) | |
tree | 92c02aa0ebc26a84c46098ed8d56931bd9cb6a5e /libstorycode/slide.c | |
parent | 891e3c9bff47bde012672aa699280400124d2447 (diff) |
Implement slide text paragraph splitting
Diffstat (limited to 'libstorycode/slide.c')
-rw-r--r-- | libstorycode/slide.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libstorycode/slide.c b/libstorycode/slide.c index 959693d..0702f52 100644 --- a/libstorycode/slide.c +++ b/libstorycode/slide.c @@ -307,3 +307,37 @@ void slide_item_get_padding(SlideItem *item, Stylesheet *ss, *t = lcalc(padding[2], frw); *b = lcalc(padding[3], frh); } + + +void slide_item_split_text_paragraph(SlideItem *item, int para, size_t off) +{ + char **np; + + np = realloc(item->paragraphs, (item->n_paras+1)*sizeof(char *)); + if ( np == NULL ) return; + +#ifdef HAVE_PANGO + PangoLayout **nl; + nl = realloc(item->layouts, (item->n_paras+1)*sizeof(PangoLayout *)); + if ( nl == NULL ) { + free(np); + return; + } + item->layouts = nl; +#endif + + item->paragraphs = np; + item->n_paras++; + + memmove(&item->paragraphs[para+1], &item->paragraphs[para], + (item->n_paras - para - 1)*sizeof(char *)); + +#ifdef HAVE_PANGO + memmove(&item->layouts[para+1], &item->layouts[para], + (item->n_paras - para - 1)*sizeof(PangoLayout *)); + item->layouts[para+1] = NULL; +#endif + + item->paragraphs[para+1] = strdup(&item->paragraphs[para][off]); + item->paragraphs[para][off] = '\0'; +} |