From 889bff2106db15c5bb7100e7fdd6f14ad6ae2bd5 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 18 Feb 2018 19:48:22 +0100 Subject: Remove text run SCBlock offset The \newpara change (commit 7f2d0abd) removed the only situation when the start of a run might not coincide with the start of an SCBlock, or vice-versa (although not all SCBlocks correspond to text runs, obviously). Therefore, the offset is always zero and can be removed, simplifying the code. --- src/sc_interp.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/sc_interp.c') diff --git a/src/sc_interp.c b/src/sc_interp.c index efdffa6..24dd4ee 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -946,7 +946,7 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl, PangoLanguage *lang, int editable, SCInterpreter *scin) { const char *text = sc_block_contents(bl); - size_t start, len_bytes; + size_t len_bytes; PangoFontDescription *fontdesc; double *col; struct sc_state *st = &scin->state[scin->j]; @@ -961,18 +961,10 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl, mrb = sc_interp_get_macro_real_block(scin); len_bytes = strlen(text); - start = 0; - do { - - size_t len = strlen(text+start); - - Paragraph *para = last_open_para(fr); - add_run(para, bl, mrb, st->macro_contents, start, len, - fontdesc, col, st->macro_editable); - set_para_spacing(para, st->paraspace); - start += len; - - } while ( start < len_bytes ); + Paragraph *para = last_open_para(fr); + add_run(para, bl, mrb, st->macro_contents, len_bytes, + fontdesc, col, st->macro_editable); + set_para_spacing(para, st->paraspace); return 0; } @@ -1032,7 +1024,7 @@ static int check_outputs(SCBlock *bl, SCInterpreter *scin) Paragraph *para = last_open_para(fr); struct sc_state *st = &scin->state[scin->j]; /* Add a dummy run which we can type into */ - add_run(para, bl, st->macro_real_block, st->macro_contents, 0, 0, + add_run(para, bl, st->macro_real_block, st->macro_contents, 0, sc_interp_get_fontdesc(scin), fr->col, st->macro_editable); set_newline_at_end(para, bl); close_last_paragraph(fr); -- cgit v1.2.3