From 1f2629403b9d62ecf44420f789b5c679a8ae1c98 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 13 Jan 2020 00:06:05 +0100 Subject: Add segment start/end markers --- libstorycode/narrative.c | 34 ++++++++++++++++++++++++++++++++-- libstorycode/narrative.h | 3 ++- libstorycode/narrative_priv.h | 2 ++ libstorycode/narrative_render_cairo.c | 12 ++++++++++++ libstorycode/storycode.c | 16 ++++++++++++++++ libstorycode/storycode.l | 2 ++ libstorycode/storycode.y | 3 +++ libstorycode/stylesheet.c | 2 ++ 8 files changed, 71 insertions(+), 3 deletions(-) (limited to 'libstorycode') diff --git a/libstorycode/narrative.c b/libstorycode/narrative.c index f61e0f8..25c01c5 100644 --- a/libstorycode/narrative.c +++ b/libstorycode/narrative.c @@ -186,8 +186,15 @@ int narrative_get_unsaved(Narrative *n) int narrative_item_is_text(Narrative *n, int item) { - if ( n->items[item].type == NARRATIVE_ITEM_SLIDE ) return 0; - if ( n->items[item].type == NARRATIVE_ITEM_EOP ) return 0; + switch ( n->items[item].type ) { + case NARRATIVE_ITEM_SLIDE : return 0; + case NARRATIVE_ITEM_EOP : return 0; + case NARRATIVE_ITEM_TEXT : return 1; + case NARRATIVE_ITEM_BP : return 1; + case NARRATIVE_ITEM_PRESTITLE : return 1; + case NARRATIVE_ITEM_SEGSTART : return 1; + case NARRATIVE_ITEM_SEGEND : return 0; + } return 1; } @@ -292,6 +299,20 @@ void narrative_add_bp(Narrative *n, struct text_run *runs, int n_runs) } +void narrative_add_segstart(Narrative *n, struct text_run *runs, int n_runs) +{ + add_text_item(n, runs, n_runs, NARRATIVE_ITEM_SEGSTART); +} + + +void narrative_add_segend(Narrative *n) +{ + struct narrative_item * item = add_item(n); + if ( item == NULL ) return; + item->type = NARRATIVE_ITEM_SEGEND; +} + + void narrative_add_slide(Narrative *n, Slide *slide) { struct narrative_item *item; @@ -754,6 +775,15 @@ void narrative_debug(Narrative *n) printf("(EOP marker)\n"); break; + case NARRATIVE_ITEM_SEGSTART : + printf("(start of segment):\n"); + debug_runs(item); + break; + + case NARRATIVE_ITEM_SEGEND : + printf("(end of segment)\n"); + break; + case NARRATIVE_ITEM_SLIDE : printf("Slide:\n"); describe_slide(item->slide); diff --git a/libstorycode/narrative.h b/libstorycode/narrative.h index 599318e..54ad380 100644 --- a/libstorycode/narrative.h +++ b/libstorycode/narrative.h @@ -56,8 +56,9 @@ extern int narrative_item_is_text(Narrative *n, int item); extern void narrative_add_text(Narrative *n, struct text_run *runs, int n_runs); extern void narrative_add_bp(Narrative *n, struct text_run *runs, int n_runs); - +extern void narrative_add_segstart(Narrative *n, struct text_run *runs, int n_runs); extern void narrative_add_prestitle(Narrative *n, struct text_run *runs, int n_runs); +extern void narrative_add_segend(Narrative *n); extern void narrative_add_slide(Narrative *n, Slide *slide); extern void narrative_add_eop(Narrative *n); diff --git a/libstorycode/narrative_priv.h b/libstorycode/narrative_priv.h index fafaa59..1f2c16a 100644 --- a/libstorycode/narrative_priv.h +++ b/libstorycode/narrative_priv.h @@ -35,6 +35,8 @@ enum narrative_item_type { NARRATIVE_ITEM_TEXT, + NARRATIVE_ITEM_SEGSTART, + NARRATIVE_ITEM_SEGEND, NARRATIVE_ITEM_PRESTITLE, NARRATIVE_ITEM_SLIDE, NARRATIVE_ITEM_BP, diff --git a/libstorycode/narrative_render_cairo.c b/libstorycode/narrative_render_cairo.c index 68531c9..0a188f4 100644 --- a/libstorycode/narrative_render_cairo.c +++ b/libstorycode/narrative_render_cairo.c @@ -313,6 +313,10 @@ int narrative_wrap_range(Narrative *n, Stylesheet *stylesheet, PangoLanguage *la stn = "NARRATIVE.SLIDE"; break; + case NARRATIVE_ITEM_SEGSTART : + stn = "NARRATIVE.SEGSTART"; + break; + case NARRATIVE_ITEM_EOP : stn = "NARRATIVE.EOP"; break; @@ -334,6 +338,7 @@ int narrative_wrap_range(Narrative *n, Stylesheet *stylesheet, PangoLanguage *la case NARRATIVE_ITEM_TEXT : case NARRATIVE_ITEM_BP : case NARRATIVE_ITEM_PRESTITLE : + case NARRATIVE_ITEM_SEGSTART : wrap_text(&n->items[i], pc, stylesheet, stn, w, srt, end); break; @@ -343,6 +348,7 @@ int narrative_wrap_range(Narrative *n, Stylesheet *stylesheet, PangoLanguage *la break; case NARRATIVE_ITEM_EOP : + case NARRATIVE_ITEM_SEGEND : wrap_marker(&n->items[i], pc, w, sel_block); break; } @@ -471,6 +477,7 @@ int narrative_render_item_cairo(Narrative*n, cairo_t *cr, int i) case NARRATIVE_ITEM_TEXT : case NARRATIVE_ITEM_PRESTITLE : + case NARRATIVE_ITEM_SEGSTART : draw_text(&n->items[i], cr); break; @@ -487,6 +494,11 @@ int narrative_render_item_cairo(Narrative*n, cairo_t *cr, int i) _("End of presentation")); break; + case NARRATIVE_ITEM_SEGEND : + draw_marker(&n->items[i], cr, 0.3, 0.3, 0.3, + _("Segment end")); + break; + } return 0; diff --git a/libstorycode/storycode.c b/libstorycode/storycode.c index 89c0440..8401e9b 100644 --- a/libstorycode/storycode.c +++ b/libstorycode/storycode.c @@ -287,6 +287,15 @@ static int write_starter(GOutputStream *fh, struct narrative_item *item) if ( write_string(fh, "ENDOFPRESENTATION") ) return 1; break; + case NARRATIVE_ITEM_SEGSTART: + if ( write_string(fh, "SEGMENT_START: ") ) return 1; + break; + + case NARRATIVE_ITEM_SEGEND: + if ( write_string(fh, "SEGMENT_END") ) return 1; + break; + + } return 0; } @@ -318,6 +327,13 @@ static int write_item(GOutputStream *fh, struct narrative_item *item) case NARRATIVE_ITEM_EOP: break; + case NARRATIVE_ITEM_SEGSTART: + write_para(fh, item->runs, item->n_runs); + break; + + case NARRATIVE_ITEM_SEGEND: + break; + } return 0; } diff --git a/libstorycode/storycode.l b/libstorycode/storycode.l index 05a5a06..2e41541 100644 --- a/libstorycode/storycode.l +++ b/libstorycode/storycode.l @@ -59,6 +59,8 @@ SLIDETITLE { return SC_SLIDETITLE; } NARRATIVE { return SC_NARRATIVE; } SLIDE { return SC_SLIDE; } ENDOFPRESENTATION { return SC_EOP; } +SEGMENT_START { return SC_SEG_START; } +SEGMENT_END { return SC_SEG_END; } BP { return SC_BP; } GEOMETRY { BEGIN(cond_geom); return SC_GEOMETRY; } TEXT { return SC_TEXTFRAME; } diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y index 0e00e36..eec1abb 100644 --- a/libstorycode/storycode.y +++ b/libstorycode/storycode.y @@ -126,6 +126,7 @@ %token IMAGEFRAME %token FILENAME %token BP +%token SEG_START SEG_END %token FONT GEOMETRY PAD ALIGN FGCOL BGCOL PARASPACE %token VERT HORIZ %token LEFT CENTER RIGHT @@ -324,6 +325,8 @@ narrative: narrative_el: PRESTITLE TEXT_START text_line { narrative_add_prestitle(n, $3.runs, $3.n_runs); } | BP TEXT_START text_line { narrative_add_bp(n, $3.runs, $3.n_runs); } +| SEG_START TEXT_START text_line { narrative_add_segstart(n, $3.runs, $3.n_runs); } +| SEG_END { narrative_add_segend(n); } | TEXT_START text_line { narrative_add_text(n, $2.runs, $2.n_runs); } | slide { narrative_add_slide(n, $1); } | EOP { narrative_add_eop(n); } diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c index 66e444c..8fd09d4 100644 --- a/libstorycode/stylesheet.c +++ b/libstorycode/stylesheet.c @@ -225,6 +225,7 @@ Stylesheet *stylesheet_new() create_style(ss, "", "NARRATIVE"); create_style(ss, "NARRATIVE", "BP"); create_style(ss, "NARRATIVE", "PRESTITLE"); + create_style(ss, "NARRATIVE", "SEGSTART"); sty = create_style(ss, "", "SLIDE"); sty->geom.w.unit = LENGTH_UNIT; sty->geom.w.len = 1024.0; @@ -565,6 +566,7 @@ const char *stylesheet_get_friendly_name(const char *in) if ( strcmp(in, "BP") == 0 ) return "Bullet point"; if ( strcmp(in, "SLIDETITLE") == 0 ) return "Slide title"; if ( strcmp(in, "PRESTITLE") == 0 ) return "Presentation title"; + if ( strcmp(in, "SEGSTART") == 0 ) return "Start of segment"; if ( strcmp(in, "TEXT") == 0 ) return "Text frame"; if ( strcmp(in, "FOOTER") == 0 ) return "Footer"; return in; -- cgit v1.2.3