Got rid of fSelected, no need to maintain a separate variable to check
if we have a selection. Now there's a "HasSelection()" method which just checks if fSelStart and fSelEnd are different. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21520 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -94,7 +94,6 @@ TermView::TermView(BRect frame, CodeConv *inCodeConv, int fd)
|
|||||||
fScrBot(fTermRows - 1),
|
fScrBot(fTermRows - 1),
|
||||||
fScrBufSize(gTermPref->getInt32(PREF_HISTORY_SIZE)),
|
fScrBufSize(gTermPref->getInt32(PREF_HISTORY_SIZE)),
|
||||||
fScrRegionSet(0),
|
fScrRegionSet(0),
|
||||||
fSelected(false),
|
|
||||||
fMouseTracking(false),
|
fMouseTracking(false),
|
||||||
fViewThread(-1),
|
fViewThread(-1),
|
||||||
fMouseThread(-1),
|
fMouseThread(-1),
|
||||||
@@ -851,7 +850,7 @@ TermView::MouseTracking(void *data)
|
|||||||
if (!has_data(find_thread(NULL))) {
|
if (!has_data(find_thread(NULL))) {
|
||||||
BRect r;
|
BRect r;
|
||||||
|
|
||||||
if (theObj->fSelected
|
if (theObj->HasSelection()
|
||||||
&& ( gTermPref->getInt32(PREF_DRAGN_COPY)
|
&& ( gTermPref->getInt32(PREF_DRAGN_COPY)
|
||||||
|| modifiers() & B_CONTROL_KEY)) {
|
|| modifiers() & B_CONTROL_KEY)) {
|
||||||
|
|
||||||
@@ -886,7 +885,7 @@ TermView::MouseTracking(void *data)
|
|||||||
if (code != MOUSE_THR_CODE)
|
if (code != MOUSE_THR_CODE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
selected = theObj->fSelected;
|
selected = theObj->HasSelection();
|
||||||
edpoint.Set(-1, -1);
|
edpoint.Set(-1, -1);
|
||||||
|
|
||||||
stpos = theObj->BPointToCurPos(stpoint);
|
stpos = theObj->BPointToCurPos(stpoint);
|
||||||
@@ -1099,7 +1098,7 @@ void
|
|||||||
TermView::UpdateSIGWINCH()
|
TermView::UpdateSIGWINCH()
|
||||||
{
|
{
|
||||||
if (fFrameResized) {
|
if (fFrameResized) {
|
||||||
if (fSelected)
|
if (HasSelection())
|
||||||
TermDrawSelectedRegion(fSelStart, fSelEnd);
|
TermDrawSelectedRegion(fSelStart, fSelEnd);
|
||||||
ScrollTo(0, fTop);
|
ScrollTo(0, fTop);
|
||||||
ResizeScrBarRange();
|
ResizeScrBarRange();
|
||||||
@@ -1575,7 +1574,7 @@ TermView::DoFileDrop(entry_ref &ref)
|
|||||||
void
|
void
|
||||||
TermView::DoCopy()
|
TermView::DoCopy()
|
||||||
{
|
{
|
||||||
if (!fSelected)
|
if (!HasSelection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BString copyStr;
|
BString copyStr;
|
||||||
@@ -1668,9 +1667,6 @@ TermView::DoClearAll(void)
|
|||||||
// reset cursor pos
|
// reset cursor pos
|
||||||
SetCurPos(0, 0);
|
SetCurPos(0, 0);
|
||||||
|
|
||||||
// reset selection.
|
|
||||||
fSelected = false;
|
|
||||||
|
|
||||||
fScrollBar->SetRange(0, 0);
|
fScrollBar->SetRange(0, 0);
|
||||||
fScrollBar->SetProportion(1);
|
fScrollBar->SetProportion(1);
|
||||||
}
|
}
|
||||||
@@ -1702,7 +1698,7 @@ TermView::MouseDown(BPoint where)
|
|||||||
|
|
||||||
// paste button
|
// paste button
|
||||||
if ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0) {
|
if ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0) {
|
||||||
if (fSelected) {
|
if (HasSelection()) {
|
||||||
// copy text from region
|
// copy text from region
|
||||||
BString copy;
|
BString copy;
|
||||||
fTextBuffer->GetStringFromRegion(copy);
|
fTextBuffer->GetStringFromRegion(copy);
|
||||||
@@ -1720,7 +1716,7 @@ TermView::MouseDown(BPoint where)
|
|||||||
Window()->CurrentMessage()->FindInt32("modifiers", &mod);
|
Window()->CurrentMessage()->FindInt32("modifiers", &mod);
|
||||||
Window()->CurrentMessage()->FindInt32("clicks", &clicks);
|
Window()->CurrentMessage()->FindInt32("clicks", &clicks);
|
||||||
|
|
||||||
if (fSelected) {
|
if (HasSelection()) {
|
||||||
CurPos inPos, stPos, edPos;
|
CurPos inPos, stPos, edPos;
|
||||||
if (fSelStart < fSelEnd) {
|
if (fSelStart < fSelEnd) {
|
||||||
stPos = fSelStart;
|
stPos = fSelStart;
|
||||||
@@ -1855,7 +1851,6 @@ TermView::Select(CurPos start, CurPos end)
|
|||||||
|
|
||||||
fTextBuffer->Select(fSelStart, fSelEnd);
|
fTextBuffer->Select(fSelStart, fSelEnd);
|
||||||
TermDrawSelectedRegion(fSelStart, fSelEnd);
|
TermDrawSelectedRegion(fSelStart, fSelEnd);
|
||||||
fSelected = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add select region(shift + mouse click)
|
// Add select region(shift + mouse click)
|
||||||
@@ -1866,7 +1861,7 @@ TermView::AddSelectRegion(CurPos pos)
|
|||||||
ushort attr;
|
ushort attr;
|
||||||
CurPos start, end, inPos;
|
CurPos start, end, inPos;
|
||||||
|
|
||||||
if (!fSelected)
|
if (!HasSelection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// error check, and if mouse point to a plase full width character,
|
// error check, and if mouse point to a plase full width character,
|
||||||
@@ -1979,7 +1974,7 @@ TermView::DeSelect(void)
|
|||||||
{
|
{
|
||||||
CurPos start, end;
|
CurPos start, end;
|
||||||
|
|
||||||
if (!fSelected)
|
if (!HasSelection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fTextBuffer->DeSelect();
|
fTextBuffer->DeSelect();
|
||||||
@@ -1991,10 +1986,16 @@ TermView::DeSelect(void)
|
|||||||
fSelEnd.Set(-1, -1);
|
fSelEnd.Set(-1, -1);
|
||||||
|
|
||||||
TermDrawSelectedRegion(start, end);
|
TermDrawSelectedRegion(start, end);
|
||||||
|
|
||||||
fSelected = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
TermView::HasSelection() const
|
||||||
|
{
|
||||||
|
return fSelStart != fSelEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermView::SelectWord(BPoint where, int mod)
|
TermView::SelectWord(BPoint where, int mod)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ class TermView : public BView {
|
|||||||
void ResizeSelectRegion(CurPos);
|
void ResizeSelectRegion(CurPos);
|
||||||
|
|
||||||
void DeSelect();
|
void DeSelect();
|
||||||
|
bool HasSelection() const;
|
||||||
|
|
||||||
// select word function
|
// select word function
|
||||||
void SelectWord(BPoint where, int mod);
|
void SelectWord(BPoint where, int mod);
|
||||||
@@ -307,7 +308,6 @@ class TermView : public BView {
|
|||||||
// view selection
|
// view selection
|
||||||
CurPos fSelStart;
|
CurPos fSelStart;
|
||||||
CurPos fSelEnd;
|
CurPos fSelEnd;
|
||||||
bool fSelected;
|
|
||||||
bool fMouseTracking;
|
bool fMouseTracking;
|
||||||
|
|
||||||
// thread ID / flags.
|
// thread ID / flags.
|
||||||
|
|||||||
Reference in New Issue
Block a user