diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-01-10 15:06:05 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-01-10 15:06:05 +0000 |
commit | eddb0f17d183cec2013d23e613e70cc03345e57f (patch) | |
tree | 73c7d4bba82da5d36daa03e7aa10998346bfca6e /desktop/textarea.c | |
parent | 4cad82db9f907fb8ffd42303527a976ca226cedd (diff) | |
download | netsurf-eddb0f17d183cec2013d23e613e70cc03345e57f.tar.gz netsurf-eddb0f17d183cec2013d23e613e70cc03345e57f.tar.bz2 |
Simplfy caret placement and redraw.
Diffstat (limited to 'desktop/textarea.c')
-rw-r--r-- | desktop/textarea.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/desktop/textarea.c b/desktop/textarea.c index 0f42a9f30..79b1ed436 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -831,9 +831,9 @@ bool textarea_set_caret(struct textarea *ta, int caret) b_off - ta->lines[ta->caret_pos.line].b_start, &x); - x += MARGIN_LEFT - ta->scroll_x; + x += MARGIN_LEFT; ta->caret_x = x; - y = ta->line_height * ta->caret_pos.line - ta->scroll_y; + y = ta->line_height * ta->caret_pos.line; ta->caret_y = y; if (textarea_scroll_visible(ta)) { @@ -1051,20 +1051,17 @@ void textarea_redraw(struct textarea *ta, int x, int y, &ta->fstyle); } - if ((ta->sel_end == -1 || - ta->sel_start == ta->sel_end) && - x + ta->caret_x >= clip->x0 && - x + ta->caret_x <= clip->x1) { - /* There is no selection and caret is in horizontal - * clip range. */ - int caret_height = ta->line_height - 1; - r.y0 = y + ta->caret_y + text_y_offset; - if (r.y0 + caret_height >= clip->y0 && r.y0 <= clip->y1) - /* Caret in vertical clip range; plot */ - plot->line(x + ta->caret_x, r.y0, - x + ta->caret_x, - r.y0 + caret_height, - &pstyle_stroke_caret); + x -= ta->scroll_x; + y -= ta->scroll_y; + + if (ta->sel_end == -1 || ta->sel_start == ta->sel_end) { + /* There is no selection; draw caret */ + int caret_y = y + ta->caret_y + text_y_offset; + int caret_height = caret_y + ta->line_height - 1; + + plot->line(x + ta->caret_x, caret_y, + x + ta->caret_x, caret_height, + &pstyle_stroke_caret); } } |