Removed dependency to the global gMouseClipboard from TermView. Now there's

a SetMouseClipboard() method to set one (defaults to be_clipboard, maybe
it's not a good idea and should default to NULL instead).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34178 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2009-11-21 19:12:05 +00:00
parent 752639885a
commit a2ba3d6562
4 changed files with 33 additions and 24 deletions
+2 -2
View File
@@ -167,8 +167,8 @@ AppearancePrefView::MessageReceived(BMessage *msg)
break; break;
case MSG_COLOR_CHANGED: { case MSG_COLOR_CHANGED: {
rgb_color oldColor = PrefHandler::Default()->getRGB( rgb_color oldColor = PrefHandler::Default()->getRGB(
fColorField->Menu()->FindMarked()->Label()); fColorField->Menu()->FindMarked()->Label());
if (oldColor != fColorControl->ValueAsColor()) { if (oldColor != fColorControl->ValueAsColor()) {
PrefHandler::Default()->setRGB( PrefHandler::Default()->setRGB(
fColorField->Menu()->FindMarked()->Label(), fColorField->Menu()->FindMarked()->Label(),
+26 -20
View File
@@ -46,7 +46,6 @@
#include <Window.h> #include <Window.h>
#include "CodeConv.h" #include "CodeConv.h"
#include "Globals.h"
#include "Shell.h" #include "Shell.h"
#include "TermConst.h" #include "TermConst.h"
#include "TerminalCharClassifier.h" #include "TerminalCharClassifier.h"
@@ -165,7 +164,7 @@ private:
TermView::TermView(BRect frame, int32 argc, const char** argv, int32 historySize) 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),
fColumns(COLUMNS_DEFAULT), fColumns(COLUMNS_DEFAULT),
fRows(ROWS_DEFAULT), fRows(ROWS_DEFAULT),
fEncoding(M_UTF8), fEncoding(M_UTF8),
@@ -183,7 +182,7 @@ TermView::TermView(BRect frame, int32 argc, const char** argv, int32 historySize
TermView::TermView(int rows, int columns, int32 argc, const char** argv, TermView::TermView(int rows, int columns, int32 argc, const char** argv,
int32 historySize) int32 historySize)
: 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),
fColumns(columns), fColumns(columns),
fRows(rows), fRows(rows),
fEncoding(M_UTF8), fEncoding(M_UTF8),
@@ -223,8 +222,8 @@ TermView::TermView(BMessage* archive)
fReportButtonMouseEvent(false), fReportButtonMouseEvent(false),
fReportAnyMouseEvent(false) fReportAnyMouseEvent(false)
{ {
// We need this SetFlags(Flags() | B_WILL_DRAW | B_FRAME_EVENTS
SetFlags(Flags() | B_WILL_DRAW | B_PULSE_NEEDED); | B_FULL_UPDATE_ON_RESIZE);
if (archive->FindInt32("encoding", (int32*)&fEncoding) < B_OK) if (archive->FindInt32("encoding", (int32*)&fEncoding) < B_OK)
fEncoding = M_UTF8; fEncoding = M_UTF8;
@@ -232,7 +231,7 @@ TermView::TermView(BMessage* archive)
fColumns = COLUMNS_DEFAULT; fColumns = COLUMNS_DEFAULT;
if (archive->FindInt32("rows", (int32*)&fRows) < B_OK) if (archive->FindInt32("rows", (int32*)&fRows) < B_OK)
fRows = ROWS_DEFAULT; fRows = ROWS_DEFAULT;
int32 argc = 0; int32 argc = 0;
if (archive->HasInt32("argc")) if (archive->HasInt32("argc"))
archive->FindInt32("argc", &argc); archive->FindInt32("argc", &argc);
@@ -244,7 +243,7 @@ TermView::TermView(BMessage* archive)
// TODO: Retrieve colors, history size, etc. from archive // TODO: Retrieve colors, history size, etc. from archive
_InitObject(argc, argv); _InitObject(argc, argv);
delete[] argv; delete[] argv;
} }
@@ -296,6 +295,7 @@ TermView::_InitObject(int32 argc, const char** argv)
fReportNormalMouseEvent = false; fReportNormalMouseEvent = false;
fReportButtonMouseEvent = false; fReportButtonMouseEvent = false;
fReportAnyMouseEvent = false; fReportAnyMouseEvent = false;
fMouseClipboard = be_clipboard;
fTextBuffer = new(std::nothrow) TerminalBuffer; fTextBuffer = new(std::nothrow) TerminalBuffer;
if (fTextBuffer == NULL) if (fTextBuffer == NULL)
@@ -326,8 +326,7 @@ TermView::_InitObject(int32 argc, const char** argv)
SetTermFont(be_fixed_font); SetTermFont(be_fixed_font);
SetTermSize(fRows, fColumns, false); SetTermSize(fRows, fColumns, false);
//SetIMAware(false);
status_t status = fShell->Open(fRows, fColumns, status_t status = fShell->Open(fRows, fColumns,
EncodingAsShortString(fEncoding), argc, argv); EncodingAsShortString(fEncoding), argc, argv);
@@ -365,8 +364,9 @@ TermView::~TermView()
BArchivable * BArchivable *
TermView::Instantiate(BMessage* data) TermView::Instantiate(BMessage* data)
{ {
if (validate_instantiation(data, "TermView")) if (validate_instantiation(data, "TermView")) {
return new (std::nothrow) TermView(data); return new (std::nothrow) TermView(data);
}
return NULL; return NULL;
} }
@@ -577,6 +577,13 @@ TermView::SetEncoding(int encoding)
} }
void
TermView::SetMouseClipboard(BClipboard *clipboard)
{
fMouseClipboard = clipboard;
}
void void
TermView::GetTermFont(BFont *font) const TermView::GetTermFont(BFont *font) const
{ {
@@ -632,9 +639,8 @@ void
TermView::SetScrollBar(BScrollBar *scrollBar) TermView::SetScrollBar(BScrollBar *scrollBar)
{ {
fScrollBar = scrollBar; fScrollBar = scrollBar;
if (fScrollBar != NULL) { if (fScrollBar != NULL)
fScrollBar->SetSteps(fFontHeight, fFontHeight * fRows); fScrollBar->SetSteps(fFontHeight, fFontHeight * fRows);
}
} }
@@ -976,7 +982,7 @@ void
TermView::AttachedToWindow() TermView::AttachedToWindow()
{ {
fMouseButtons = 0; fMouseButtons = 0;
MakeFocus(true); MakeFocus(true);
if (fScrollBar) { if (fScrollBar) {
fScrollBar->SetSteps(fFontHeight, fFontHeight * fRows); fScrollBar->SetSteps(fFontHeight, fFontHeight * fRows);
@@ -1470,19 +1476,19 @@ TermView::MessageReceived(BMessage *msg)
// the contents of the mouse clipboard with the ones from the // the contents of the mouse clipboard with the ones from the
// system clipboard, in case it contains text data. // system clipboard, in case it contains text data.
if (be_clipboard->Lock()) { if (be_clipboard->Lock()) {
if (gMouseClipboard->Lock()) { if (fMouseClipboard->Lock()) {
BMessage* clipMsgA = be_clipboard->Data(); BMessage* clipMsgA = be_clipboard->Data();
const char* text; const char* text;
ssize_t numBytes; ssize_t numBytes;
if (clipMsgA->FindData("text/plain", B_MIME_TYPE, if (clipMsgA->FindData("text/plain", B_MIME_TYPE,
(const void**)&text, &numBytes) == B_OK ) { (const void**)&text, &numBytes) == B_OK ) {
gMouseClipboard->Clear(); fMouseClipboard->Clear();
BMessage* clipMsgB = gMouseClipboard->Data(); BMessage* clipMsgB = fMouseClipboard->Data();
clipMsgB->AddData("text/plain", B_MIME_TYPE, clipMsgB->AddData("text/plain", B_MIME_TYPE,
text, numBytes); text, numBytes);
gMouseClipboard->Commit(); fMouseClipboard->Commit();
} }
gMouseClipboard->Unlock(); fMouseClipboard->Unlock();
} }
be_clipboard->Unlock(); be_clipboard->Unlock();
} }
@@ -2154,7 +2160,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) {
Paste(gMouseClipboard); Paste(fMouseClipboard);
fLastClickPoint = where; fLastClickPoint = where;
return; return;
} }
@@ -2338,7 +2344,7 @@ TermView::MouseUp(BPoint where)
} else { } else {
if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0 if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0
&& (fMouseButtons & B_PRIMARY_MOUSE_BUTTON) != 0) { && (fMouseButtons & B_PRIMARY_MOUSE_BUTTON) != 0) {
Copy(gMouseClipboard); Copy(fMouseClipboard);
} }
} }
+3 -1
View File
@@ -62,10 +62,11 @@ public:
int Encoding() const; int Encoding() const;
void SetEncoding(int encoding); void SetEncoding(int encoding);
//void SetIMAware(bool);
void SetScrollBar(BScrollBar* scrollBar); void SetScrollBar(BScrollBar* scrollBar);
BScrollBar* ScrollBar() const { return fScrollBar; }; BScrollBar* ScrollBar() const { return fScrollBar; };
void SetMouseClipboard(BClipboard *);
virtual void SetTitle(const char* title); virtual void SetTitle(const char* title);
virtual void NotifyQuit(int32 reason); virtual void NotifyQuit(int32 reason);
@@ -266,6 +267,7 @@ private:
bool fReportNormalMouseEvent; bool fReportNormalMouseEvent;
bool fReportButtonMouseEvent; bool fReportButtonMouseEvent;
bool fReportAnyMouseEvent; bool fReportAnyMouseEvent;
BClipboard* fMouseClipboard;
// Input Method parameter. // Input Method parameter.
int fIMViewPtr; int fIMViewPtr;
+2 -1
View File
@@ -32,6 +32,7 @@
#include "AppearPrefView.h" #include "AppearPrefView.h"
#include "Encoding.h" #include "Encoding.h"
#include "FindWindow.h" #include "FindWindow.h"
#include "Globals.h"
#include "PrefWindow.h" #include "PrefWindow.h"
#include "PrefHandler.h" #include "PrefHandler.h"
#include "SmartTabView.h" #include "SmartTabView.h"
@@ -800,7 +801,7 @@ TermWindow::_AddTab(Arguments *args)
// and update the title using the last executed command ? // and update the title using the last executed command ?
// Or like Gnome's Terminal and use the current path ? // Or like Gnome's Terminal and use the current path ?
view->SetScrollBar(scrollView->ScrollBar(B_VERTICAL)); view->SetScrollBar(scrollView->ScrollBar(B_VERTICAL));
view->SetMouseClipboard(gMouseClipboard);
view->SetEncoding(EncodingID( view->SetEncoding(EncodingID(
PrefHandler::Default()->getString(PREF_TEXT_ENCODING))); PrefHandler::Default()->getString(PREF_TEXT_ENCODING)));