diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/presentation.c | 11 | ||||
-rw-r--r-- | src/sc_interp.c | 28 | ||||
-rw-r--r-- | src/utils.c | 28 | ||||
-rw-r--r-- | src/utils.h | 2 |
4 files changed, 40 insertions, 29 deletions
diff --git a/src/presentation.c b/src/presentation.c index c3f0d07..1aa126a 100644 --- a/src/presentation.c +++ b/src/presentation.c @@ -228,7 +228,16 @@ SCBlock *prev_slide(struct presentation *p, SCBlock *sl) static void set_slide_size_from_stylesheet(struct presentation *p) { - /* FIXME: From JSON */ + char *result; + + result = stylesheet_lookup(p->stylesheet, "$.slide.size"); + if ( result != NULL ) { + float v[2]; + if ( parse_double(result, v) == 0 ) { + p->slide_width = v[0]; + p->slide_height = v[1]; + } + } } diff --git a/src/sc_interp.c b/src/sc_interp.c index d7f7b6b..0b39d00 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -679,34 +679,6 @@ void sc_interp_destroy(SCInterpreter *scin) } -static int parse_double(const char *a, float v[2]) -{ - int nn; - - nn = sscanf(a, "%fx%f", &v[0], &v[1]); - if ( nn != 2 ) { - fprintf(stderr, _("Invalid size '%s'\n"), a); - return 1; - } - - return 0; -} - - -static int parse_tuple(const char *a, float v[4]) -{ - int nn; - - nn = sscanf(a, "%f,%f,%f,%f", &v[0], &v[1], &v[2], &v[3]); - if ( nn != 4 ) { - fprintf(stderr, _("Invalid tuple '%s'\n"), a); - return 1; - } - - return 0; -} - - static void set_padding(struct frame *fr, const char *opts) { float p[4]; diff --git a/src/utils.c b/src/utils.c index 9033466..bafbb99 100644 --- a/src/utils.c +++ b/src/utils.c @@ -109,6 +109,34 @@ static char *fgets_long(FILE *fh, size_t *lp) } +int parse_double(const char *a, float v[2]) +{ + int nn; + + nn = sscanf(a, "%fx%f", &v[0], &v[1]); + if ( nn != 2 ) { + fprintf(stderr, _("Invalid size '%s'\n"), a); + return 1; + } + + return 0; +} + + +int parse_tuple(const char *a, float v[4]) +{ + int nn; + + nn = sscanf(a, "%f,%f,%f,%f", &v[0], &v[1], &v[2], &v[3]); + if ( nn != 4 ) { + fprintf(stderr, _("Invalid tuple '%s'\n"), a); + return 1; + } + + return 0; +} + + char *load_everything(const char *filename) { FILE *fh; diff --git a/src/utils.h b/src/utils.h index bfc04c2..8870a98 100644 --- a/src/utils.h +++ b/src/utils.h @@ -30,6 +30,8 @@ extern void chomp(char *s); extern int safe_strcmp(const char *a, const char *b); +extern int parse_double(const char *a, float v[2]); +extern int parse_tuple(const char *a, float v[4]); extern char *load_everything(const char *filename); #include <libintl.h> |