diff options
author | Thomas White <taw@bitwiz.me.uk> | 2020-01-05 23:45:15 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2020-01-05 23:45:15 +0100 |
commit | 9c45f71e39f0c0ded10d4c837dcaece44dcd379e (patch) | |
tree | 652e21f6f6af6ce65c10c7bf132b360014ddfba4 /libstorycode/narrative.c | |
parent | c6d6e0b4a175b39151fec94daeaf8922a7b27eac (diff) |
Cut/copy in Storycode format
Diffstat (limited to 'libstorycode/narrative.c')
-rw-r--r-- | libstorycode/narrative.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/libstorycode/narrative.c b/libstorycode/narrative.c index 5dc3f7f..c7e1e31 100644 --- a/libstorycode/narrative.c +++ b/libstorycode/narrative.c @@ -592,7 +592,49 @@ Slide *narrative_get_slide_by_number(Narrative *n, int pos) /* Return the text between item p1/offset o1 and p2/o2 */ char *narrative_range_as_storycode(Narrative *n, int p1, size_t o1, int p2, size_t o2) { - return strdup(": Text"); + GOutputStream *fh; + char *text; + int i; + + fh = g_memory_output_stream_new_resizable(); + if ( fh == NULL ) return NULL; + + for ( i=p1; i<=p2; i++ ) { + + if ( ((i>p1) && (i<p2)) || !narrative_item_is_text(n, i) ) { + + narrative_write_item(n, i, fh); + + } else { + + size_t start_offs, end_offs; + GError *error = NULL; + + if ( i==p1 ) { + start_offs = o1; + } else { + start_offs = 0; + } + + if ( i==p2 ) { + end_offs = o2; + } else { + end_offs = -1; + } + + narrative_write_partial_item(n, i, start_offs, end_offs, fh); + if ( i < p2 ) g_output_stream_write(fh, "\n", 1, NULL, &error); + + } + + } + + g_output_stream_close(fh, NULL, NULL); + text = g_memory_output_stream_steal_data(G_MEMORY_OUTPUT_STREAM(fh)); + g_object_unref(fh); + + printf("SC '%s'\n", text); + return text; } |