From fc430dba753ee80762ff3ffdbde8be59a00ba9ab Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 11 Feb 2013 16:47:11 +0000 Subject: Clip native caret render so it can't overwrite border. Slight simplification. --- desktop/textarea.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'desktop') diff --git a/desktop/textarea.c b/desktop/textarea.c index 82a026188..eedc09115 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -1643,22 +1643,23 @@ void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale, c_pos++; } - plot->clip(clip); - - if ((ta->sel_end == -1 || ta->sel_start == ta->sel_end) && + if (ta->flags & TEXTAREA_INTERNAL_CARET && + (ta->sel_end == -1 || ta->sel_start == ta->sel_end) && ta->caret_pos.char_off >= 0) { - /* There is no selection, and caret visible: show caret */ + /* No native caret, there is no selection, and caret visible */ int caret_y = y - ta->scroll_y + ta->caret_y; - if (ta->flags & TEXTAREA_INTERNAL_CARET) { - /* Render our own caret */ - plot->line(x - ta->scroll_x + ta->caret_x, caret_y, - x - ta->scroll_x + ta->caret_x, - caret_y + ta->line_height, - &pstyle_stroke_caret); - } + plot->clip(&r); + + /* Render our own caret */ + plot->line(x - ta->scroll_x + ta->caret_x, caret_y, + x - ta->scroll_x + ta->caret_x, + caret_y + ta->line_height, + &pstyle_stroke_caret); } + plot->clip(clip); + if (ta->bar_x != NULL) scrollbar_redraw(ta->bar_x, x / scale + ta->border_width, -- cgit v1.2.3