[haiku-commits] haiku: hrev47440 - src/apps/debugger/user_interface/gui/team_window

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 29 Jun 2014 01:49:52 +0200 (CEST)

hrev47440 adds 2 changesets to branch 'master'
old head: 632843911c19a1c1f68239b3cf886f21a15918dd
new head: 473a74f72e6580b2c7cbe5a3e748cb4916a039f6
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=473a74f+%5E6328439

----------------------------------------------------------------------------

2f605e9: TeamWindow: Fix accidental double message sending.
  
  - When we explicitly handle sending B_COPY/B_SELECT_ALL, don't
    then pass control back to BWindow::DispatchMessage(), as that will
    wind up sending the message to the target view twice.

                                         [ Rene Gollent <rene@xxxxxxxxxxx> ]

473a74f: Debugger: Add support for copying variable values.
  
  - Implements a simple copy option in the variables context menu that
    allows one to copy the displayed value to the clipboard.

                                      [ Rene Gollent <anevilyak@xxxxxxxxx> ]

----------------------------------------------------------------------------

3 files changed, 41 insertions(+), 5 deletions(-)
.../gui/team_window/TeamWindow.cpp               |  4 +-
.../gui/team_window/VariablesView.cpp            | 39 ++++++++++++++++++--
.../gui/team_window/VariablesView.h              |  3 +-

############################################################################

Commit:      2f605e9fd7440ed162317844cca61dc8540da5d0
URL:         http://cgit.haiku-os.org/haiku/commit/?id=2f605e9
Author:      Rene Gollent <rene@xxxxxxxxxxx>
Date:        Sat Jun 28 23:40:01 2014 UTC

TeamWindow: Fix accidental double message sending.

- When we explicitly handle sending B_COPY/B_SELECT_ALL, don't
  then pass control back to BWindow::DispatchMessage(), as that will
  wind up sending the message to the target view twice.

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp 
b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
index 22baa3b..a32a69b 100644
--- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
+++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
@@ -236,8 +236,10 @@ TeamWindow::DispatchMessage(BMessage* message, BHandler* 
handler)
                case B_COPY:
                case B_SELECT_ALL:
                        BView* focusView = CurrentFocus();
-                       if (focusView != NULL)
+                       if (focusView != NULL) {
                                focusView->MessageReceived(message);
+                               return;
+                       }
                        break;
        }
        BWindow::DispatchMessage(message, handler);

############################################################################

Revision:    hrev47440
Commit:      473a74f72e6580b2c7cbe5a3e748cb4916a039f6
URL:         http://cgit.haiku-os.org/haiku/commit/?id=473a74f
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Mon Apr 29 00:17:08 2013 UTC
Committer:   Rene Gollent <rene@xxxxxxxxxxx>
Commit-Date: Sat Jun 28 23:47:27 2014 UTC

Debugger: Add support for copying variable values.

- Implements a simple copy option in the variables context menu that
  allows one to copy the displayed value to the clipboard.

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp 
b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
index 5d75846..0f62ede 100644
--- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
+++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
@@ -1,19 +1,18 @@
 /*
  * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx.
- * Copyright 2011-2013, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2011-2014, Rene Gollent, rene@xxxxxxxxxxx.
  * Distributed under the terms of the MIT License.
  */
 
 
 #include "VariablesView.h"
 
-#include <stdio.h>
-
 #include <new>
 
 #include <debugger.h>
 
 #include <Alert.h>
+#include <Clipboard.h>
 #include <Looper.h>
 #include <PopUpMenu.h>
 #include <ToolTip.h>
@@ -1822,6 +1821,11 @@ VariablesView::MessageReceived(BMessage* message)
                        fVariableTableModel->NotifyNodeChanged(node);
                        break;
                }
+               case B_COPY:
+               {
+                       _CopyVariableValueToClipboard();
+                       break;
+               }
                default:
                        BGroupView::MessageReceived(message);
                        break;
@@ -2084,6 +2088,15 @@ VariablesView::_GetContextActionsForNode(ModelNode* node,
        if (valueNode == NULL)
                return B_OK;
 
+       if (valueNode->LocationAndValueResolutionState() == B_OK) {
+               result = _AddContextAction("Copy Value", B_COPY, actions, 
message);
+               if (result != B_OK)
+                       return result;
+       }
+
+       // if the current node isn't itself a ranged container, check if it
+       // contains a hidden node which is, since in the latter case we
+       // want to present the range selection as well.
        if (!valueNode->IsRangedContainer()) {
                if (node->CountChildren() == 1 && node->ChildAt(0)->IsHidden()) 
{
                        valueNode = node->ChildAt(0)->NodeChild()->Node();
@@ -2296,6 +2309,26 @@ 
VariablesView::_ApplyViewStateDescendentNodeInfos(VariablesViewState* viewState,
 }
 
 
+void
+VariablesView::_CopyVariableValueToClipboard()
+{
+       ModelNode* node = reinterpret_cast<ModelNode*>(
+               fVariableTable->SelectionModel()->NodeAt(0));
+
+       Value* value = node->GetValue();
+       BString valueData;
+       if (value != NULL && value->ToString(valueData)) {
+               be_clipboard->Lock();
+               be_clipboard->Data()->RemoveData("text/plain");
+               be_clipboard->Data()->AddData ("text/plain",
+                       B_MIME_TYPE, valueData.String(),
+                       valueData.Length());
+               be_clipboard->Commit();
+               be_clipboard->Unlock();
+       }
+}
+
+
 // #pragma mark - Listener
 
 
diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h 
b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h
index 9db6c3b..83583f4 100644
--- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h
+++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h
@@ -1,6 +1,6 @@
 /*
  * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx.
- * Copyright 2012, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2012-2014, Rene Gollent, rene@xxxxxxxxxxx.
  * Distributed under the terms of the MIT License.
  */
 #ifndef VARIABLES_VIEW_H
@@ -86,6 +86,7 @@ private:
                        status_t                        
_ApplyViewStateDescendentNodeInfos(
                                                                        
VariablesViewState* viewState, void* parent,
                                                                        
TreeTablePath& path);
+                       void                            
_CopyVariableValueToClipboard();
 
 private:
                        Thread*                         fThread;


Other related posts:

  • » [haiku-commits] haiku: hrev47440 - src/apps/debugger/user_interface/gui/team_window - anevilyak