aboutsummaryrefslogtreecommitdiff
path: root/libstorycode/storycode.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-04-04 23:42:25 +0200
committerThomas White <taw@bitwiz.me.uk>2019-04-04 23:42:25 +0200
commitefd1f6fe44b8b2326b1ae7f836179c59e16b9ada (patch)
tree7d5081fd54006beb54692f25a5b115e057e7609b /libstorycode/storycode.c
parentbe908ee410e6b188f05a6181eab74a28dfd8fc9e (diff)
Write narrative
Diffstat (limited to 'libstorycode/storycode.c')
-rw-r--r--libstorycode/storycode.c62
1 files changed, 52 insertions, 10 deletions
diff --git a/libstorycode/storycode.c b/libstorycode/storycode.c
index 7fe46d7..f9094f7 100644
--- a/libstorycode/storycode.c
+++ b/libstorycode/storycode.c
@@ -66,6 +66,54 @@ static int write_string(GOutputStream *fh, char *str)
}
+static int write_slide(GOutputStream *fh, Slide *s)
+{
+ int i;
+
+ for ( i=0; i<s->n_items; i++ ) {
+ }
+
+ return 0;
+}
+
+
+static int write_item(GOutputStream *fh, struct narrative_item *item)
+{
+ switch ( item->type ) {
+
+ case NARRATIVE_ITEM_TEXT:
+ /* FIXME: separate alignment */
+ if ( write_string(fh, ": ") ) return 1;
+ if ( write_string(fh, item->text) ) return 1;
+ if ( write_string(fh, "\n") ) return 1;
+ break;
+
+ case NARRATIVE_ITEM_PRESTITLE:
+ /* FIXME: separate alignment */
+ if ( write_string(fh, "PRESTITLE: ") ) return 1;
+ if ( write_string(fh, item->text) ) return 1;
+ if ( write_string(fh, "\n") ) return 1;
+ break;
+
+ case NARRATIVE_ITEM_BP:
+ /* FIXME: separate alignment */
+ if ( write_string(fh, "BP: ") ) return 1;
+ if ( write_string(fh, item->text) ) return 1;
+ if ( write_string(fh, "\n") ) return 1;
+ break;
+
+ case NARRATIVE_ITEM_SLIDE:
+ /* FIXME: separate slide size */
+ if ( write_string(fh, "SLIDE {\n") ) return 1;
+ if ( write_slide(fh, item->slide) ) return 1;
+ if ( write_string(fh, "}\n") ) return 1;
+ break;
+
+ }
+ return 0;
+}
+
+
int storycode_write_presentation(Narrative *n, GOutputStream *fh)
{
int i;
@@ -76,17 +124,11 @@ int storycode_write_presentation(Narrative *n, GOutputStream *fh)
if ( ss_text == NULL ) return 1;
if ( write_string(fh, ss_text) ) return 1;
- for ( i=0; i<n->n_items; i++ ) {
-
- gssize r;
- GError *error = NULL;
- char *a = "Hello";
+ if ( write_string(fh, "\n") ) return 1;
- r = g_output_stream_write(fh, a, strlen(a), NULL, &error);
- if ( r == -1 ) {
- fprintf(stderr, "Write failed: %s\n", error->message);
- return 1;
- }
+ for ( i=0; i<n->n_items; i++ ) {
+ if ( write_item(fh, &n->items[i]) ) return 1;
}
+
return 0;
}