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.
This commit is contained in:
committed by
Rene Gollent
parent
2f605e9fd7
commit
473a74f72e
@@ -1,19 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
* Copyright 2011-2013, Rene Gollent, [email protected].
|
* Copyright 2011-2014, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "VariablesView.h"
|
#include "VariablesView.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <debugger.h>
|
#include <debugger.h>
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
#include <Clipboard.h>
|
||||||
#include <Looper.h>
|
#include <Looper.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
#include <ToolTip.h>
|
#include <ToolTip.h>
|
||||||
@@ -1822,6 +1821,11 @@ VariablesView::MessageReceived(BMessage* message)
|
|||||||
fVariableTableModel->NotifyNodeChanged(node);
|
fVariableTableModel->NotifyNodeChanged(node);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case B_COPY:
|
||||||
|
{
|
||||||
|
_CopyVariableValueToClipboard();
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
BGroupView::MessageReceived(message);
|
BGroupView::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
@@ -2084,6 +2088,15 @@ VariablesView::_GetContextActionsForNode(ModelNode* node,
|
|||||||
if (valueNode == NULL)
|
if (valueNode == NULL)
|
||||||
return B_OK;
|
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 (!valueNode->IsRangedContainer()) {
|
||||||
if (node->CountChildren() == 1 && node->ChildAt(0)->IsHidden()) {
|
if (node->CountChildren() == 1 && node->ChildAt(0)->IsHidden()) {
|
||||||
valueNode = node->ChildAt(0)->NodeChild()->Node();
|
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
|
// #pragma mark - Listener
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
* Copyright 2012, Rene Gollent, [email protected].
|
* Copyright 2012-2014, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef VARIABLES_VIEW_H
|
#ifndef VARIABLES_VIEW_H
|
||||||
@@ -86,6 +86,7 @@ private:
|
|||||||
status_t _ApplyViewStateDescendentNodeInfos(
|
status_t _ApplyViewStateDescendentNodeInfos(
|
||||||
VariablesViewState* viewState, void* parent,
|
VariablesViewState* viewState, void* parent,
|
||||||
TreeTablePath& path);
|
TreeTablePath& path);
|
||||||
|
void _CopyVariableValueToClipboard();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Thread* fThread;
|
Thread* fThread;
|
||||||
|
|||||||
Reference in New Issue
Block a user