summaryrefslogtreecommitdiff
path: root/desktop/textarea.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-09-17 19:20:37 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2014-09-18 16:00:31 +0100
commit1878bc88a9c2ead4e12e6ed9165a27e99ef9c6f9 (patch)
treec3eee573c648d59ff5341e60668e0f4584017933 /desktop/textarea.c
parentdcf49c7341eac680838edd4358814b42d07bfa7c (diff)
downloadnetsurf-1878bc88a9c2ead4e12e6ed9165a27e99ef9c6f9.tar.gz
netsurf-1878bc88a9c2ead4e12e6ed9165a27e99ef9c6f9.tar.bz2
Improve comments and simplify code.
Diffstat (limited to 'desktop/textarea.c')
-rw-r--r--desktop/textarea.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/desktop/textarea.c b/desktop/textarea.c
index a1e46ddab..e37f06e53 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -972,14 +972,18 @@ static bool textarea_reflow_multiline(struct textarea *ta,
avail_width = 0;
h_extent = avail_width;
- /* Set up initial length and text offset */
- if (line == 0) {
- len = ta->text.len - 1;
- text = ta->text.data;
- } else {
+ /* Set up length of remaining text and offset to current point
+ * in text. Initially set it to start of textarea */
+ len = ta->text.len - 1;
+ text = ta->text.data;
+
+ if (line != 0) {
+ /* Not starting at the beginning of the textarea, so
+ * jump forward, and make sure the horizontal extents
+ * accommodate the width of the skipped lines. */
unsigned int i;
- len = ta->text.len - 1 - ta->lines[line].b_start;
- text = ta->text.data + ta->lines[line].b_start;
+ len -= ta->lines[line].b_start;
+ text += ta->lines[line].b_start;
for (i = 0; i < line; i++) {
if (ta->lines[i].width > h_extent) {