Simplified a bit some code
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22231 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -135,6 +135,7 @@ TermView::TermView(BRect frame, int32 argc, const char **argv, int32 historySize
|
|||||||
: BView(frame, "termview", B_FOLLOW_ALL,
|
: BView(frame, "termview", B_FOLLOW_ALL,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE| B_PULSE_NEEDED),
|
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE| B_PULSE_NEEDED),
|
||||||
fShell(NULL),
|
fShell(NULL),
|
||||||
|
fWinchRunner(NULL),
|
||||||
fFontWidth(0),
|
fFontWidth(0),
|
||||||
fFontHeight(0),
|
fFontHeight(0),
|
||||||
fFontAscent(0),
|
fFontAscent(0),
|
||||||
@@ -184,6 +185,7 @@ TermView::TermView(int rows, int columns, int32 argc, const char **argv, int32 h
|
|||||||
: BView(BRect(0, 0, 0, 0), "termview", B_FOLLOW_ALL,
|
: BView(BRect(0, 0, 0, 0), "termview", B_FOLLOW_ALL,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE| B_PULSE_NEEDED),
|
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE| B_PULSE_NEEDED),
|
||||||
fShell(NULL),
|
fShell(NULL),
|
||||||
|
fWinchRunner(NULL),
|
||||||
fFontWidth(0),
|
fFontWidth(0),
|
||||||
fFontHeight(0),
|
fFontHeight(0),
|
||||||
fFontAscent(0),
|
fFontAscent(0),
|
||||||
@@ -234,6 +236,7 @@ TermView::TermView(BMessage *archive)
|
|||||||
:
|
:
|
||||||
BView(archive),
|
BView(archive),
|
||||||
fShell(NULL),
|
fShell(NULL),
|
||||||
|
fWinchRunner(NULL),
|
||||||
fFontWidth(0),
|
fFontWidth(0),
|
||||||
fFontHeight(0),
|
fFontHeight(0),
|
||||||
fFontAscent(0),
|
fFontAscent(0),
|
||||||
@@ -1166,42 +1169,7 @@ TermView::_MouseTracking()
|
|||||||
float scr_start, scr_end, scr_pos;
|
float scr_start, scr_end, scr_pos;
|
||||||
|
|
||||||
while(!fQuitting) {
|
while(!fQuitting) {
|
||||||
if (1) {
|
|
||||||
#ifdef CHANGE_CURSOR_IMAGE
|
|
||||||
if (!has_data(find_thread(NULL))) {
|
|
||||||
BRect r;
|
|
||||||
|
|
||||||
if (_HasSelection()
|
|
||||||
&& (modifiers() & B_CONTROL_KEY)) {
|
|
||||||
|
|
||||||
if (LockLooper()) {
|
|
||||||
GetMouse(&stpoint, &button);
|
|
||||||
r = Bounds();
|
|
||||||
UnlockLooper();
|
|
||||||
}
|
|
||||||
if (r.Contains(stpoint)) {
|
|
||||||
CurPos tmppos = _BPointToCurPos(stpoint);
|
|
||||||
if (fSelStart > fSelEnd) {
|
|
||||||
stpos = fSelEnd;
|
|
||||||
edpos = fSelStart;
|
|
||||||
} else {
|
|
||||||
stpos = fSelStart;
|
|
||||||
edpos = fSelEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tmppos > stpos && tmppos < edpos)
|
|
||||||
SetViewCursor(M_ADD_CURSOR);
|
|
||||||
else
|
|
||||||
SetViewCursor(B_HAND_CURSOR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
snooze(50 * 1000);
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
code = receive_data(&sender,(void *)&stpoint, sizeof(BPoint));
|
code = receive_data(&sender,(void *)&stpoint, sizeof(BPoint));
|
||||||
}
|
|
||||||
|
|
||||||
if (code != MOUSE_THR_CODE)
|
if (code != MOUSE_THR_CODE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1211,8 +1179,7 @@ TermView::_MouseTracking()
|
|||||||
stpos = _BPointToCurPos(stpoint);
|
stpos = _BPointToCurPos(stpoint);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
snooze(40000);
|
||||||
snooze(40 * 1000);
|
|
||||||
|
|
||||||
if (LockLooper()) {
|
if (LockLooper()) {
|
||||||
GetMouse(&edpoint, &button);
|
GetMouse(&edpoint, &button);
|
||||||
@@ -2019,19 +1986,8 @@ TermView::MouseDown(BPoint where)
|
|||||||
Window()->CurrentMessage()->FindInt32("clicks", &clicks);
|
Window()->CurrentMessage()->FindInt32("clicks", &clicks);
|
||||||
|
|
||||||
if (_HasSelection()) {
|
if (_HasSelection()) {
|
||||||
CurPos inPos, stPos, edPos;
|
CurPos inPos = _BPointToCurPos(where);
|
||||||
if (fSelStart < fSelEnd) {
|
if (_CheckSelectedRegion(inPos)) {
|
||||||
stPos = fSelStart;
|
|
||||||
edPos = fSelEnd;
|
|
||||||
} else {
|
|
||||||
stPos = fSelEnd;
|
|
||||||
edPos = fSelStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
inPos = _BPointToCurPos(where);
|
|
||||||
|
|
||||||
// If mouse pointer is avove selected Region, start Drag'n Copy.
|
|
||||||
if (inPos > stPos && inPos < edPos) {
|
|
||||||
if (mod & B_CONTROL_KEY) {
|
if (mod & B_CONTROL_KEY) {
|
||||||
BPoint p;
|
BPoint p;
|
||||||
uint32 bt;
|
uint32 bt;
|
||||||
@@ -2043,34 +1999,12 @@ TermView::MouseDown(BPoint where)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
snooze(40 * 1000);
|
snooze(40000);
|
||||||
|
|
||||||
} while (abs((int)(where.x - p.x)) < 4
|
} while (abs((int)(where.x - p.x)) < 4
|
||||||
&& abs((int)(where.y - p.y)) < 4);
|
&& abs((int)(where.y - p.y)) < 4);
|
||||||
|
|
||||||
BString copyStr("");
|
InitiateDrag();
|
||||||
fTextBuffer->GetStringFromRegion(copyStr, fSelStart, fSelEnd);
|
|
||||||
|
|
||||||
BMessage msg(B_MIME_TYPE);
|
|
||||||
msg.AddData("text/plain", B_MIME_TYPE, copyStr.String(), copyStr.Length());
|
|
||||||
|
|
||||||
BPoint st = _CurPosToBPoint(stPos);
|
|
||||||
BPoint ed = _CurPosToBPoint(edPos);
|
|
||||||
BRect r;
|
|
||||||
|
|
||||||
if (stPos.y == edPos.y) {
|
|
||||||
r.Set(st.x, st.y - fTop,
|
|
||||||
ed.x + fFontWidth, ed.y + fFontHeight - fTop);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
r.Set(0, st.y - fTop,
|
|
||||||
fTermColumns * fFontWidth, ed.y + fFontHeight - fTop);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = r & Bounds();
|
|
||||||
|
|
||||||
DragMessage(&msg, r);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2114,6 +2048,7 @@ TermView::MouseDown(BPoint where)
|
|||||||
BView::MouseDown(where);
|
BView::MouseDown(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
|
TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
|
||||||
{
|
{
|
||||||
@@ -2537,6 +2472,35 @@ TermView::CheckShellGone()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TermView::InitiateDrag()
|
||||||
|
{
|
||||||
|
BString copyStr("");
|
||||||
|
fTextBuffer->GetStringFromRegion(copyStr, fSelStart, fSelEnd);
|
||||||
|
|
||||||
|
BMessage message(B_MIME_TYPE);
|
||||||
|
message.AddData("text/plain", B_MIME_TYPE, copyStr.String(), copyStr.Length());
|
||||||
|
|
||||||
|
BPoint start = _CurPosToBPoint(fSelStart);
|
||||||
|
BPoint end = _CurPosToBPoint(fSelEnd);
|
||||||
|
|
||||||
|
BRect rect;
|
||||||
|
if (fSelStart.y == fSelEnd.y) {
|
||||||
|
rect.Set(start.x, start.y - fTop, end.x + fFontWidth,
|
||||||
|
end.y + fFontHeight - fTop);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
rect.Set(0, start.y - fTop, fTermColumns * fFontWidth,
|
||||||
|
end.y + fFontHeight - fTop);
|
||||||
|
}
|
||||||
|
|
||||||
|
rect = rect & Bounds();
|
||||||
|
|
||||||
|
DragMessage(&message, rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
TermView::_Redraw(int x1, int y1, int x2, int y2)
|
TermView::_Redraw(int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ public:
|
|||||||
|
|
||||||
void SetTermFont(const BFont *halfFont, const BFont *fullFont);
|
void SetTermFont(const BFont *halfFont, const BFont *fullFont);
|
||||||
void GetFontSize(int *width, int *height);
|
void GetFontSize(int *width, int *height);
|
||||||
|
|
||||||
BRect SetTermSize(int rows, int cols, bool resize);
|
BRect SetTermSize(int rows, int cols, bool resize);
|
||||||
|
|
||||||
void SetTextColor(rgb_color fore, rgb_color back);
|
void SetTextColor(rgb_color fore, rgb_color back);
|
||||||
void SetSelectColor(rgb_color fore, rgb_color back);
|
void SetSelectColor(rgb_color fore, rgb_color back);
|
||||||
void SetCursorColor(rgb_color fore, rgb_color back);
|
void SetCursorColor(rgb_color fore, rgb_color back);
|
||||||
@@ -117,6 +117,8 @@ public:
|
|||||||
|
|
||||||
void CheckShellGone();
|
void CheckShellGone();
|
||||||
|
|
||||||
|
void InitiateDrag();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
@@ -139,7 +141,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _InitObject(int32 argc, const char **argv);
|
status_t _InitObject(int32 argc, const char **argv);
|
||||||
status_t _InitMouseThread(void);
|
status_t _InitMouseThread();
|
||||||
|
|
||||||
status_t _AttachShell(Shell *shell);
|
status_t _AttachShell(Shell *shell);
|
||||||
void _DetachShell();
|
void _DetachShell();
|
||||||
@@ -186,7 +188,6 @@ private:
|
|||||||
|
|
||||||
bool _CheckSelectedRegion(const CurPos &pos);
|
bool _CheckSelectedRegion(const CurPos &pos);
|
||||||
|
|
||||||
|
|
||||||
void _UpdateSIGWINCH();
|
void _UpdateSIGWINCH();
|
||||||
|
|
||||||
static void _FixFontAttributes(BFont &font);
|
static void _FixFontAttributes(BFont &font);
|
||||||
|
|||||||
Reference in New Issue
Block a user