diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index 92f4facde5..00506cc34c 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -135,6 +135,7 @@ TermView::TermView(BRect frame, int32 argc, const char **argv, int32 historySize : BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE| B_PULSE_NEEDED), fShell(NULL), + fWinchRunner(NULL), fFontWidth(0), fFontHeight(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, B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE| B_PULSE_NEEDED), fShell(NULL), + fWinchRunner(NULL), fFontWidth(0), fFontHeight(0), fFontAscent(0), @@ -234,6 +236,7 @@ TermView::TermView(BMessage *archive) : BView(archive), fShell(NULL), + fWinchRunner(NULL), fFontWidth(0), fFontHeight(0), fFontAscent(0), @@ -1166,42 +1169,7 @@ TermView::_MouseTracking() float scr_start, scr_end, scr_pos; 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) continue; @@ -1211,8 +1179,7 @@ TermView::_MouseTracking() stpos = _BPointToCurPos(stpoint); do { - - snooze(40 * 1000); + snooze(40000); if (LockLooper()) { GetMouse(&edpoint, &button); @@ -2019,19 +1986,8 @@ TermView::MouseDown(BPoint where) Window()->CurrentMessage()->FindInt32("clicks", &clicks); if (_HasSelection()) { - CurPos inPos, stPos, edPos; - if (fSelStart < fSelEnd) { - 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) { + CurPos inPos = _BPointToCurPos(where); + if (_CheckSelectedRegion(inPos)) { if (mod & B_CONTROL_KEY) { BPoint p; uint32 bt; @@ -2043,34 +1999,12 @@ TermView::MouseDown(BPoint where) return; } - snooze(40 * 1000); + snooze(40000); } while (abs((int)(where.x - p.x)) < 4 && abs((int)(where.y - p.y)) < 4); - BString copyStr(""); - 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); + InitiateDrag(); return; } } @@ -2114,6 +2048,7 @@ TermView::MouseDown(BPoint where) BView::MouseDown(where); } + void 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 TermView::_Redraw(int x1, int y1, int x2, int y2) { diff --git a/src/apps/terminal/TermView.h b/src/apps/terminal/TermView.h index a32b7a97a3..8705f26bca 100644 --- a/src/apps/terminal/TermView.h +++ b/src/apps/terminal/TermView.h @@ -42,8 +42,8 @@ public: void SetTermFont(const BFont *halfFont, const BFont *fullFont); void GetFontSize(int *width, int *height); - BRect SetTermSize(int rows, int cols, bool resize); + void SetTextColor(rgb_color fore, rgb_color back); void SetSelectColor(rgb_color fore, rgb_color back); void SetCursorColor(rgb_color fore, rgb_color back); @@ -117,6 +117,8 @@ public: void CheckShellGone(); + void InitiateDrag(); + protected: virtual void AttachedToWindow(); virtual void DetachedFromWindow(); @@ -139,7 +141,7 @@ protected: private: status_t _InitObject(int32 argc, const char **argv); - status_t _InitMouseThread(void); + status_t _InitMouseThread(); status_t _AttachShell(Shell *shell); void _DetachShell(); @@ -164,9 +166,9 @@ private: // void _DoIMChange (BMessage* message); // void _DoIMLocation (BMessage* message); // void _DoIMConfirm (void); - void _ConfirmString (const char *, int32); - int32 _GetCharFromUTF8String (const char *, char *); - int32 _GetWidthFromUTF8String (const char *); + void _ConfirmString(const char *, int32); + int32 _GetCharFromUTF8String(const char *, char *); + int32 _GetWidthFromUTF8String(const char *); // Mouse select void _Select(CurPos start, CurPos end); @@ -186,7 +188,6 @@ private: bool _CheckSelectedRegion(const CurPos &pos); - void _UpdateSIGWINCH(); static void _FixFontAttributes(BFont &font);