aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/frame.c14
-rw-r--r--src/frame.h12
-rw-r--r--src/sc_interp.c14
3 files changed, 25 insertions, 15 deletions
diff --git a/src/frame.c b/src/frame.c
index 2ff8f16..3c4451d 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -480,11 +480,11 @@ Paragraph *insert_paragraph(struct frame *fr, int pos)
}
-void add_callback_para(struct frame *fr, SCBlock *bl, SCBlock *rbl,
- double w, double h,
- SCCallbackDrawFunc draw_func,
- SCCallbackClickFunc click_func, void *bvp,
- void *vp)
+Paragraph *add_callback_para(struct frame *fr, SCBlock *bl, SCBlock *rbl,
+ double w, double h,
+ SCCallbackDrawFunc draw_func,
+ SCCallbackClickFunc click_func, void *bvp,
+ void *vp)
{
Paragraph *pnew;
@@ -494,7 +494,7 @@ void add_callback_para(struct frame *fr, SCBlock *bl, SCBlock *rbl,
pnew = create_paragraph(fr, bl, rbl);
if ( pnew == NULL ) {
fprintf(stderr, "Failed to add callback paragraph\n");
- return;
+ return NULL;
}
}
@@ -509,6 +509,8 @@ void add_callback_para(struct frame *fr, SCBlock *bl, SCBlock *rbl,
pnew->vp = vp;
pnew->height = h;
pnew->empty = 0;
+
+ return pnew;
}
diff --git a/src/frame.h b/src/frame.h
index dece73c..ef98e34 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -139,12 +139,12 @@ 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 Paragraph *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,
SCBlock *rscblock, const char *filename,
diff --git a/src/sc_interp.c b/src/sc_interp.c
index 2e95e8c..98a944d 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -244,9 +244,17 @@ static int check_callback(SCInterpreter *scin, SCBlock *bl)
if ( strcmp(cbl->names[i], name) != 0 ) continue;
r = cbl->box_funcs[i](scin, bl, &w, &h, &bvp, cbl->vps[i]);
if ( r ) {
- add_callback_para(sc_interp_get_frame(scin), bl, rbl, w, h,
- cbl->draw_funcs[i], cbl->click_funcs[i],
- bvp, cbl->vps[i]);
+ struct sc_state *st = &scin->state[scin->j];
+ Paragraph *pnew;
+ pnew = add_callback_para(sc_interp_get_frame(scin),
+ bl, rbl, w, h,
+ cbl->draw_funcs[i],
+ cbl->click_funcs[i],
+ bvp, cbl->vps[i]);
+ if ( pnew != NULL ) {
+ set_para_spacing(pnew, st->paraspace);
+ }
+
}
return 1;