diff options
author | Jeffrey Lee <me@phlamethrower.co.uk> | 2006-09-10 16:12:45 +0000 |
---|---|---|
committer | Jeffrey Lee <me@phlamethrower.co.uk> | 2006-09-10 16:12:45 +0000 |
commit | bfe14720be66af03474df80f41dea8576c1014d5 (patch) | |
tree | 3c85e44164f9e280ab2455e1aaed04c511187198 /desktop/textinput.c | |
parent | cc41d7c27a97816c559fd3bc08b964d31ef8a2fa (diff) | |
download | netsurf-bfe14720be66af03474df80f41dea8576c1014d5.tar.gz netsurf-bfe14720be66af03474df80f41dea8576c1014d5.tar.bz2 |
Fixed the other caret issues after pasting into textarea
svn path=/trunk/netsurf/; revision=2944
Diffstat (limited to 'desktop/textinput.c')
-rw-r--r-- | desktop/textinput.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/desktop/textinput.c b/desktop/textinput.c index 4fd72af5c..fe804c348 100644 --- a/desktop/textinput.c +++ b/desktop/textinput.c @@ -1229,9 +1229,26 @@ bool browser_window_textarea_paste_text(struct browser_window *bw, /* reflow textarea preserving width and height */ textarea_reflow(bw, textarea, inline_container); - /* reflowing may have broken our caret offset */ - if(textarea->gadget->caret_box_offset > text_box->length) - char_offset = textarea->gadget->caret_box_offset = text_box->length; + /* reflowing may have broken our caret offset + this bit should hopefully continue to work if textarea_reflow + is fixed to update the caret itself */ + char_offset = textarea->gadget->caret_box_offset; + text_box = textarea->gadget->caret_text_box; + while((char_offset > text_box->length+text_box->space) && (text_box->next) && (text_box->next->type == BOX_TEXT)) + { + LOG(("Caret out of range: Was %d in boxlen %d space %d",char_offset,text_box->length,text_box->space)); + char_offset -= text_box->length+text_box->space; + text_box = text_box->next; + } + /* not sure if this will happen or not... but won't stick an assert here as we can recover from it */ + if(char_offset > text_box->length) + { + LOG(("Caret moved beyond end of line: Was %d in boxlen %d",char_offset,text_box->length)); + char_offset = text_box->length; + } + textarea->gadget->caret_text_box = text_box; + textarea->gadget->caret_box_offset = char_offset; + nsfont_width(text_box->style, text_box->text, char_offset, &pixel_offset); |