diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-01-10 23:20:42 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-01-10 23:20:42 +0000 |
commit | ac89e5210918839b5d29cc0f030a79636b900e76 (patch) | |
tree | 2541a8b7096f15ac041b88c7084d5302ff2ddb70 | |
parent | ab5d165659d0867213217f81794d985efa5d87c1 (diff) | |
download | netsurf-ac89e5210918839b5d29cc0f030a79636b900e76.tar.gz netsurf-ac89e5210918839b5d29cc0f030a79636b900e76.tar.bz2 |
Simplify routine to scroll ta so that caret is visible.
-rw-r--r-- | desktop/textarea.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/desktop/textarea.c b/desktop/textarea.c index a12ed3282..0d0542ed6 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -238,7 +238,6 @@ static bool textarea_select_fragment(struct textarea * ta) static bool textarea_scroll_visible(struct textarea *ta) { int x0, x1, y0, y1, x, y; - int index, b_off; bool scrolled = false; if (ta->caret_pos.char_off == -1) @@ -249,21 +248,8 @@ static bool textarea_scroll_visible(struct textarea *ta) y0 = 0; y1 = ta->vis_height; - index = textarea_get_caret(ta); - - /* find byte offset of caret position */ - for (b_off = 0; index-- > 0; - b_off = utf8_next(ta->text, ta->text_len, b_off)) - ; /* do nothing */ - - nsfont.font_width(&ta->fstyle, - ta->text + ta->lines[ta->caret_pos.line].b_start, - b_off - ta->lines[ta->caret_pos.line].b_start, - &x); - - /* top-left of caret */ - x += MARGIN_LEFT - ta->scroll_x; - y = ta->line_height * ta->caret_pos.line - ta->scroll_y; + x = ta->caret_x - ta->scroll_x; + y = ta->caret_y - ta->scroll_y; /* check and change vertical scroll */ if (y < y0) { |