aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-03-12 19:55:39 +0100
committerThomas White <taw@physics.org>2018-03-12 19:55:39 +0100
commit8164766c66c8d9149a7741e5625aef9d9fdac854 (patch)
tree5bc07c96024509ddf91728126f79977a53c16d81 /src
parentc7a86a47001baca65c87d0f060f9a57af8537cf2 (diff)
Add rscblocks for image and callback paragraphs
Diffstat (limited to 'src')
-rw-r--r--src/frame.c14
-rw-r--r--src/frame.h4
-rw-r--r--src/sc_interp.c16
3 files changed, 24 insertions, 10 deletions
diff --git a/src/frame.c b/src/frame.c
index 7099209..9792746 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -59,6 +59,7 @@ struct _paragraph
/* For anything other than PARA_TYPE_TEXT
* (for text paragraphs, these things are in the runs) */
SCBlock *scblock;
+ SCBlock *rscblock;
/* For PARA_TYPE_IMAGE */
char *filename;
@@ -472,7 +473,7 @@ Paragraph *insert_paragraph(struct frame *fr, int pos)
}
-void add_callback_para(struct frame *fr, SCBlock *bl,
+void add_callback_para(struct frame *fr, SCBlock *bl, SCBlock *rbl,
double w, double h,
SCCallbackDrawFunc draw_func,
SCCallbackClickFunc click_func, void *bvp,
@@ -488,6 +489,7 @@ void add_callback_para(struct frame *fr, SCBlock *bl,
pnew->type = PARA_TYPE_CALLBACK;
pnew->scblock = bl;
+ pnew->rscblock = rbl;
pnew->cb_w = w;
pnew->cb_h = h;
pnew->draw_func = draw_func;
@@ -499,7 +501,8 @@ void add_callback_para(struct frame *fr, SCBlock *bl,
}
-void add_image_para(struct frame *fr, SCBlock *scblock, const char *filename,
+void add_image_para(struct frame *fr, SCBlock *scblock, SCBlock *rscblock,
+ const char *filename,
ImageStore *is, double w, double h, int editable)
{
Paragraph *pnew;
@@ -524,6 +527,7 @@ void add_image_para(struct frame *fr, SCBlock *scblock, const char *filename,
pnew->type = PARA_TYPE_IMAGE;
pnew->scblock = scblock;
+ pnew->rscblock = rscblock;
pnew->filename = strdup(filename);
pnew->image_w = w;
pnew->image_h = h;
@@ -1776,6 +1780,12 @@ SCBlock *para_scblock(Paragraph *para)
}
+SCBlock *para_rscblock(Paragraph *para)
+{
+ return para->rscblock;
+}
+
+
enum para_type para_type(Paragraph *para)
{
return para->type;
diff --git a/src/frame.h b/src/frame.h
index f3e1538..af2e9fd 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -143,13 +143,14 @@ extern void add_run(Paragraph *para, SCBlock *scblock, SCBlock *rscblock,
extern Paragraph *insert_paragraph(struct frame *fr, int pos);
extern void add_callback_para(struct frame *fr, SCBlock *scblock,
+ SCBlock *rscblock,
double w, double h,
SCCallbackDrawFunc draw_func,
SCCallbackClickFunc click_func, void *bvp,
void *vp);
extern void add_image_para(struct frame *fr, SCBlock *scblock,
- const char *filename,
+ SCBlock *rscblock, const char *filename,
ImageStore *is, double w, double h, int editable);
extern void wrap_paragraph(Paragraph *para, PangoContext *pc, double w,
@@ -204,6 +205,7 @@ extern void merge_paragraphs(struct frame *fr, int para);
extern enum para_type para_type(Paragraph *para);
extern SCBlock *para_scblock(Paragraph *para);
+extern SCBlock *para_rscblock(Paragraph *para);
extern int para_debug_num_runs(Paragraph *para);
extern int para_debug_run_info(Paragraph *para, int i, SCBlock **scblock,
diff --git a/src/sc_interp.c b/src/sc_interp.c
index 5c3cd8c..c9f3d76 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -231,15 +231,17 @@ static void do_callback(SCInterpreter *scin, SCBlock *bl, const char *name)
double w, h;
int r;
void *bvp;
- SCBlock *mr;
+ SCBlock *rbl;
- mr = sc_interp_get_macro_real_block(scin);
- if ( mr == NULL ) mr = bl;
+ rbl = bl;
+ if ( sc_interp_get_macro_real_block(scin) != NULL ) {
+ bl = sc_interp_get_macro_real_block(scin);
+ }
if ( strcmp(cbl->names[i], name) != 0 ) continue;
r = cbl->box_funcs[i](scin, bl, &w, &h, &bvp, cbl->vps[i]);
if ( !r ) return;
- add_callback_para(sc_interp_get_frame(scin), bl, w, h,
+ add_callback_para(sc_interp_get_frame(scin), bl, rbl, w, h,
cbl->draw_funcs[i], cbl->click_funcs[i],
bvp, cbl->vps[i]);
@@ -988,11 +990,11 @@ static int check_outputs(SCBlock *bl, SCInterpreter *scin)
if ( parse_image_options(options, sc_interp_get_frame(scin),
&w, &h, &filename) == 0 )
{
- SCBlock *ebl = bl;
+ SCBlock *rbl = bl;
if ( st->macro_real_block != NULL ) {
- ebl = st->macro_real_block;
+ rbl = st->macro_real_block;
}
- add_image_para(sc_interp_get_frame(scin), ebl,
+ add_image_para(sc_interp_get_frame(scin), bl, rbl,
filename, scin->is, w, h, 1);
free(filename);
} else {