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.c145
1 files changed, 105 insertions, 40 deletions
diff --git a/src/sc_interp.c b/src/sc_interp.c
index b603c61..d7f7b6b 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -1025,11 +1025,107 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl,
}
+static void apply_style(SCInterpreter *scin, Stylesheet *ss, const char *path)
+{
+ char fullpath[256];
+ size_t len;
+ char *result;
+
+ len = strlen(path);
+ if ( len > 160 ) {
+ fprintf(stderr, "Can't apply style: path too long.\n");
+ return;
+ }
+
+ /* Font */
+ strcpy(fullpath, path);
+ strcat(fullpath, ".font");
+ result = stylesheet_lookup(ss, fullpath);
+ if ( result != NULL ) set_font(scin, result);
+
+ /* Foreground colour */
+ strcpy(fullpath, path);
+ strcat(fullpath, ".fgcol");
+ result = stylesheet_lookup(ss, fullpath);
+ if ( result != NULL ) set_colour(scin, result);
+
+ /* Background (vertical gradient) */
+ strcpy(fullpath, path);
+ strcat(fullpath, ".bggradv");
+ result = stylesheet_lookup(ss, fullpath);
+ if ( result != NULL ) set_bggrad(scin, result, GRAD_VERT);
+
+ /* Background (horizontal gradient) */
+ strcpy(fullpath, path);
+ strcat(fullpath, ".bggradh");
+ result = stylesheet_lookup(ss, fullpath);
+ if ( result != NULL ) set_bggrad(scin, result, GRAD_HORIZ);
+
+ /* Background (solid colour) */
+ strcpy(fullpath, path);
+ strcat(fullpath, ".bgcol");
+ result = stylesheet_lookup(ss, fullpath);
+ if ( result != NULL ) set_bgcol(scin, result);
+
+ /* Padding */
+ strcpy(fullpath, path);
+ strcat(fullpath, ".pad");
+ result = stylesheet_lookup(ss, fullpath);
+ if ( result != NULL ) set_padding(sc_interp_get_frame(scin), result);
+
+ update_bg(scin);
+}
+
+
+static void output_frame(SCInterpreter *scin, SCBlock *bl, Stylesheet *ss,
+ const char *stylename)
+{
+ struct frame *fr;
+ SCBlock *child = sc_block_child(bl);
+ const char *options = sc_block_options(bl);
+ char fullpath[256];
+ size_t len;
+ char *result;
+
+ len = strlen(stylename);
+ if ( len > 160 ) {
+ fprintf(stderr, "Can't apply style: path too long.\n");
+ return;
+ }
+
+ fr = add_subframe(sc_interp_get_frame(scin));
+ fr->scblocks = bl;
+ fr->resizable = 1;
+ if ( fr == NULL ) {
+ fprintf(stderr, _("Failed to add frame.\n"));
+ return;
+ }
+
+ /* Lowest priority: current state of interpreter */
+ set_frame_default_style(fr, scin);
+
+ /* Next priority: geometry from stylesheet */
+ strcpy(fullpath, stylename);
+ strcat(fullpath, ".geometry");
+ result = stylesheet_lookup(ss, fullpath);
+ if ( result != NULL ) {
+ parse_frame_options(fr, sc_interp_get_frame(scin), result);
+ }
+
+ /* Highest priority: parameters to \f (or \slidetitle etc) */
+ parse_frame_options(fr, sc_interp_get_frame(scin), options);
+
+ maybe_recurse_before(scin, child);
+ set_frame(scin, fr);
+ apply_style(scin, ss, stylename);
+ maybe_recurse_after(scin, child, ss);
+}
+
+
static int check_outputs(SCBlock *bl, SCInterpreter *scin, Stylesheet *ss)
{
const char *name = sc_block_name(bl);
const char *options = sc_block_options(bl);
- SCBlock *child = sc_block_child(bl);
if ( name == NULL ) {
add_text(sc_interp_get_frame(scin),
@@ -1051,28 +1147,18 @@ static int check_outputs(SCBlock *bl, SCInterpreter *scin, Stylesheet *ss)
}
} else if ( strcmp(name, "f")==0 ) {
+ output_frame(scin, bl, ss, "$.slide.frame");
- struct frame *fr;
-
- fr = add_subframe(sc_interp_get_frame(scin));
- fr->scblocks = bl;
- fr->resizable = 1;
- if ( fr == NULL ) {
- fprintf(stderr, _("Failed to add frame.\n"));
- return 1;
- }
+ } else if ( strcmp(name, "slidetitle")==0 ) {
+ output_frame(scin, bl, ss, "$.slide.slidetitle");
- set_frame_default_style(fr, scin);
+ } else if ( strcmp(name, "prestitle")==0 ) {
+ output_frame(scin, bl, ss, "$.slide.prestitle");
- parse_frame_options(fr, sc_interp_get_frame(scin), options);
-
- maybe_recurse_before(scin, child);
- set_frame(scin, fr);
- /* FIXME: Set frame style */
- maybe_recurse_after(scin, child, ss);
+ } else if ( strcmp(name, "author")==0 ) {
+ output_frame(scin, bl, ss, "$.slide.author");
} else if ( strcmp(name, "newpara")==0 ) {
-
struct frame *fr = sc_interp_get_frame(scin);
SCBlock *rbl = bl;
add_newpara(fr, bl, rbl);
@@ -1085,27 +1171,6 @@ static int check_outputs(SCBlock *bl, SCInterpreter *scin, Stylesheet *ss)
}
-static void apply_style(SCInterpreter *scin, Stylesheet *ss, const char *path)
-{
- char fullpath[256];
- size_t len;
- char *bgcol1;
-
- len = strlen(path);
- if ( len > 160 ) {
- fprintf(stderr, "Can't apply style: path too long.\n");
- return;
- }
-
- strcpy(fullpath, path);
- strcat(fullpath, ".bggradv");
- bgcol1 = stylesheet_lookup(ss, fullpath);
- set_bggrad(scin, bgcol1, GRAD_VERT);
-
- update_bg(scin);
-}
-
-
int sc_interp_add_block(SCInterpreter *scin, SCBlock *bl, Stylesheet *ss)
{
const char *name = sc_block_name(bl);
@@ -1133,7 +1198,7 @@ int sc_interp_add_block(SCInterpreter *scin, SCBlock *bl, Stylesheet *ss)
} else if ( strcmp(name, "slide") == 0 ) {
maybe_recurse_before(scin, child);
- /* FIXME: Apply slide style */
+ apply_style(scin, ss, "$.slide");
maybe_recurse_after(scin, child, ss);
} else if ( strcmp(name, "font") == 0 ) {