From f170c993f12c36df69cd8c4617e87b6f14b58f36 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 2 May 2019 21:29:40 +0200 Subject: Implement "revert" button for stylesheet editor --- libstorycode/stylesheet.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libstorycode/stylesheet.c') diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c index 3bbddb3..be4db9b 100644 --- a/libstorycode/stylesheet.c +++ b/libstorycode/stylesheet.c @@ -568,3 +568,23 @@ const char *stylesheet_get_friendly_name(const char *in) if ( strcmp(in, "FOOTER") == 0 ) return "Footer"; return in; } + + +int stylesheet_set_from_storycode(Stylesheet *ss, const char *sc) +{ + Stylesheet *ssnew; + Narrative *n; + + n = storycode_parse_presentation(sc); + if ( n == NULL ) return 1; + + ssnew = narrative_get_stylesheet(n); + if ( ssnew == NULL ) return 1; + + narrative_free(n); + + free_style_contents(&ss->top); + ss->top = ssnew->top; + + return 0; +} -- cgit v1.2.3