aboutsummaryrefslogtreecommitdiff
path: root/libstorycode
diff options
context:
space:
mode:
Diffstat (limited to 'libstorycode')
-rw-r--r--libstorycode/scparse_priv.h4
-rw-r--r--libstorycode/slide.c12
-rw-r--r--libstorycode/slide.h2
-rw-r--r--libstorycode/storycode.y51
4 files changed, 54 insertions, 15 deletions
diff --git a/libstorycode/scparse_priv.h b/libstorycode/scparse_priv.h
index 51d0d8a..54dca40 100644
--- a/libstorycode/scparse_priv.h
+++ b/libstorycode/scparse_priv.h
@@ -34,6 +34,10 @@ struct scpctx
Stylesheet *ss;
Slide *s;
+ int n_str;
+ int max_str;
+ char **str;
+
/* Frame options */
struct frame_geom geom;
};
diff --git a/libstorycode/slide.c b/libstorycode/slide.c
index 28ca159..6ff5691 100644
--- a/libstorycode/slide.c
+++ b/libstorycode/slide.c
@@ -27,12 +27,17 @@
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
#include "slide.h"
enum slide_item_type
{
SLIDE_ITEM_TEXT,
+ SLIDE_ITEM_IMAGE,
+ SLIDE_ITEM_FOOTER,
+ SLIDE_ITEM_SLIDETITLE,
+ SLIDE_ITEM_PRESTITLE,
};
@@ -82,8 +87,13 @@ int slide_add_image(Slide *s, char *filename, struct frame_geom geom)
}
-int slide_add_text(Slide *s, char *text, struct frame_geom geom)
+int slide_add_text(Slide *s, char **text, int n_text, struct frame_geom geom)
{
+ int i;
+ printf("got text:\n");
+ for ( i=0; i<n_text; i++ ) {
+ printf("%3i: '%s'\n", i, text[i]);
+ }
return 0;
}
diff --git a/libstorycode/slide.h b/libstorycode/slide.h
index 2c0607f..c9be25a 100644
--- a/libstorycode/slide.h
+++ b/libstorycode/slide.h
@@ -45,7 +45,7 @@ extern void slide_free(Slide *s);
extern int slide_add_prestitle(Slide *s, char *prestitle);
extern int slide_add_image(Slide *s, char *filename, struct frame_geom geom);
-extern int slide_add_text(Slide *s, char *text, struct frame_geom geom);
+extern int slide_add_text(Slide *s, char **text, int n_text, struct frame_geom geom);
extern int slide_add_footer(Slide *s);
extern int slide_add_slidetitle(Slide *s, char *slidetitle);
diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y
index 654dec3..433b158 100644
--- a/libstorycode/storycode.y
+++ b/libstorycode/storycode.y
@@ -44,6 +44,7 @@
%{
#include <stdio.h>
+ #include <stdlib.h>
extern int sclex();
extern int scparse();
@@ -75,10 +76,8 @@
%type <ss> stylesheet
%type <str> prestitle
%type <str> STRING
-%type <str> textframe
%type <str> imageframe
%type <str> bulletpoint
-%type <str> multi_line_string
%type <str> frameopt
%type <str> geometry /* FIXME: Should have its own type */
%type <str> slidetitle
@@ -93,12 +92,33 @@
ctx->n = narrative_new();
ctx->ss = stylesheet_new();
ctx->s = slide_new();
+
+ ctx->n_str = 0;
+ ctx->max_str = 32;
+ ctx->str = malloc(ctx->max_str*sizeof(char *));
+ if ( ctx->str == NULL ) ctx->max_str = 0;
}
%{
void frameopts_reset(struct scpctx *ctx)
{
}
+
+ void str_reset(struct scpctx *ctx)
+ {
+ ctx->n_str = 0;
+ }
+
+ void add_str(struct scpctx *ctx, char *str)
+ {
+ if ( ctx->n_str == ctx->max_str ) {
+ char **nstr = realloc(ctx->str, (ctx->max_str+32)*sizeof(char *));
+ if ( nstr == NULL ) return;
+ ctx->max_str += 32;
+ }
+
+ ctx->str[ctx->n_str++] = str;
+ }
%}
%%
@@ -148,11 +168,15 @@ slide_parts:
;
slide_part:
- prestitle { slide_add_prestitle(ctx->s, $1); }
-| imageframe { slide_add_image(ctx->s, $1, ctx->geom); frameopts_reset(ctx); }
-| textframe { slide_add_text(ctx->s, $1, ctx->geom); frameopts_reset(ctx); }
+ prestitle { slide_add_prestitle(ctx->s, $1); str_reset(ctx); }
+| imageframe { slide_add_image(ctx->s, $1, ctx->geom);
+ frameopts_reset(ctx);
+ str_reset(ctx); }
+| textframe { slide_add_text(ctx->s, ctx->str, ctx->n_str, ctx->geom);
+ frameopts_reset(ctx);
+ str_reset(ctx); }
| FOOTER { slide_add_footer(ctx->s); }
-| slidetitle { slide_add_slidetitle(ctx->s, $1); }
+| slidetitle { slide_add_slidetitle(ctx->s, $1); str_reset(ctx); }
;
imageframe:
@@ -160,14 +184,15 @@ imageframe:
;
textframe:
- TEXTFRAME frame_options multi_line_string { printf("text frame '%s'\n", $3); }
-| TEXTFRAME frame_options OPENBRACE multi_line_string CLOSEBRACE { printf("text frame m\n"); }
+ TEXTFRAME frame_options multi_line_string { }
+| TEXTFRAME frame_options OPENBRACE multi_line_string CLOSEBRACE { }
+;
multi_line_string:
- STRING { printf("string '%s'\n", $1); }
-| multi_line_string STRING { printf("more string '%s'\n", $2); }
-| bulletpoint { printf("string *%s\n", $1); }
-| multi_line_string bulletpoint { printf("more string *%s\n", $1); }
+ STRING { add_str(ctx, $1); }
+| multi_line_string STRING { add_str(ctx, $2); }
+| bulletpoint { add_str(ctx, $1); }
+| multi_line_string bulletpoint { add_str(ctx, $2); }
;
/* There can be any number of options */
@@ -178,7 +203,7 @@ frame_options:
/* Each option is enclosed in square brackets */
frame_option:
- SQOPEN frameopt SQCLOSE { printf("got an option: '%s'\n", $2); }
+ SQOPEN frameopt SQCLOSE { }
;
frameopt: