[haiku-commits] r34178 - haiku/trunk/src/apps/terminal

  • From: stefano.ceccherini@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 21 Nov 2009 20:12:05 +0100 (CET)

Author: jackburton
Date: 2009-11-21 20:12:05 +0100 (Sat, 21 Nov 2009)
New Revision: 34178
Changeset: http://dev.haiku-os.org/changeset/34178/haiku

Modified:
   haiku/trunk/src/apps/terminal/AppearPrefView.cpp
   haiku/trunk/src/apps/terminal/TermView.cpp
   haiku/trunk/src/apps/terminal/TermView.h
   haiku/trunk/src/apps/terminal/TermWindow.cpp
Log:
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).


Modified: haiku/trunk/src/apps/terminal/AppearPrefView.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/AppearPrefView.cpp    2009-11-21 18:13:06 UTC 
(rev 34177)
+++ haiku/trunk/src/apps/terminal/AppearPrefView.cpp    2009-11-21 19:12:05 UTC 
(rev 34178)
@@ -167,8 +167,8 @@
                        break;
 
                case MSG_COLOR_CHANGED: {
-                               rgb_color oldColor = 
PrefHandler::Default()->getRGB(
-                                       
fColorField->Menu()->FindMarked()->Label());
+                       rgb_color oldColor = PrefHandler::Default()->getRGB(
+                               fColorField->Menu()->FindMarked()->Label());
                                if (oldColor != fColorControl->ValueAsColor()) {
                                        PrefHandler::Default()->setRGB(
                                                
fColorField->Menu()->FindMarked()->Label(),

Modified: haiku/trunk/src/apps/terminal/TermView.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermView.cpp  2009-11-21 18:13:06 UTC (rev 
34177)
+++ haiku/trunk/src/apps/terminal/TermView.cpp  2009-11-21 19:12:05 UTC (rev 
34178)
@@ -46,7 +46,6 @@
 #include <Window.h>
 
 #include "CodeConv.h"
-#include "Globals.h"
 #include "Shell.h"
 #include "TermConst.h"
 #include "TerminalCharClassifier.h"
@@ -165,7 +164,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),
+               B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE),
        fColumns(COLUMNS_DEFAULT),
        fRows(ROWS_DEFAULT),
        fEncoding(M_UTF8),
@@ -183,7 +182,7 @@
 TermView::TermView(int rows, int columns, int32 argc, const char** argv,
                int32 historySize)
        : 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),
        fRows(rows),
        fEncoding(M_UTF8),
@@ -223,8 +222,8 @@
        fReportButtonMouseEvent(false),
        fReportAnyMouseEvent(false)
 {
-       // We need this
-       SetFlags(Flags() | B_WILL_DRAW | B_PULSE_NEEDED);
+       SetFlags(Flags() | B_WILL_DRAW | B_FRAME_EVENTS
+               | B_FULL_UPDATE_ON_RESIZE);
 
        if (archive->FindInt32("encoding", (int32*)&fEncoding) < B_OK)
                fEncoding = M_UTF8;
@@ -232,7 +231,7 @@
                fColumns = COLUMNS_DEFAULT;
        if (archive->FindInt32("rows", (int32*)&fRows) < B_OK)
                fRows = ROWS_DEFAULT;
-
+       
        int32 argc = 0;
        if (archive->HasInt32("argc"))
                archive->FindInt32("argc", &argc);
@@ -244,7 +243,7 @@
 
        // TODO: Retrieve colors, history size, etc. from archive
        _InitObject(argc, argv);
-
+       
        delete[] argv;
 }
 
@@ -296,6 +295,7 @@
        fReportNormalMouseEvent = false;
        fReportButtonMouseEvent = false;
        fReportAnyMouseEvent = false;
+       fMouseClipboard = be_clipboard;
 
        fTextBuffer = new(std::nothrow) TerminalBuffer;
        if (fTextBuffer == NULL)
@@ -326,8 +326,7 @@
 
        SetTermFont(be_fixed_font);
        SetTermSize(fRows, fColumns, false);
-       //SetIMAware(false);
-
+       
        status_t status = fShell->Open(fRows, fColumns,
                EncodingAsShortString(fEncoding), argc, argv);
 
@@ -365,8 +364,9 @@
 BArchivable *
 TermView::Instantiate(BMessage* data)
 {
-       if (validate_instantiation(data, "TermView"))
+       if (validate_instantiation(data, "TermView")) {
                return new (std::nothrow) TermView(data);
+       }
 
        return NULL;
 }
@@ -578,6 +578,13 @@
 
 
 void
+TermView::SetMouseClipboard(BClipboard *clipboard)
+{
+       fMouseClipboard = clipboard;
+}
+       
+       
+void
 TermView::GetTermFont(BFont *font) const
 {
        if (font != NULL)
@@ -632,9 +639,8 @@
 TermView::SetScrollBar(BScrollBar *scrollBar)
 {
        fScrollBar = scrollBar;
-       if (fScrollBar != NULL) {
+       if (fScrollBar != NULL)
                fScrollBar->SetSteps(fFontHeight, fFontHeight * fRows);
-       }
 }
 
 
@@ -976,7 +982,7 @@
 TermView::AttachedToWindow()
 {
        fMouseButtons = 0;
-
+               
        MakeFocus(true);
        if (fScrollBar) {
                fScrollBar->SetSteps(fFontHeight, fFontHeight * fRows);
@@ -1470,19 +1476,19 @@
                        // the contents of the mouse clipboard with the ones 
from the
                        // system clipboard, in case it contains text data.
                        if (be_clipboard->Lock()) {
-                               if (gMouseClipboard->Lock()) {
+                               if (fMouseClipboard->Lock()) {
                                        BMessage* clipMsgA = 
be_clipboard->Data();
                                        const char* text;
                                        ssize_t numBytes;
                                        if (clipMsgA->FindData("text/plain", 
B_MIME_TYPE,
                                                        (const void**)&text, 
&numBytes) == B_OK ) {
-                                               gMouseClipboard->Clear();
-                                               BMessage* clipMsgB = 
gMouseClipboard->Data();
+                                               fMouseClipboard->Clear();
+                                               BMessage* clipMsgB = 
fMouseClipboard->Data();
                                                clipMsgB->AddData("text/plain", 
B_MIME_TYPE,
                                                        text, numBytes);
-                                               gMouseClipboard->Commit();
+                                               fMouseClipboard->Commit();
                                        }
-                                       gMouseClipboard->Unlock();
+                                       fMouseClipboard->Unlock();
                                }
                                be_clipboard->Unlock();
                        }
@@ -2154,7 +2160,7 @@
 
        // paste button
        if ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 
0) {
-               Paste(gMouseClipboard);
+               Paste(fMouseClipboard);
                fLastClickPoint = where;
                return;
        }
@@ -2338,7 +2344,7 @@
        } else {
                if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0
                        && (fMouseButtons & B_PRIMARY_MOUSE_BUTTON) != 0) {
-                       Copy(gMouseClipboard);
+                       Copy(fMouseClipboard);
                }
 
        }

Modified: haiku/trunk/src/apps/terminal/TermView.h
===================================================================
--- haiku/trunk/src/apps/terminal/TermView.h    2009-11-21 18:13:06 UTC (rev 
34177)
+++ haiku/trunk/src/apps/terminal/TermView.h    2009-11-21 19:12:05 UTC (rev 
34178)
@@ -62,10 +62,11 @@
                        int                             Encoding() const;
                        void                    SetEncoding(int encoding);
 
-                       //void                  SetIMAware(bool);
                        void                    SetScrollBar(BScrollBar* 
scrollBar);
                        BScrollBar*             ScrollBar() const { return 
fScrollBar; };
 
+                       void                    SetMouseClipboard(BClipboard *);
+                       
        virtual void                    SetTitle(const char* title);
        virtual void                    NotifyQuit(int32 reason);
 
@@ -266,6 +267,7 @@
                        bool                    fReportNormalMouseEvent;
                        bool                    fReportButtonMouseEvent;
                        bool                    fReportAnyMouseEvent;
+                       BClipboard*             fMouseClipboard;
 
                        // Input Method parameter.
                        int                             fIMViewPtr;

Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermWindow.cpp        2009-11-21 18:13:06 UTC 
(rev 34177)
+++ haiku/trunk/src/apps/terminal/TermWindow.cpp        2009-11-21 19:12:05 UTC 
(rev 34178)
@@ -32,6 +32,7 @@
 #include "AppearPrefView.h"
 #include "Encoding.h"
 #include "FindWindow.h"
+#include "Globals.h"
 #include "PrefWindow.h"
 #include "PrefHandler.h"
 #include "SmartTabView.h"
@@ -800,7 +801,7 @@
                        // and update the title using the last executed command 
?
                        // Or like Gnome's Terminal and use the current path ?
                view->SetScrollBar(scrollView->ScrollBar(B_VERTICAL));
-
+               view->SetMouseClipboard(gMouseClipboard);
                view->SetEncoding(EncodingID(
                        PrefHandler::Default()->getString(PREF_TEXT_ENCODING)));
 


Other related posts:

  • » [haiku-commits] r34178 - haiku/trunk/src/apps/terminal - stefano . ceccherini