diff options
Diffstat (limited to 'libstorycode/narrative_render_cairo.c')
-rw-r--r-- | libstorycode/narrative_render_cairo.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/libstorycode/narrative_render_cairo.c b/libstorycode/narrative_render_cairo.c index 17f22aa..b001132 100644 --- a/libstorycode/narrative_render_cairo.c +++ b/libstorycode/narrative_render_cairo.c @@ -146,7 +146,7 @@ int index_with_removal(int *chars_removed, int n_chars_removed, int idx) int i; for ( i=0; i<n_chars_removed; i++ ) { - if ( chars_removed[i] > idx ) break; + if ( chars_removed[i] >= idx ) break; } return idx - i; @@ -172,6 +172,8 @@ static void process_tags(struct narrative_item *item, PangoAttrList *attrs) int i, j, k; size_t len; + printf("Processing '%s'\n", item->text); + item->n_chars_removed = 0; free(item->chars_removed); item->chars_removed = NULL; @@ -205,9 +207,26 @@ static void process_tags(struct narrative_item *item, PangoAttrList *attrs) text = g_utf8_find_next_char(efend, NULL); } + printf("Found %i ranges:\n", n_add); + for ( i=0; i<n_add; i++ ) { + printf("%c : %i - %i\n", add[i].type, add[i].start, add[i].end); + } + + printf("%i characters to remove: ", item->n_chars_removed); + for ( i=0; i<item->n_chars_removed; i++ ) { + printf("%i ", item->chars_removed[i]); + } + printf("\n"); + /* Sort the list of removed characters */ qsort(item->chars_removed, item->n_chars_removed, sizeof(int), cmpi); + printf("Sorted: "); + for ( i=0; i<item->n_chars_removed; i++ ) { + printf("%i ", item->chars_removed[i]); + } + printf("\n"); + /* Go through the list of attributes, and correct the character ranges * so that they refer to the text with characters removed, and add them * to the PangoAttrList */ @@ -235,10 +254,13 @@ static void process_tags(struct narrative_item *item, PangoAttrList *attrs) attr->end_index = index_with_removal(item->chars_removed, item->n_chars_removed, - add[i].end) + 1; + add[i].end); pango_attr_list_insert(attrs, attr); + printf("Adding %c with indices %i - %i\n", + add[i].type, attr->start_index, attr->end_index); + } /* Create the version of the text with characters removed */ @@ -258,6 +280,8 @@ static void process_tags(struct narrative_item *item, PangoAttrList *attrs) } } + printf("The edited text: '%s'\n", item->layout_text); + free(add); } |