aboutsummaryrefslogtreecommitdiff
path: root/libstorycode/storycode.y
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-02-20 22:51:31 +0100
committerThomas White <taw@bitwiz.me.uk>2019-02-20 22:51:31 +0100
commit2244ab129bf25893cae4d68313222ef810bd0631 (patch)
treebafc8f43f481f5ae380d084cccfa4fdbc87f5bad /libstorycode/storycode.y
parent24c20239779d0ec616adde651c594c7bf08d58c7 (diff)
Add creation of most slide items
Diffstat (limited to 'libstorycode/storycode.y')
-rw-r--r--libstorycode/storycode.y89
1 files changed, 55 insertions, 34 deletions
diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y
index 433b158..576e223 100644
--- a/libstorycode/storycode.y
+++ b/libstorycode/storycode.y
@@ -40,6 +40,10 @@
Narrative *n;
Slide *s;
char *str;
+ struct length len;
+ struct frame_geom geom;
+ char character;
+ double val;
}
%{
@@ -79,46 +83,60 @@
%type <str> imageframe
%type <str> bulletpoint
%type <str> frameopt
-%type <str> geometry /* FIXME: Should have its own type */
+%type <geom> geometry
+%type <len> length
%type <str> slidetitle
+%type <character> UNIT
+%type <val> VALUE
%parse-param { struct scpctx *ctx };
%initial-action
{
- ctx->p = presentation_new();
-
- /* These are the objects currently being created. They will be
- * added to the presentation when they're complete */
- 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;
+ ctx->p = presentation_new();
+
+ /* These are the objects currently being created. They will be
+ * added to the presentation when they're complete */
+ 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;
+
+ frameopts_reset(ctx);
}
%{
- 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;
- }
+void frameopts_reset(struct scpctx *ctx)
+{
+ ctx->geom_set = 0;
+ ctx->geom.x.len = 0.0;
+ ctx->geom.y.len = 0.0;
+ ctx->geom.w.len = 1.0;
+ ctx->geom.h.len = 1.0;
+ ctx->geom.x.unit = LENGTH_FRAC;
+ ctx->geom.y.unit = LENGTH_FRAC;
+ ctx->geom.w.unit = LENGTH_FRAC;
+ ctx->geom.h.unit = LENGTH_FRAC;
+}
+
+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;
+}
%}
%%
@@ -212,7 +230,8 @@ frameopt:
;
geometry:
- length TIMES length PLUS length PLUS length { $$ = "geom"; printf("Geometry\n"); }
+ length TIMES length PLUS length PLUS length { $$.x = $1; $$.y = $3; $$.w = $5; $$.h = $7;
+ ctx->geom = $$; ctx->geom_set = 1; }
;
alignment:
@@ -226,7 +245,9 @@ slidetitle:
;
length:
- VALUE UNIT
+ VALUE UNIT { $$.len = $VALUE;
+ if ( $UNIT == 'f' ) $$.unit = LENGTH_UNIT;
+ if ( $UNIT == 'u' ) $$.unit = LENGTH_FRAC; }
;