From 2f3895f0882e696598665cefcc0468de4cec0bff Mon Sep 17 00:00:00 2001 From: Adrian Lees Date: Sat, 16 Apr 2005 08:22:57 +0000 Subject: [project @ 2005-04-16 08:22:57 by adrianl] first cut at selecting inter-block spaces svn path=/import/netsurf/; revision=1652 --- render/html_redraw.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'render') diff --git a/render/html_redraw.c b/render/html_redraw.c index 491631194..c2eef9d3e 100644 --- a/render/html_redraw.c +++ b/render/html_redraw.c @@ -359,16 +359,31 @@ bool html_redraw_box(struct box *box, selection_highlighted(current_redraw_browser->sel, box, &start_idx, &end_idx)) { + unsigned endtxt_idx = end_idx; int startx, endx; + if (end_idx > box->length) { + /* adjust for trailing space, not present in box->text */ + assert(end_idx == box->length + 1); + endtxt_idx = box->length; + } + if (!nsfont_width(box->style, box->text, start_idx, &startx)) startx = 0; if (!nsfont_width(box->style, box->text + start_idx, - end_idx - start_idx, &endx)) + endtxt_idx - start_idx, &endx)) endx = 0; endx += startx; + /* is there a trailing space that should be highlighted as well? */ + if (end_idx > box->length) { + int spc_width; + /* \todo is there a more elegant/efficient solution? */ + if (nsfont_width(box->style, " ", 1, &spc_width)) + endx += spc_width; + } + if (scale != 1.0) { startx *= scale; endx *= scale; @@ -389,15 +404,15 @@ bool html_redraw_box(struct box *box, return false; if (!plot.text(x + startx, y + (int) (box->height * 0.75 * scale), - box->style, box->text + start_idx, end_idx - start_idx, + box->style, box->text + start_idx, endtxt_idx - start_idx, current_background_color ^ 0xffffff, current_background_color)) return false; - if (end_idx < box->length) { + if (endtxt_idx < box->length) { if (!plot.text(x + endx, y + (int) (box->height * 0.75 * scale), - box->style, box->text + end_idx, box->length - end_idx, + box->style, box->text + endtxt_idx, box->length - endtxt_idx, current_background_color, /*print_text_black ? 0 :*/ box->style->color)) return false; -- cgit v1.2.3