aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frame.c2
-rw-r--r--src/frame.h2
-rw-r--r--src/loadsave.c677
-rw-r--r--src/loadsave.h78
-rw-r--r--src/mainwindow.c22
-rw-r--r--src/notes.h2
-rw-r--r--src/presentation.c110
-rw-r--r--src/presentation.h8
-rw-r--r--src/render.c19
-rw-r--r--src/sc_interp.c40
-rw-r--r--src/sc_interp.h40
-rw-r--r--src/sc_parse.c (renamed from src/storycode.c)6
-rw-r--r--src/sc_parse.h (renamed from src/storycode.h)10
-rw-r--r--src/wrap.c2
14 files changed, 120 insertions, 898 deletions
diff --git a/src/frame.c b/src/frame.c
index 829a44d..8dbbba2 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <string.h>
-#include "storycode.h"
+#include "sc_parse.h"
#include "frame.h"
diff --git a/src/frame.h b/src/frame.h
index 2645060..f183c1b 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -92,8 +92,6 @@ struct frame
size_t pos;
struct layout_parameters lop;
- struct style *style;
- int lop_from_style; /* True if lop came from SS */
/* The rectangle allocated to this frame, determined by the renderer */
double x;
diff --git a/src/loadsave.c b/src/loadsave.c
deleted file mode 100644
index 4d65106..0000000
--- a/src/loadsave.c
+++ /dev/null
@@ -1,677 +0,0 @@
-/*
- * loadsave.c
- *
- * Copyright © 2013 Thomas White <taw@bitwiz.org.uk>
- *
- * This file is part of Colloquium.
- *
- * Colloquium is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <assert.h>
-
-#include "presentation.h"
-
-
-static int alloc_children(struct ds_node *node)
-{
- struct ds_node **new;
-
- new = realloc(node->children,
- node->max_children*sizeof(*node->children));
- if ( new == NULL ) return 1;
-
- node->children = new;
- return 0;
-}
-
-
-struct ds_node *new_ds_node(const char *key)
-{
- struct ds_node *new;
-
- new = malloc(sizeof(*new));
- if ( new == NULL ) return NULL;
-
- new->key = strdup(key);
- if ( new->key == NULL ) {
- free(new);
- return NULL;
- }
-
- new->value = NULL;
- new->n_children = 0;
- new->max_children = 32;
- new->children = NULL;
-
- if ( alloc_children(new) ) {
- free(new);
- return NULL;
- }
-
- return new;
-}
-
-
-static struct ds_node *add_child(struct ds_node *node, const char *key)
-{
- struct ds_node *new;
-
- new = new_ds_node(key);
- if ( new == NULL ) return NULL;
-
- if ( node->n_children >= new->max_children ) {
- new->max_children += 32;
- if ( alloc_children(node) ) {
- free(new);
- return NULL;
- }
- }
-
- node->children[node->n_children++] = new;
-
- return new;
-}
-
-
-void show_tree(struct ds_node *root, const char *path)
-{
- char newpath[1024];
- int i;
-
- snprintf(newpath, 1023, "%s%s/", path, root->key);
-
- printf("%s\n", newpath);
- for ( i=0; i<root->n_children; i++ ) {
- printf(" %s => %s\n", root->children[i]->key,
- root->children[i]->value);
- }
-
- for ( i=0; i<root->n_children; i++ ) {
- if ( root->children[i]->n_children > 0 ) {
- printf("\n");
- show_tree(root->children[i], newpath);
- }
- }
-}
-
-
-struct ds_node *find_node(struct ds_node *root, const char *path, int cr)
-{
- size_t start, len;
- char element[1024];
- struct ds_node *cur = root;
-
- len = strlen(path);
-
- start = 0;
- while ( start < len ) {
-
- size_t pos, i;
- int child;
- int found = 0;
-
- pos = 0;
- for ( i=start; i<len; i++ ) {
-
- if ( path[i] == '/' ) break;
- element[pos++] = path[i];
-
- }
- element[pos++] = '\0';
- if ( element[0] == '\0' ) {
- goto out;
- }
- start = i+1;
-
- for ( child=0; child<cur->n_children; child++ ) {
-
- const char *this_key = cur->children[child]->key;
-
- if ( strcmp(this_key, element) == 0 ) {
- cur = cur->children[child];
- found = 1;
- break;
- }
-
- }
-
- if ( !found ) {
-
- if ( cr ) {
- cur = add_child(cur, element);
- if ( cur == NULL ) {
- return NULL; /* Error */
- }
- } else {
- return NULL;
- }
-
- }
-
- }
-
-out:
- return cur;
-}
-
-
-static void parse_line(struct ds_node *root, struct ds_node **cn,
- const char *line)
-{
- size_t i;
- size_t len, s_start;
- size_t s_equals = 0;
- size_t s_val = 0;
- size_t s_openbracket = 0;
- size_t s_closebracket = 0;
- int h_start = 0;
- int h_equals = 0;
- int h_val = 0;
- int h_openbracket = 0;
- int h_closebracket = 0;
- struct ds_node *cur_node = *cn;
-
- len = strlen(line);
-
- s_start = len;
-
- for ( i=0; i<len; i++ ) {
- if ( !h_start && !isspace(line[i]) ) {
- s_start = i;
- h_start = 1;
- }
- if ( !h_val && h_equals && !isspace(line[i]) ) {
- s_val = i;
- h_val = 1;
- }
- if ( !h_equals && (line[i] == '=') ) {
- s_equals = i;
- h_equals = 1;
- }
- if ( !h_openbracket && (line[i] == '[') && !h_equals ) {
- s_openbracket = i;
- h_openbracket = 1;
- }
- if ( h_openbracket && !h_closebracket
- && (line[i] == ']') && !h_equals )
- {
- s_closebracket = i;
- h_closebracket = 1;
- }
- }
-
- if ( (h_openbracket && !h_closebracket)
- || (!h_openbracket && h_closebracket) )
- {
- fprintf(stderr, "Mismatched square brackets: %s\n", line);
- return;
- }
-
- if ( !h_openbracket && !h_equals ) return;
-
- if ( !h_openbracket && (!h_start || !h_val || !h_equals) ) {
- fprintf(stderr, "Incomplete assignment: %s\n", line);
- return;
- }
-
- if ( h_equals && (h_openbracket || h_closebracket) ) {
- fprintf(stderr, "Brackets and equals: %s\n", line);
- return;
- }
-
- if ( !h_openbracket ) {
-
- size_t pos = 0;
- char *key;
- char *value;
- struct ds_node *node;
-
- key = malloc(len);
- value = malloc(len);
-
- for ( i=s_start; i<s_equals; i++ ) {
- if ( !isspace(line[i]) ) key[pos++] = line[i];
- }
- key[pos] = '\0';
-
- pos = 0;
- for ( i=s_val; i<len; i++ ) {
- if ( line[i] != '\n' ) value[pos++] = line[i];
- }
- value[pos] = '\0';
-
- node = find_node(cur_node, key, 1);
- node->value = strdup(value);
-
- free(key);
- free(value);
-
- } else {
-
- size_t pos = 0;
- char *path;
-
- path = malloc(len);
-
- for ( i=s_openbracket+1; i<s_closebracket; i++ ) {
- if ( !isspace(line[i]) ) path[pos++] = line[i];
- }
- path[pos] = '\0';
- cur_node = find_node(root, path, 1);
-
- free(path);
-
- }
-
- *cn = cur_node;
-}
-
-
-static char *fgets_long(FILE *fh)
-{
- char *line;
- size_t la, l;
-
- la = 1024;
- line = malloc(la);
- if ( line == NULL ) return NULL;
-
- l = 0;
- do {
-
- int r;
-
- r = fgetc(fh);
- if ( r == EOF ) {
- free(line);
- return NULL;
- }
-
- if ( r == '\n' ) {
- line[l++] = '\0';
- return line;
- }
-
- line[l++] = r;
-
- if ( l == la ) {
-
- char *ln;
-
- la += 1024;
- ln = realloc(line, la);
- if ( ln == NULL ) {
- free(line);
- return NULL;
- }
-
- line = ln;
-
- }
-
- } while ( 1 );
-}
-
-
-int deserialize_file(FILE *fh, struct ds_node *root)
-{
- char *line;
- struct ds_node *cur_node = root;
-
- line = NULL;
- do {
-
- line = fgets_long(fh);
- if ( line == NULL ) {
- if ( ferror(fh) ) printf("Read error!\n");
- continue;
- }
-
- parse_line(root, &cur_node, line);
-
- } while ( line != NULL );
-
- return 0;
-}
-
-
-int deserialize_memory(const char *s, struct ds_node *root)
-{
- char *end;
- int done;
- struct ds_node *cur_node = root;
-
- done = 0;
- do {
-
- char *line;
-
- end = strchr(s, '\n');
- if ( end == NULL ) {
- parse_line(root, &cur_node, s);
- done = 1;
- } else {
- line = strndup(s, end-s);
- parse_line(root, &cur_node, line);
- free(line);
- s = end+1;
- }
-
- } while ( !done );
-
- return 0;
-}
-
-
-void free_ds_tree(struct ds_node *root)
-{
- int i;
-
- for ( i=0; i<root->n_children; i++ ) {
- if ( root->children[i]->n_children > 0 ) {
- free_ds_tree(root->children[i]);
- }
- }
-
- free(root->key);
- free(root->value); /* Might free(NULL), but that's fine */
- free(root);
-}
-
-
-char *escape_text(const char *a)
-{
- char *b;
- size_t l1, l, i;
-
- if ( a == NULL ) return NULL;
-
- l1 = strlen(a);
-
- b = malloc(2*l1 + 1);
- l = 0;
-
- for ( i=0; i<l1; i++ ) {
-
- char c = a[i];
-
- /* Yes, this is horribly confusing */
- if ( c == '\n' ) {
- b[l++] = '\\'; b[l++] = 'n';
- } else if ( c == '\r' ) {
- b[l++] = '\\'; b[l++] = 'r';
- } else if ( c == '\"' ) {
- b[l++] = '\\'; b[l++] = '\"';
- } else if ( c == '\t' ) {
- b[l++] = '\\'; b[l++] = 't';
- } else {
- b[l++] = c;
- }
-
- }
- b[l++] = '\0';
-
- return realloc(b, l);
-}
-
-
-char *unescape_text(const char *a)
-{
- char *b;
- size_t l1, l, i;
- int escape;
-
- if ( a == NULL ) return NULL;
-
- l1 = strlen(a);
-
- b = malloc(l1 + 1);
- l = 0;
- escape = 0;
-
- for ( i=0; i<l1; i++ ) {
-
- char c = a[i];
-
- if ( escape ) {
- if ( c == 'r' ) b[l++] = '\r';
- else if ( c == 'n' ) b[l++] = '\n';
- else if ( c == '\"' ) b[l++] = '\"';
- else if ( c == 't' ) b[l++] = '\t';
- else {
- b[l++] = '\\';
- b[l++] = c;
- }
- escape = 0;
- continue;
- }
-
- if ( c == '\\' ) {
- escape = 1;
- continue;
- }
-
- b[l++] = c;
-
- }
- b[l++] = '\0';
-
- return realloc(b, l);
-}
-
-
-
-int get_field_f(struct ds_node *root, const char *key, double *val)
-{
- struct ds_node *node;
- double v;
- char *check;
-
- node = find_node(root, key, 0);
- if ( node == NULL ) {
- fprintf(stderr, "Couldn't find field '%s'\n", key);
- return 1;
- }
-
- v = strtod(node->value, &check);
- if ( check == node->value ) {
- fprintf(stderr, "Invalid value for '%s'\n", key);
- return 1;
- }
-
- *val = v;
-
- return 0;
-}
-
-
-int get_field_i(struct ds_node *root, const char *key, int *val)
-{
- struct ds_node *node;
- int v;
- char *check;
-
- node = find_node(root, key, 0);
- if ( node == NULL ) {
- fprintf(stderr, "Couldn't find field '%s'\n", key);
- return 1;
- }
-
- v = strtol(node->value, &check, 0);
- if ( check == node->value ) {
- fprintf(stderr, "Invalid value for '%s'\n", key);
- return 1;
- }
-
- *val = v;
-
- return 0;
-}
-
-
-int get_field_s(struct ds_node *root, const char *key, char **val)
-{
- struct ds_node *node;
- char *v;
- size_t i, len, s1, s2;
- int hq;
-
- node = find_node(root, key, 0);
- if ( node == NULL ) {
- *val = NULL;
- return 1;
- }
-
- len = strlen(node->value);
- hq = 0;
- for ( i=0; i<len; i++ ) {
- if ( node->value[i] == '"' ) {
- s1 = i;
- hq = 1;
- break;
- }
- }
- if ( !hq ) {
- fprintf(stderr, "No quotes in '%s'\n", node->value);
- v = strdup(node->value); /* Use the whole thing */
- } else {
-
- for ( i=len-1; i>=0; i-- ) {
- if ( node->value[i] == '"' ) {
- s2 = i;
- break;
- }
- }
-
- if ( s1 == s2 ) {
- fprintf(stderr, "Mismatched quotes in '%s'\n",
- node->value);
- return 1;
- }
-
- v = malloc(s2-s1+1);
- if ( v == NULL ) {
- fprintf(stderr, "Failed to allocate space for '%s'\n",
- key);
- return 1;
- }
-
- strncpy(v, node->value+s1+1, s2-s1-1);
- v[s2-s1-1] = '\0';
- }
-
- *val = unescape_text(v);
- free(v);
-
- return 0;
-}
-
-
-static void rebuild_prefix(struct serializer *ser)
-{
- int i;
- size_t sz = 1; /* Space for terminator */
-
- for ( i=0; i<ser->stack_depth; i++ ) {
- sz += strlen(ser->stack[i]) + 1;
- }
-
- free(ser->prefix);
- ser->prefix = malloc(sz);
- if ( ser->prefix == NULL ) return; /* Probably bad! */
-
- ser->prefix[0] = '\0';
- for ( i=0; i<ser->stack_depth; i++ ) {
- if ( i != 0 ) strcat(ser->prefix, "/");
- strcat(ser->prefix, ser->stack[i]);
- }
-}
-
-
-void serialize_start(struct serializer *ser, const char *id)
-{
- ser->stack[ser->stack_depth++] = strdup(id);
- rebuild_prefix(ser);
- ser->empty_set = 1;
-}
-
-
-static void check_prefix_output(struct serializer *ser)
-{
- if ( ser->empty_set ) {
- ser->empty_set = 0;
- if ( ser->prefix != NULL ) {
- fprintf(ser->fh, "\n");
- fprintf(ser->fh, "[%s]\n", ser->prefix);
- }
- }
-}
-
-
-void serialize_s(struct serializer *ser, const char *key, const char *val)
-{
- char *n;
-
- n = escape_text(val);
- if ( n == NULL ) {
- fprintf(stderr, "Failed to escape '%s'\n", val);
- return;
- }
-
- check_prefix_output(ser);
- fprintf(ser->fh, "%s = \"%s\"\n", key, n);
-
- free(n);
-}
-
-
-void serialize_f(struct serializer *ser, const char *key, double val)
-{
- check_prefix_output(ser);
- fprintf(ser->fh, "%s = %.2f\n", key, val);
-}
-
-
-void serialize_b(struct serializer *ser, const char *key, int val)
-{
- check_prefix_output(ser);
- fprintf(ser->fh, "%s = %i\n", key, val);
-}
-
-
-void serialize_i(struct serializer *ser, const char *key, int val)
-{
- check_prefix_output(ser);
- fprintf(ser->fh, "%s = %i\n", key, val);
-}
-
-
-void serialize_end(struct serializer *ser)
-{
- free(ser->stack[--ser->stack_depth]);
- rebuild_prefix(ser);
- ser->empty_set = 1;
-}
-
diff --git a/src/loadsave.h b/src/loadsave.h
deleted file mode 100644
index 892ee45..0000000
--- a/src/loadsave.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * loadsave.h
- *
- * Copyright © 2013 Thomas White <taw@bitwiz.org.uk>
- *
- * This file is part of Colloquium.
- *
- * Colloquium is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef LOADSAVE_H
-#define LOADSAVE_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/* Forward declaration */
-struct presentation;
-
-struct ds_node
-{
- char *key;
- char *value;
- struct ds_node **children;
- int n_children;
- int max_children;
-};
-
-/* Would be opaque if I could be bothered to write the constructor */
-struct serializer
-{
- FILE *fh;
-
- char *stack[32];
- int stack_depth;
- char *prefix;
- int empty_set;
- int blank_written;
-};
-
-extern struct ds_node *new_ds_node(const char *key);
-extern void free_ds_tree(struct ds_node *root);
-extern int deserialize_file(FILE *fh, struct ds_node *root);
-extern int deserialize_memory(const char *s, struct ds_node *root);
-
-extern void show_tree(struct ds_node *root, const char *path);
-
-extern char *escape_text(const char *a);
-extern char *unescape_text(const char *a);
-
-extern void serialize_start(struct serializer *s, const char *id);
-extern void serialize_s(struct serializer *s, const char *key, const char *val);
-extern void serialize_f(struct serializer *s, const char *key, double val);
-extern void serialize_b(struct serializer *s, const char *key, int val);
-extern void serialize_i(struct serializer *s, const char *key, int val);
-extern void serialize_end(struct serializer *s);
-
-extern int get_field_f(struct ds_node *root, const char *key, double *val);
-extern int get_field_i(struct ds_node *root, const char *key, int *val);
-extern int get_field_s(struct ds_node *root, const char *key, char **val);
-
-extern struct ds_node *find_node(struct ds_node *root, const char *path,
- int cr);
-
-#endif /* LOADSAVE_H */
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 322f2c4..aa74d4c 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -182,6 +182,7 @@ static void do_slide_update(struct presentation *p, PangoContext *pc)
}
+#if 0
static void add_furniture_real(struct presentation *p, struct style *sty)
{
struct frame *fr;
@@ -199,10 +200,14 @@ static void add_furniture_real(struct presentation *p, struct style *sty)
p->cursor_pos = 0;
}
+#endif
static gint add_furniture(GtkWidget *widget, struct menu_pl *pl)
{
+#if 0
+/* FIXME: Add furniture */
+
struct style *sty = pl->sty;
struct presentation *p = pl->p;
@@ -220,6 +225,7 @@ static gint add_furniture(GtkWidget *widget, struct menu_pl *pl)
p->cur_edit_slide->top->style = pl->st->top_style;
do_slide_update(p, p->pc);
+#endif
return 0;
}
@@ -227,6 +233,8 @@ static gint add_furniture(GtkWidget *widget, struct menu_pl *pl)
static void update_style_menus(struct presentation *p)
{
+#if 0
+/* FIXME: Menus */
GtkWidget *menu;
struct slide_template *t;
TemplateIterator *iter;
@@ -305,8 +313,8 @@ static void update_style_menus(struct presentation *p)
}
gtk_widget_show_all(menu);
-
p->n_menu_rebuild = j;
+#endif
}
@@ -382,7 +390,8 @@ static gint loadstyle_response_sig(GtkWidget *d, gint response,
char *filename;
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(d));
- replace_stylesheet(p, filename);
+ /* FIXME: Implement this (now easy) */
+ //replace_stylesheet(p, filename);
g_free(filename);
update_style_menus(p);
rerender_slide(p);
@@ -496,9 +505,10 @@ static gint save_ss_response_sig(GtkWidget *d, gint response,
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(d));
- if ( save_stylesheet(p->ss, filename) ) {
- show_error(p, "Failed to save style sheet");
- }
+ /* FIXME: Implement this */
+// if ( save_stylesheet(p->ss, filename) ) {
+// show_error(p, "Failed to save style sheet");
+// }
g_free(filename);
@@ -1477,8 +1487,6 @@ static struct frame *create_frame(struct presentation *p, double x, double y,
fr = add_subframe(parent);
fr->sc = NULL;
- fr->style = default_style(p->ss);
- fr->lop_from_style = 0;
fr->lop.x = x;
fr->lop.y = y;
fr->lop.w = w;
diff --git a/src/notes.h b/src/notes.h
index 32b6bbe..62c3c2e 100644
--- a/src/notes.h
+++ b/src/notes.h
@@ -1,7 +1,7 @@
/*
* notes.h
*
- * Copyright © 2013 Thomas White <taw@bitwiz.org.uk>
+ * Copyright © 2013-2014 Thomas White <taw@bitwiz.org.uk>
*
* This file is part of Colloquium.
*
diff --git a/src/presentation.c b/src/presentation.c
index d573257..a1b7a19 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -1,7 +1,7 @@
/*
* presentation.c
*
- * Copyright © 2013 Thomas White <taw@bitwiz.org.uk>
+ * Copyright © 2013-2014 Thomas White <taw@bitwiz.org.uk>
*
* This file is part of Colloquium.
*
@@ -31,7 +31,6 @@
#include <gtk/gtk.h>
#include "presentation.h"
-#include "loadsave.h"
#include "mainwindow.h"
#include "frame.h"
#include "imagestore.h"
@@ -296,7 +295,7 @@ struct presentation *new_presentation()
new->completely_empty = 1;
- new->ss = default_stylesheet();
+ new->ss = strdup("");
new->n_menu_rebuild = 0;
new->menu_rebuild_list = NULL;
@@ -323,70 +322,6 @@ static char *maybe_star(int i)
}
-static char *frame_options_string(struct frame *fr, StyleSheet *ss)
-{
- char *opt;
-
- opt = malloc(64);
- if ( opt == NULL ) return NULL;
-
- snprintf(opt, 31, "style=%s%s",
- fr->style->pname, maybe_star(fr->lop_from_style));
-
- if ( !fr->lop_from_style ) {
- char tmp[32];
- snprintf(tmp, 31, ",%.1f%sx%.1f%s+%.1f+%.1f",
- fr->lop.w, units(fr->lop.w_units),
- fr->lop.h, units(fr->lop.h_units),
- fr->lop.x, fr->lop.y);
- strcat(opt, tmp);
- }
-
- return opt;
-}
-
-
-char *packed_sc(struct frame *fr, StyleSheet *ss)
-{
- char *sc;
- int i;
- size_t len = 0;
-
- if ( fr->sc != NULL ) {
- len += strlen(fr->sc)+1;
- sc = malloc(len);
- memcpy(sc, fr->sc, len);
- } else {
- len = 0;
- sc = malloc(1);
- sc[0] = '\0';
- }
-
- for ( i=0; i<fr->num_children; i++ ) {
-
- char *ch_sc;
- char *scn;
- size_t ch_len;
- char *frame_opts;
-
- ch_sc = packed_sc(fr->children[i], ss);
- ch_len = strlen(ch_sc);
-
- frame_opts = frame_options_string(fr->children[i], ss);
-
- len += ch_len + 64;
- scn = malloc(len + ch_len);
- snprintf(scn, len, "%s\\f[%s]{%s}", sc, frame_opts, ch_sc);
- free(ch_sc);
- free(sc);
- sc = scn;
-
- }
-
- return sc;
-}
-
-
int save_presentation(struct presentation *p, const char *filename)
{
FILE *fh;
@@ -399,45 +334,8 @@ int save_presentation(struct presentation *p, const char *filename)
fh = fopen(filename, "w");
if ( fh == NULL ) return 1;
- /* Set up the serializer */
- ser.fh = fh;
- ser.stack_depth = 0;
- ser.prefix = NULL;
-
- fprintf(fh, "# Colloquium presentation file\n");
- serialize_f(&ser, "version", 0.1);
-
- serialize_start(&ser, "slide-properties");
- serialize_f(&ser, "width", p->slide_width);
- serialize_f(&ser, "height", p->slide_height);
- serialize_end(&ser);
-
- serialize_start(&ser, "stylesheet");
- write_stylesheet(p->ss, &ser);
- serialize_end(&ser);
-
- serialize_start(&ser, "slides");
- for ( i=0; i<p->num_slides; i++ ) {
-
- struct slide *s;
- char s_id[32];
- char *sc;
-
- s = p->slides[i];
-
- snprintf(s_id, 31, "%i", i);
- serialize_start(&ser, s_id);
-
- sc = packed_sc(s->top, p->ss);
- serialize_s(&ser, "sc", sc);
- free(sc);
-
- write_notes(s, &ser);
-
- serialize_end(&ser);
-
- }
- serialize_end(&ser);
+ fprintf(fh, "%s", p->ss);
+ fprintf(fh, "%s", p->sc);
/* Slightly fiddly because someone might
* do save_presentation(p, p->filename) */
diff --git a/src/presentation.h b/src/presentation.h
index 3d344eb..9b69993 100644
--- a/src/presentation.h
+++ b/src/presentation.h
@@ -61,7 +61,7 @@ struct slide
/* This should always be present (and up to date). */
cairo_surface_t *rendered_thumb;
- struct frame *top;
+ struct frame *top;
char *notes;
};
@@ -183,9 +183,11 @@ struct presentation
int ss_blank;
char ss_geom[256];
- StyleSheet *ss;
unsigned int num_slides;
struct slide **slides;
+
+ char *ss;
+ char *sc;
struct inhibit_sys *inhibit;
};
@@ -204,7 +206,7 @@ extern void delete_subframe(struct slide *s, struct frame *fr);
extern void get_titlebar_string(struct presentation *p);
-extern char *packed_sc(struct frame *fr, StyleSheet *ss);
+extern char *packed_sc(struct frame *fr);
extern int slide_number(struct presentation *p, struct slide *s);
diff --git a/src/render.c b/src/render.c
index 813344d..6ea1afa 100644
--- a/src/render.c
+++ b/src/render.c
@@ -35,7 +35,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
-#include "storycode.h"
+#include "sc_parse.h"
#include "presentation.h"
#include "frame.h"
#include "render.h"
@@ -277,16 +277,6 @@ static void run_render_sc(cairo_t *cr, struct frame *fr, const char *sc)
}
-
-static void do_background(cairo_t *cr, struct frame *fr)
-{
- if ( fr->style != NULL ) {
- run_render_sc(cr, fr, fr->style->sc_prologue);
- }
- run_render_sc(cr, fr, fr->sc);
-}
-
-
/* Render Level 1 Storycode (no subframes) */
static int render_sc(cairo_t *cr, struct frame *fr, ImageStore *is,
enum is_size isz, struct slide_constants *scc,
@@ -332,12 +322,13 @@ static int render_frame(cairo_t *cr, struct frame *fr, ImageStore *is,
{
int i;
- do_background(cr, fr);
-
/* Render all subframes */
for ( i=0; i<fr->num_children; i++ ) {
struct frame *ch = fr->children[i];
+#if 0
+/* Frame geometry calculation */
+
double mtot;
if ( ch->style != NULL ) {
@@ -385,7 +376,7 @@ static int render_frame(cairo_t *cr, struct frame *fr, ImageStore *is,
break;
}
-
+#endif
ch->x = ch->lop.x + fr->lop.pad_l + ch->lop.margin_l;
ch->y = ch->lop.y + fr->lop.pad_t + ch->lop.margin_t;
cairo_save(cr);
diff --git a/src/sc_interp.c b/src/sc_interp.c
new file mode 100644
index 0000000..28182a9
--- /dev/null
+++ b/src/sc_interp.c
@@ -0,0 +1,40 @@
+/*
+ * sc_interp.c
+ *
+ * Copyright © 2014 Thomas White <taw@bitwiz.org.uk>
+ *
+ * This file is part of Colloquium.
+ *
+ * Colloquium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "sc_parse.h"
+#include "sc_interp.h"
+
+struct _scinterp
+{
+ int dummy;
+};
+
+f \ No newline at end of file
diff --git a/src/sc_interp.h b/src/sc_interp.h
new file mode 100644
index 0000000..b5fba5e
--- /dev/null
+++ b/src/sc_interp.h
@@ -0,0 +1,40 @@
+/*
+ * sc_interp.h
+ *
+ * Copyright © 2014 Thomas White <taw@bitwiz.org.uk>
+ *
+ * This file is part of Colloquium.
+ *
+ * Colloquium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef SC_INTERP_H
+#define SC_INTERP_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+typedef struct _scinterp SCInterpreter;
+
+extern SCInterpreter *sc_interp_new(void);
+extern void sc_interp_destroy(SCInterpreter *scin);
+
+extern void sc_interp_save(SCInterpreter *scin);
+extern void sc_interp_restore(SCInterpreter *scin);
+
+extern void sc_interp_run(SCInterpreter *scin, const char *sc);
+
+#endif /* SC_INTERP_H */
diff --git a/src/storycode.c b/src/sc_parse.c
index 9e58092..e4cb94c 100644
--- a/src/storycode.c
+++ b/src/sc_parse.c
@@ -1,7 +1,7 @@
/*
- * storycode.c
+ * sc_parse.c
*
- * Copyright © 2013 Thomas White <taw@bitwiz.org.uk>
+ * Copyright © 2013-2014 Thomas White <taw@bitwiz.org.uk>
*
* This file is part of Colloquium.
*
@@ -31,7 +31,7 @@
#include <stdio.h>
#include <ctype.h>
-#include "storycode.h"
+#include "sc_parse.h"
struct _scblocklist
diff --git a/src/storycode.h b/src/sc_parse.h
index 2119a25..d7d8df3 100644
--- a/src/storycode.h
+++ b/src/sc_parse.h
@@ -1,7 +1,7 @@
/*
- * storycode.h
+ * sc_parse.h
*
- * Copyright © 2013 Thomas White <taw@bitwiz.org.uk>
+ * Copyright © 2013-2014 Thomas White <taw@bitwiz.org.uk>
*
* This file is part of Colloquium.
*
@@ -20,8 +20,8 @@
*
*/
-#ifndef STORYCODE_H
-#define STORYCODE_H
+#ifndef SC_PARSE_H
+#define SC_PARSE_H
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -48,4 +48,4 @@ extern void sc_block_list_free(SCBlockList *bl);
extern char *remove_blocks(const char *in, const char *blockname);
-#endif /* STORYCODE_H */
+#endif /* SC_PARSE_H */
diff --git a/src/wrap.c b/src/wrap.c
index 5dde838..b77769a 100644
--- a/src/wrap.c
+++ b/src/wrap.c
@@ -34,7 +34,7 @@
#include <math.h>
#include <gdk/gdk.h>
-#include "storycode.h"
+#include "sc_parse.h"
#include "wrap.h"
#include "frame.h"
#include "presentation.h"