aboutsummaryrefslogtreecommitdiff
path: root/src/sc_interp.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-03-12 22:35:43 +0100
committerThomas White <taw@physics.org>2018-03-12 22:35:43 +0100
commitcc5038a7a2be909dd845e0e5e635cc6f0697e98f (patch)
tree5e23038dfb91ad43185340f5a720052986b7b9ac /src/sc_interp.c
parent6f95a69666891323f594f01c9eac918665968b54 (diff)
Get rid of Paragraph->open
Diffstat (limited to 'src/sc_interp.c')
-rw-r--r--src/sc_interp.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/sc_interp.c b/src/sc_interp.c
index c9f3d76..d827326 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -695,7 +695,7 @@ static void set_paraspace(SCInterpreter *scin, const char *opts)
st->paraspace[2] = p[2];
st->paraspace[3] = p[3];
- set_para_spacing(current_para(sc_interp_get_frame(scin)), p);
+ set_para_spacing(last_para(sc_interp_get_frame(scin)), p);
}
@@ -943,6 +943,19 @@ static int in_macro(SCInterpreter *scin)
}
+static void add_newpara(struct frame *fr, SCBlock *bl)
+{
+ Paragraph *last_para;
+
+ if ( fr->paras == NULL ) return;
+ last_para = fr->paras[fr->n_paras-1];
+
+ set_newline_at_end(last_para, bl);
+
+ create_paragraph(fr);
+}
+
+
/* Add the SCBlock to the text in 'frame', at the end */
static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl,
PangoLanguage *lang, int editable, SCInterpreter *scin)
@@ -952,6 +965,7 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl,
double *col;
struct sc_state *st = &scin->state[scin->j];
SCBlock *rbl;
+ Paragraph *para;
/* Empty block? */
if ( text == NULL ) return 1;
@@ -959,13 +973,18 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl,
fontdesc = sc_interp_get_fontdesc(scin);
col = sc_interp_get_fgcol(scin);
- Paragraph *para = last_open_para(fr);
+ para = last_para(fr);
+ if ( (para == NULL) || (para_type(para) != PARA_TYPE_TEXT) ) {
+ /* Last paragraph is not text.
+ * or: no paragraphs yet.
+ * Either way: Create the first one */
+ para = create_paragraph(fr);
+ }
rbl = bl;
if ( st->macro_real_block != NULL ) {
bl = st->macro_real_block;
}
-
add_run(para, bl, rbl, fontdesc, col);
set_para_spacing(para, st->paraspace);