From 9d73eec0ef3145a44fa5d15c350fed5cd30d39b8 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Wed, 30 Jan 2008 10:58:04 +0000 Subject: [PATCH] Fixed a couple of problems with inserting text when there was a selection (for example, moving around text with the mouse). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23789 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/TextView.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index bf21c47d59..1be6f53fe1 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -3056,7 +3056,7 @@ BTextView::_HandleAlphaKey(const char *bytes, int32 numBytes) } else _DoInsertText(bytes, numBytes, fSelStart, NULL, NULL); - fClickOffset = fSelEnd; + fSelStart = fSelEnd = fClickOffset = fSelStart + numBytes; ScrollToOffset(fClickOffset); } @@ -3480,7 +3480,13 @@ BTextView::_DoInsertText(const char *inText, int32 inLength, int32 inOffset, if (TextLength() + inLength > MaxBytes()) return; - + + if (fSelStart != fSelEnd + && fSelStart != 0 + && fSelEnd != 0) { + + Select(fSelStart, fSelStart); + } // Don't do any check, the public methods will have adjusted // eventual bogus values... @@ -3491,13 +3497,8 @@ BTextView::_DoInsertText(const char *inText, int32 inLength, int32 inOffset, // copy data into buffer InsertText(inText, inLength, inOffset, inRuns); - // offset the caret/selection - int32 saveStart = fSelStart; - fSelStart += inLength; - fSelEnd += inLength; - // recalc line breaks and draw the text - _Refresh(saveStart, fSelEnd, true, false); + _Refresh(inOffset, textLength, true, false); }