From 4fbcf2caee32f8efa82b98a94dab4e33dc62154f Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 25 Jan 2020 21:08:58 +0100 Subject: Put the cursor in the right place after adding narrative item --- libstorycode/gtk/gtknarrativeview.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libstorycode/gtk/gtknarrativeview.c b/libstorycode/gtk/gtknarrativeview.c index b47f4a4..65d292d 100644 --- a/libstorycode/gtk/gtknarrativeview.c +++ b/libstorycode/gtk/gtknarrativeview.c @@ -1323,10 +1323,10 @@ int maybe_split_para(GtkNarrativeView *e) } -static void post_add_stuff(GtkNarrativeView *e) +static void post_add_stuff(GtkNarrativeView *e, int para) { rewrap_range(e, e->cpos.para, e->cpos.para+2); - e->cpos.para++; + e->cpos.para = para; e->cpos.pos = 0; e->cpos.trail = 0; update_size(e); @@ -1343,7 +1343,7 @@ void gtk_narrative_view_add_slide_at_cursor(GtkNarrativeView *e) if ( s == NULL ) return; insert_pos = maybe_split_para(e); narrative_insert_slide(e->n, insert_pos, s); - post_add_stuff(e); + post_add_stuff(e, insert_pos); } @@ -1372,7 +1372,7 @@ void gtk_narrative_view_add_prestitle_at_cursor(GtkNarrativeView *e) if ( runs == NULL ) return; insert_pos = maybe_split_para(e); narrative_insert_prestitle(e->n, insert_pos, runs, 1); - post_add_stuff(e); + post_add_stuff(e, insert_pos); } @@ -1383,7 +1383,7 @@ void gtk_narrative_view_add_segstart_at_cursor(GtkNarrativeView *e) if ( runs == NULL ) return; insert_pos = maybe_split_para(e); narrative_insert_segstart(e->n, insert_pos, runs, 1); - post_add_stuff(e); + post_add_stuff(e, insert_pos); } @@ -1392,7 +1392,7 @@ void gtk_narrative_view_add_segend_at_cursor(GtkNarrativeView *e) int insert_pos; insert_pos = maybe_split_para(e); narrative_insert_segend(e->n, insert_pos); - post_add_stuff(e); + post_add_stuff(e, insert_pos); } @@ -1403,7 +1403,7 @@ void gtk_narrative_view_add_bp_at_cursor(GtkNarrativeView *e) if ( runs == NULL ) return; insert_pos = maybe_split_para(e); narrative_insert_bp(e->n, insert_pos, runs, 1); - post_add_stuff(e); + post_add_stuff(e, insert_pos); } @@ -1411,7 +1411,7 @@ void gtk_narrative_view_add_eop_at_cursor(GtkNarrativeView *e) { int insert_pos = maybe_split_para(e); narrative_insert_eop(e->n, insert_pos); - post_add_stuff(e); + post_add_stuff(e, insert_pos); } -- cgit v1.2.3