diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shape.c | 6 | ||||
-rw-r--r-- | src/wrap.c | 5 | ||||
-rw-r--r-- | src/wrap.h | 1 |
3 files changed, 7 insertions, 5 deletions
diff --git a/src/shape.c b/src/shape.c index ccfe9e1..f483510 100644 --- a/src/shape.c +++ b/src/shape.c @@ -50,11 +50,14 @@ void shape_box(struct wrap_box *box) { PangoRectangle rect; const char *tp; + const char *ep; tp = g_utf8_offset_to_pointer(sc_block_contents(box->scblock), box->offs_char); + ep = g_utf8_offset_to_pointer(sc_block_contents(box->scblock), + box->offs_char+box->len_chars); - pango_shape(tp, box->len_bytes, &box->analysis, box->glyphs); + pango_shape(tp, ep-tp, &box->analysis, box->glyphs); pango_glyph_string_extents(box->glyphs, box->font, NULL, &rect); @@ -98,7 +101,6 @@ static void add_wrap_box(gpointer vi, gpointer vb) box->scblock = bas->bl; box->offs_char = g_utf8_pointer_to_offset(tp, tp+offs_bytes); box->len_chars = g_utf8_strlen(tp+offs_bytes, item->length); - box->len_bytes = item->length; col = sc_interp_get_fgcol(bas->scin); box->col[0] = col[0]; /* Red */ @@ -125,6 +125,7 @@ void get_cursor_pos(struct wrap_box *box, int pos, int p; const char *block_text; const char *box_text; + const char *ep; *xposd = 0.0; *yposd = 0.0; @@ -144,9 +145,9 @@ void get_cursor_pos(struct wrap_box *box, int pos, case WRAP_BOX_PANGO : block_text = sc_block_contents(box->scblock); box_text = g_utf8_offset_to_pointer(block_text, box->offs_char); - /* cast because this function is not const-clean */ + ep = g_utf8_offset_to_pointer(box_text, box->len_chars); pango_glyph_string_index_to_x(box->glyphs, (char *)box_text, - box->len_bytes, &box->analysis, + ep - box_text, &box->analysis, pos, FALSE, &p); *xposd += pango_units_to_double(p); break; @@ -78,7 +78,6 @@ struct wrap_box PangoGlyphString *glyphs; PangoFont *font; double col[4]; /* rgba colour */ - size_t len_bytes; PangoAnalysis analysis; int len_chars; |