diff options
author | Thomas White <taw@bitwiz.org.uk> | 2015-10-11 23:02:38 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2015-10-11 23:02:38 +0200 |
commit | a8112c90cf0fdf44ceee5b54fed77468f5c15757 (patch) | |
tree | f4ff9f9492d5685e042eaf68cf6339d5c4c05927 | |
parent | 702407e5f93ac71b686ec3ee9ff8cab022d4e446 (diff) |
Keep track of the boxes at the three levels: orig, para, wrapped
-rw-r--r-- | src/sc_editor.c | 7 | ||||
-rw-r--r-- | src/shape.c | 1 | ||||
-rw-r--r-- | src/wrap.c | 6 | ||||
-rw-r--r-- | src/wrap.h | 1 |
4 files changed, 14 insertions, 1 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c index 1b1bb04..b9a0032 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -579,6 +579,13 @@ static void insert_text(char *t, SCEditor *e) printf("sps=%i, offs_char=%i\n", sps, sbox->offs_char); sc_insert_text(sbox->scblock, sps+sbox->offs_char, t); + /* Update the length of the box in the unwrapped and un-paragraph-split + * string of wrap boxes */ + sbox->cf->cf->len_chars += 1; + + /* ... and also in the paragraph split but unwrapped box */ + sbox->cf->len_chars += 1; + fr->empty = 0; full_rerender(e); /* FIXME: No need for full */ diff --git a/src/shape.c b/src/shape.c index f483510..24848e5 100644 --- a/src/shape.c +++ b/src/shape.c @@ -94,6 +94,7 @@ static void add_wrap_box(gpointer vi, gpointer vb) box->editable = bas->editable; box->ascent = sc_interp_get_ascent(bas->scin); box->height = sc_interp_get_height(bas->scin); + box->cf = NULL; /* Link to the actual text */ tp = sc_block_contents(bas->bl); @@ -756,7 +756,10 @@ static void first_fit(struct wrap_line *boxes, double line_length, line = new_line(fr); len = boxes->boxes[j].width; } - line->boxes[line->n_boxes++] = boxes->boxes[j++]; + line->boxes[line->n_boxes] = boxes->boxes[j]; + line->boxes[line->n_boxes].cf = &boxes->boxes[j]; + line->n_boxes++; + j++; if ( (j > 0) && (boxes->boxes[j-1].type != WRAP_BOX_SENTINEL) ) { @@ -827,6 +830,7 @@ static struct wrap_line *split_paragraph(struct wrap_line *boxes, int *n, alloc_boxes(para); for ( i=start; i<end; i++ ) { para->boxes[i-start] = boxes->boxes[i]; + para->boxes[i-start].cf = &boxes->boxes[i]; } return para; } @@ -65,6 +65,7 @@ struct wrap_box SCBlock *scblock; int offs_char; /* offset (in characters, not bytes) into scblock */ + struct wrap_box *cf; /* Copied from */ /* Pango units */ int width; |