* BTextView no longer inverts the caret although there is a selection, which
would yield double inversion of the caret position, causing #5006 * cleanup with respect to when the selection can be highlighted and/or the caret can be shown/hidden git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34944 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1137,11 +1137,11 @@ BTextView::SetText(const char *inText, int32 inLength,
|
|||||||
|
|
||||||
// hide the caret/unhilite the selection
|
// hide the caret/unhilite the selection
|
||||||
if (fActive) {
|
if (fActive) {
|
||||||
if (fSelStart != fSelEnd)
|
if (fSelStart != fSelEnd) {
|
||||||
Highlight(fSelStart, fSelEnd);
|
if (fSelectable)
|
||||||
else {
|
Highlight(fSelStart, fSelEnd);
|
||||||
|
} else
|
||||||
_HideCaret();
|
_HideCaret();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove data from buffer
|
// remove data from buffer
|
||||||
@@ -1157,8 +1157,7 @@ BTextView::SetText(const char *inText, int32 inLength,
|
|||||||
ScrollTo(B_ORIGIN);
|
ScrollTo(B_ORIGIN);
|
||||||
|
|
||||||
// draw the caret
|
// draw the caret
|
||||||
if (fActive)
|
_ShowCaret();
|
||||||
_ShowCaret();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1197,8 +1196,7 @@ BTextView::SetText(BFile *inFile, int32 inOffset, int32 inLength,
|
|||||||
ScrollToOffset(fSelStart);
|
ScrollToOffset(fSelStart);
|
||||||
|
|
||||||
// draw the caret
|
// draw the caret
|
||||||
if (fActive)
|
_ShowCaret();
|
||||||
_ShowCaret();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1251,9 +1249,10 @@ BTextView::Delete(int32 startOffset, int32 endOffset)
|
|||||||
|
|
||||||
// hide the caret/unhilite the selection
|
// hide the caret/unhilite the selection
|
||||||
if (fActive) {
|
if (fActive) {
|
||||||
if (fSelStart != fSelEnd)
|
if (fSelStart != fSelEnd) {
|
||||||
Highlight(fSelStart, fSelEnd);
|
if (fSelectable)
|
||||||
else
|
Highlight(fSelStart, fSelEnd);
|
||||||
|
} else
|
||||||
_HideCaret();
|
_HideCaret();
|
||||||
}
|
}
|
||||||
// remove data from buffer
|
// remove data from buffer
|
||||||
@@ -1271,8 +1270,7 @@ BTextView::Delete(int32 startOffset, int32 endOffset)
|
|||||||
_Refresh(startOffset, endOffset, false);
|
_Refresh(startOffset, endOffset, false);
|
||||||
|
|
||||||
// draw the caret
|
// draw the caret
|
||||||
if (fActive)
|
_ShowCaret();
|
||||||
_ShowCaret();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2338,15 +2336,8 @@ BTextView::MakeSelectable(bool selectable)
|
|||||||
|
|
||||||
fSelectable = selectable;
|
fSelectable = selectable;
|
||||||
|
|
||||||
if (Window() != NULL) {
|
if (fActive && fSelStart != fSelEnd && Window() != NULL)
|
||||||
if (fActive) {
|
Highlight(fSelStart, fSelEnd);
|
||||||
// show/hide the caret, hilite/unhilite the selection
|
|
||||||
if (fSelStart != fSelEnd)
|
|
||||||
Highlight(fSelStart, fSelEnd);
|
|
||||||
else
|
|
||||||
_InvertCaret();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2410,11 +2401,11 @@ BTextView::SetWordWrap(bool wrap)
|
|||||||
bool updateOnScreen = fActive && Window() != NULL;
|
bool updateOnScreen = fActive && Window() != NULL;
|
||||||
if (updateOnScreen) {
|
if (updateOnScreen) {
|
||||||
// hide the caret, unhilite the selection
|
// hide the caret, unhilite the selection
|
||||||
if (fSelStart != fSelEnd)
|
if (fSelStart != fSelEnd) {
|
||||||
Highlight(fSelStart, fSelEnd);
|
if (fSelectable)
|
||||||
else {
|
Highlight(fSelStart, fSelEnd);
|
||||||
|
} else
|
||||||
_HideCaret();
|
_HideCaret();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fWrap = wrap;
|
fWrap = wrap;
|
||||||
@@ -2424,9 +2415,10 @@ BTextView::SetWordWrap(bool wrap)
|
|||||||
|
|
||||||
if (updateOnScreen) {
|
if (updateOnScreen) {
|
||||||
// show the caret, hilite the selection
|
// show the caret, hilite the selection
|
||||||
if (fSelStart != fSelEnd && fSelectable)
|
if (fSelStart != fSelEnd) {
|
||||||
Highlight(fSelStart, fSelEnd);
|
if (fSelectable)
|
||||||
else
|
Highlight(fSelStart, fSelEnd);
|
||||||
|
} else
|
||||||
_ShowCaret();
|
_ShowCaret();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2596,9 +2588,10 @@ BTextView::MakeResizable(bool resize, BView *resizeView)
|
|||||||
fWrap = false;
|
fWrap = false;
|
||||||
|
|
||||||
if (fActive && Window() != NULL) {
|
if (fActive && Window() != NULL) {
|
||||||
if (fSelStart != fSelEnd && fSelectable)
|
if (fSelStart != fSelEnd) {
|
||||||
Highlight(fSelStart, fSelEnd);
|
if (fSelectable)
|
||||||
else
|
Highlight(fSelStart, fSelEnd);
|
||||||
|
} else
|
||||||
_HideCaret();
|
_HideCaret();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4476,9 +4469,10 @@ BTextView::_DrawLines(int32 startLine, int32 endLine, int32 startOffset,
|
|||||||
|
|
||||||
// draw the caret/hilite the selection
|
// draw the caret/hilite the selection
|
||||||
if (fActive) {
|
if (fActive) {
|
||||||
if (fSelStart != fSelEnd && fSelectable)
|
if (fSelStart != fSelEnd) {
|
||||||
Highlight(fSelStart, fSelEnd);
|
if (fSelectable)
|
||||||
else {
|
Highlight(fSelStart, fSelEnd);
|
||||||
|
} else {
|
||||||
if (fCaretVisible)
|
if (fCaretVisible)
|
||||||
_DrawCaret(fSelStart);
|
_DrawCaret(fSelStart);
|
||||||
}
|
}
|
||||||
@@ -4537,7 +4531,7 @@ BTextView::_DrawCaret(int32 offset)
|
|||||||
inline void
|
inline void
|
||||||
BTextView::_ShowCaret()
|
BTextView::_ShowCaret()
|
||||||
{
|
{
|
||||||
if (!fCaretVisible && fEditable)
|
if (fActive && !fCaretVisible && fEditable && fSelStart == fSelEnd)
|
||||||
_InvertCaret();
|
_InvertCaret();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4545,7 +4539,7 @@ BTextView::_ShowCaret()
|
|||||||
inline void
|
inline void
|
||||||
BTextView::_HideCaret()
|
BTextView::_HideCaret()
|
||||||
{
|
{
|
||||||
if (fCaretVisible)
|
if (fCaretVisible && fSelStart == fSelEnd)
|
||||||
_InvertCaret();
|
_InvertCaret();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5053,10 +5047,8 @@ BTextView::_Activate()
|
|||||||
if (fSelStart != fSelEnd) {
|
if (fSelStart != fSelEnd) {
|
||||||
if (fSelectable)
|
if (fSelectable)
|
||||||
Highlight(fSelStart, fSelEnd);
|
Highlight(fSelStart, fSelEnd);
|
||||||
} else {
|
} else
|
||||||
if (fEditable)
|
_ShowCaret();
|
||||||
_ShowCaret();
|
|
||||||
}
|
|
||||||
|
|
||||||
BPoint where;
|
BPoint where;
|
||||||
ulong buttons;
|
ulong buttons;
|
||||||
@@ -5620,5 +5612,3 @@ BTextView::TextTrackState::SimulateMouseMovement(BTextView *textView)
|
|||||||
textView->GetMouse(&where, &buttons);
|
textView->GetMouse(&where, &buttons);
|
||||||
textView->_PerformMouseMoved(where, B_INSIDE_VIEW);
|
textView->_PerformMouseMoved(where, B_INSIDE_VIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user