From fca1417369d0fde1af7a7ec9c2438e987c4050ec Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 12 Jul 2008 02:36:26 +0000 Subject: [PATCH] Fixed small selection problems: * When selecting character-wise backwards the initially selected char was deselected. * When first extending a selection and then moving the mouse back into the initial selection region (char, word, or line), the previously selected additional char/word/line would not be deselected (only when moving the mouse in the other direction out of the initial selection). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26389 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/terminal/TermView.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index d2744bdb5b..05e8b8d884 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -1933,8 +1933,19 @@ TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message) switch (fSelectGranularity) { case SELECT_CHARS: + { + // If we just start selecting, we first select the initially + // hit char, so that we get a proper initial selection -- the char + // in question, which will thus always be selected, regardless of + // whether selecting forward or backward. + if (fInitialSelectionStart == fInitialSelectionEnd) { + _Select(fInitialSelectionStart, fInitialSelectionEnd, true, + true); + } + _ExtendSelection(_ConvertToTerminal(where), true, true); break; + } case SELECT_WORDS: _SelectWord(where, true, true); break; @@ -2056,6 +2067,8 @@ TermView::_ExtendSelection(TermPos pos, bool inclusive, _Select(pos, end, false, !useInitialSelection); else if (pos > end) _Select(start, pos, false, !useInitialSelection); + else if (useInitialSelection) + _Select(start, end, false, false); } @@ -2098,6 +2111,8 @@ TermView::_SelectWord(BPoint where, bool extend, bool useInitialSelection) _ExtendSelection(start, false, useInitialSelection); else if (end > (useInitialSelection ? fInitialSelectionEnd : fSelEnd)) _ExtendSelection(end, false, useInitialSelection); + else if (useInitialSelection) + _Select(start, end, false, false); } else _Select(start, end, false, !useInitialSelection); } @@ -2114,7 +2129,8 @@ TermView::_SelectLine(BPoint where, bool extend, bool useInitialSelection) _ExtendSelection(start, false, useInitialSelection); else if (end > (useInitialSelection ? fInitialSelectionEnd : fSelEnd)) _ExtendSelection(end, false, useInitialSelection); - + else if (useInitialSelection) + _Select(start, end, false, false); } else _Select(start, end, false, !useInitialSelection); }