diff options
author | Thomas White <taw@bitwiz.org.uk> | 2014-01-18 21:06:36 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2014-01-18 21:06:36 +0100 |
commit | f72616c114b82b710b3be0faa56fa4ae3f45f188 (patch) | |
tree | 4e85b484a02fb29746d5210982f230d7c690858b /src | |
parent | 93956372d317fc90f8751e6b319e0055507c2519 (diff) |
Restore images and slide number
Diffstat (limited to 'src')
-rw-r--r-- | src/sc_interp.c | 60 | ||||
-rw-r--r-- | src/shape.c | 6 | ||||
-rw-r--r-- | src/shape.h | 3 | ||||
-rw-r--r-- | src/wrap.c | 36 |
4 files changed, 54 insertions, 51 deletions
diff --git a/src/sc_interp.c b/src/sc_interp.c index 5e1be23..7f46982 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -388,6 +388,44 @@ static void parse_frame_options(struct frame *fr, struct frame *parent, } +static int get_size(const char *a, struct frame *fr, int *wp, int *hp) +{ + char *x; + char *ws; + char *hs; + + if ( a == NULL ) goto invalid; + + x = index(a, 'x'); + if ( x == NULL ) goto invalid; + + if ( rindex(a, 'x') != x ) goto invalid; + + ws = strndup(a, x-a); + hs = strdup(x+1); + + if ( strcmp(ws, "fit") == 0 ) { + *wp = fr->w - (fr->pad_l+fr->pad_r); + } else { + *wp = strtoul(ws, NULL, 10); + } + if ( strcmp(ws, "fit") == 0 ) { + *hp = fr->h - (fr->pad_t+fr->pad_b); + } else { + *hp = strtoul(hs, NULL, 10); + } + + free(ws); + free(hs); + + return 0; + +invalid: + fprintf(stderr, "Invalid dimensions '%s'\n", a); + return 1; +} + + int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) { while ( bl != NULL ) { @@ -414,25 +452,25 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) } else if ( strcmp(name, "bgcol") == 0 ) { set_frame_bgcolour(sc_interp_get_frame(scin), options); -#if 0 } else if ( strcmp(name, "image")==0 ) { int w, h; - if ( get_size(options, fr, &w, &h) == 0 ) { - add_image_box(boxes, b->contents, offset, w, h, - editable); + if ( get_size(options, sc_interp_get_frame(scin), + &w, &h) == 0 ) + { + add_image_box(sc_interp_get_frame(scin)->boxes, + sc_block_contents(child), + w, h, 1); + child = NULL; /* Don't recurse */ } } else if ( strcmp(name, "slidenumber")==0) { char *tmp = malloc(64); if ( tmp != NULL ) { snprintf(tmp, 63, "%i", - slide_constants->slide_number); - add_wrap_box(boxes, tmp, offset, - WRAP_SPACE_NONE, pc, - &fonts->stack[fonts->n_fonts-1], - 0); - } /* else go away and sulk about it */ -#endif + scin->s_constants->slide_number); + split_words(sc_interp_get_frame(scin)->boxes, + scin->pc, tmp, scin->lang, 0, scin); + } } else if ( strcmp(name, "f")==0 ) { diff --git a/src/shape.c b/src/shape.c index a3f2292..e54de09 100644 --- a/src/shape.c +++ b/src/shape.c @@ -112,14 +112,12 @@ static int add_wrap_box(struct wrap_line *line, char *text, size_t offset, } -static void add_image_box(struct wrap_line *line, const char *filename, - size_t offset, int w, int h, int editable) +void add_image_box(struct wrap_line *line, const char *filename, + int w, int h, int editable) { struct wrap_box *box; box = &line->boxes[line->n_boxes]; - if ( !editable ) offset = 0; - box->sc_offset = offset; box->type = WRAP_BOX_IMAGE; box->text = NULL; box->space = WRAP_SPACE_NONE; diff --git a/src/shape.h b/src/shape.h index 77d9c3f..bdc5775 100644 --- a/src/shape.h +++ b/src/shape.h @@ -35,4 +35,7 @@ extern int split_words(struct wrap_line *boxes, PangoContext *pc, const char *text, PangoLanguage *lang, int editable, SCInterpreter *scin); +extern void add_image_box(struct wrap_line *line, const char *filename, + int w, int h, int editable); + #endif /* SHAPE_H */ @@ -289,42 +289,6 @@ static void calc_line_geometry(struct wrap_line *line) } -static int get_size(const char *a, struct frame *fr, int *wp, int *hp) -{ - char *x; - char *ws; - char *hs; - - x = index(a, 'x'); - if ( x == NULL ) goto invalid; - - if ( rindex(a, 'x') != x ) goto invalid; - - ws = strndup(a, x-a); - hs = strdup(x+1); - - if ( strcmp(ws, "fit") == 0 ) { - *wp = fr->w - (fr->pad_l+fr->pad_r); - } else { - *wp = strtoul(ws, NULL, 10); - } - if ( strcmp(ws, "fit") == 0 ) { - *hp = fr->h - (fr->pad_t+fr->pad_b); - } else { - *hp = strtoul(hs, NULL, 10); - } - - free(ws); - free(hs); - - return 0; - -invalid: - fprintf(stderr, "Invalid dimensions '%s'\n", a); - return 1; -} - - /* Normal width of space */ static double sp_x(enum wrap_box_space s) { |