summaryrefslogtreecommitdiff
path: root/desktop/textarea.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-03-26 14:07:08 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2013-03-26 14:07:08 +0000
commit9a73da63473187502b7ff129645dd1fd731cafac (patch)
tree9c51073c4ea14bcecdeb0f7c382b9b7727c699c6 /desktop/textarea.c
parent0bb95432932ac004370e1c6829f3e7bb76819596 (diff)
downloadnetsurf-9a73da63473187502b7ff129645dd1fd731cafac.tar.gz
netsurf-9a73da63473187502b7ff129645dd1fd731cafac.tar.bz2
Reduce multi-line textarea a bit more. When redrawing only one line, don't redraw unchanged text at the start of the line.
Diffstat (limited to 'desktop/textarea.c')
-rw-r--r--desktop/textarea.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 1dea06361..75b0416e9 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -824,9 +824,11 @@ static bool textarea_reflow_singleline(struct textarea *ta, size_t b_off,
ta->password.utf8_len = ta->text.utf8_len;
}
+ /* Measure new width */
nsfont.font_width(&ta->fstyle, ta->show->data,
ta->show->len - 1, &x);
+ /* Get width of retained text */
if (b_off != ta->lines[0].b_length) {
nsfont.font_width(&ta->fstyle, ta->show->data,
b_off, &retained_width);
@@ -859,6 +861,7 @@ static bool textarea_reflow_singleline(struct textarea *ta, size_t b_off,
*
* \param ta Textarea to reflow
* \param b_start 0-based byte offset in ta->text to start of modification
+ * \param b_length Byte length of change in textarea text
* \return true on success false otherwise
*/
static bool textarea_reflow_multiline(struct textarea *ta,
@@ -1115,12 +1118,31 @@ static bool textarea_reflow_multiline(struct textarea *ta,
if ((skip_line || start == 0) &&
ta->lines[start].b_start + ta->lines[start].b_length >=
b_start + b_length) {
- text = ta->text.data + ta->lines[start].b_start +
+ size_t b_line_end = ta->lines[start].b_start +
ta->lines[start].b_length;
+ text = ta->text.data + b_line_end;
if (*text == '\0' || *text == '\n') {
r->y1 = min(r->y1, (signed)
(ta->line_height * (start + 1) +
ta->text_y_offset - ta->scroll_y));
+ if (b_start > ta->lines[start].b_start &&
+ b_start <= b_line_end) {
+ /* Remove unchanged text at start of line
+ * from redraw region */
+ int retained_width = 0;
+ size_t retain_end = b_start -
+ ta->lines[start].b_start;
+ text = ta->text.data + ta->lines[start].b_start;
+
+ nsfont.font_width(&ta->fstyle, text,
+ retain_end, &retained_width);
+
+ r->x0 = max(r->x0,
+ retained_width +
+ ta->border_width +
+ ta->pad_left -
+ ta->scroll_x - 1);
+ }
}
}