aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/frame.c21
-rw-r--r--src/frame.h6
-rw-r--r--src/sc_editor.c2
-rw-r--r--src/sc_interp.c6
4 files changed, 26 insertions, 9 deletions
diff --git a/src/frame.c b/src/frame.c
index 5c20437..d71df4e 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -38,6 +38,7 @@
struct text_run
{
SCBlock *scblock;
+ SCBlock *macro_real_block;
size_t scblock_offs_bytes;
size_t para_offs_bytes;
size_t len_bytes;
@@ -58,7 +59,8 @@ struct _paragraph
PangoLayout *layout;
size_t offset_last;
- /* For anything other than PARA_TYPE_TEXT */
+ /* For anything other than PARA_TYPE_TEXT
+ * (for text paragraphs, these things are in the runs) */
SCBlock *scblock;
SCBlock *macro_real_scblock;
@@ -340,8 +342,9 @@ void wrap_paragraph(Paragraph *para, PangoContext *pc, double w)
}
-void add_run(Paragraph *para, SCBlock *scblock, size_t offs_bytes,
- size_t len_bytes, PangoFontDescription *fdesc, double col[4])
+void add_run(Paragraph *para, SCBlock *scblock, SCBlock *macro_real,
+ size_t offs_bytes, size_t len_bytes, PangoFontDescription *fdesc,
+ double col[4])
{
struct text_run *runs_new;
@@ -359,6 +362,7 @@ void add_run(Paragraph *para, SCBlock *scblock, size_t offs_bytes,
para->runs = runs_new;
para->runs[para->n_runs].scblock = scblock;
+ para->runs[para->n_runs].macro_real_block = macro_real;
para->runs[para->n_runs].scblock_offs_bytes = offs_bytes;
para->runs[para->n_runs].para_offs_bytes = para->offset_last;
para->offset_last += len_bytes;
@@ -798,6 +802,11 @@ void insert_text_in_paragraph(Paragraph *para, size_t offs, const char *t)
}
run = &para->runs[nrun];
+ if ( run->macro_real_block != NULL ) {
+ printf("Not inserting text into a macro block.\n");
+ return;
+ }
+
/* Translate paragraph offset for insertion into SCBlock offset */
run_offs = offs - run->para_offs_bytes;
scblock_offs = run_offs + run->scblock_offs_bytes;
@@ -837,6 +846,12 @@ void delete_text_in_paragraph(Paragraph *para, size_t offs1, size_t offs2)
struct text_run *run;
run = &para->runs[nrun];
+
+ if ( run->macro_real_block != NULL ) {
+ printf("Not deleting text from macro block\n");
+ continue;
+ }
+
ds = offs1 - run->para_offs_bytes;
de = offs2 - run->para_offs_bytes;
if ( ds < 0 ) ds = 0;
diff --git a/src/frame.h b/src/frame.h
index 7f9c920..f594d05 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -121,9 +121,9 @@ extern double paragraph_height(Paragraph *para);
extern void render_paragraph(cairo_t *cr, Paragraph *para, ImageStore *is,
enum is_size isz);
-extern void add_run(Paragraph *para, SCBlock *scblock, size_t offs_bytes,
- size_t len_bytes, PangoFontDescription *fdesc,
- double col[4]);
+extern void add_run(Paragraph *para, SCBlock *scblock, SCBlock *macro_real,
+ size_t offs_bytes, size_t len_bytes,
+ PangoFontDescription *fdesc, double col[4]);
extern void add_callback_para(struct frame *fr, SCBlock *scblock, SCBlock *mr,
double w, double h,
diff --git a/src/sc_editor.c b/src/sc_editor.c
index fd558be..1cb1761 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -938,7 +938,7 @@ static void check_paragraph(struct frame *fr, PangoContext *pc,
scblocks = sc_block_next(scblocks);
}
- add_run(para, scblocks, 0, 0, fr->fontdesc, fr->col);
+ add_run(para, scblocks, NULL, 0, 0, fr->fontdesc, fr->col);
wrap_paragraph(para, pc, fr->w - fr->pad_l - fr->pad_r);
}
diff --git a/src/sc_interp.c b/src/sc_interp.c
index 625948e..59d5e33 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -875,6 +875,7 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl,
double *col;
int just_closed = 0;
struct sc_state *st = &scin->state[scin->j];
+ SCBlock *mrb;
/* Empty block? */
if ( text == NULL ) return 1;
@@ -885,6 +886,7 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl,
fontdesc = sc_interp_get_fontdesc(scin);
col = sc_interp_get_fgcol(scin);
+ mrb = sc_interp_get_macro_real_block(scin);
len_bytes = strlen(text);
start = 0;
@@ -903,7 +905,7 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl,
if ( text[start] == '\n' ) {
if ( just_closed ) {
Paragraph *para = last_open_para(fr);
- add_run(para, bl, start, 0, fontdesc, col);
+ add_run(para, bl, mrb, start, 0, fontdesc, col);
set_para_spacing(para, st->paraspace);
}
close_last_paragraph(fr);
@@ -911,7 +913,7 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl,
just_closed = 1;
} else {
Paragraph *para = last_open_para(fr);
- add_run(para, bl, start, len, fontdesc, col);
+ add_run(para, bl, mrb, start, len, fontdesc, col);
set_para_spacing(para, st->paraspace);
start += len;
just_closed = 0;