aboutsummaryrefslogtreecommitdiff
path: root/src/sc_interp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sc_interp.c')
-rw-r--r--src/sc_interp.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/sc_interp.c b/src/sc_interp.c
index e3b584f..31c1f77 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -61,6 +61,10 @@ struct sc_state
int height;
float paraspace[4];
+ int have_size;
+ double slide_width;
+ double slide_height;
+
struct frame *fr; /* The current frame */
int n_macros;
@@ -601,6 +605,7 @@ SCInterpreter *sc_interp_new(PangoContext *pc, PangoLanguage *lang,
st->paraspace[2] = 0.0;
st->paraspace[3] = 0.0;
st->fontdesc = NULL;
+ st->have_size = 0;
scin->lang = lang;
@@ -633,6 +638,20 @@ 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;
@@ -676,6 +695,19 @@ static void set_paraspace(SCInterpreter *scin, const char *opts)
}
+static void set_slide_size(SCInterpreter *scin, const char *opts)
+{
+ float p[2];
+ struct sc_state *st = &scin->state[scin->j];
+
+ if ( parse_double(opts, p) ) return;
+
+ st->slide_width = p[0];
+ st->slide_height = p[1];
+ st->have_size = 1;
+}
+
+
void update_geom(struct frame *fr)
{
char geom[256];
@@ -1314,6 +1346,9 @@ void sc_interp_run_stylesheet(SCInterpreter *scin, SCBlock *bl)
} else if ( strcmp(name, "paraspace") == 0 ) {
set_paraspace(scin, options);
+ } else if ( strcmp(name, "slidesize") == 0 ) {
+ set_slide_size(scin, options);
+
}
bl = sc_block_next(bl);
@@ -1322,6 +1357,15 @@ void sc_interp_run_stylesheet(SCInterpreter *scin, SCBlock *bl)
}
+int sc_interp_get_slide_size(SCInterpreter *scin, double *w, double *h)
+{
+ if ( !scin->state->have_size ) return 1;
+ *w = scin->state->slide_width;
+ *h = scin->state->slide_height;
+ return 0;
+}
+
+
struct template_id *sc_interp_get_templates(SCInterpreter *scin, int *np)
{
struct template_id *list;