aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libstorycode/gtk/gtkslideview.c15
-rw-r--r--libstorycode/slide.c34
-rw-r--r--libstorycode/slide.h2
3 files changed, 44 insertions, 7 deletions
diff --git a/libstorycode/gtk/gtkslideview.c b/libstorycode/gtk/gtkslideview.c
index f3d7d59..913fd56 100644
--- a/libstorycode/gtk/gtkslideview.c
+++ b/libstorycode/gtk/gtkslideview.c
@@ -970,13 +970,14 @@ static void insert_text(char *t, GtkSlideView *e)
}
if ( strcmp(t, "\n") == 0 ) {
- //split_paragraph_at_cursor(n, e->cpos);
- //rewrap_range(e, e->cpos.para, e->cpos.para+1);
- //update_size(e);
- //cursor_moveh(n, &e->cpos, +1);
- //check_cursor_visible(e);
- //emit_change_sig(e);
- //redraw(e);
+ off = pos_trail_to_offset(e->cursor_frame, e->cpos.para,
+ e->cpos.pos, e->cpos.trail);
+ slide_item_split_text_paragraph(e->cursor_frame, e->cpos.para, off);
+ e->cpos.para++;
+ e->cpos.pos = 0;
+ e->cpos.trail = 0;
+ emit_change_sig(e);
+ redraw(e);
return;
}
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';
+}
diff --git a/libstorycode/slide.h b/libstorycode/slide.h
index 6242d08..ab014d5 100644
--- a/libstorycode/slide.h
+++ b/libstorycode/slide.h
@@ -54,6 +54,8 @@ extern void slide_item_get_padding(SlideItem *item, Stylesheet *ss,
double *l, double *r, double *t, double *b,
double slide_w, double slide_h);
+extern void slide_item_split_text_paragraph(SlideItem *item, int para, size_t off);
+
/* For debugging, not really part of API */
extern void describe_slide(Slide *s);