Skip to content

Commit

Permalink
Add Copy menu item to the right-click menu
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberShadow committed Dec 23, 2014
1 parent 0dcc947 commit ec519bf
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/wxProfilerGUI/contextmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "contextmenu.h"
#include "mainwin.h"
#include <wx/menu.h>
#include <wx/clipbrd.h>
#include <sstream>

enum {
ID_COLLAPSE_FUNC=2001,
Expand All @@ -35,6 +37,7 @@ enum {
ID_FILTER_SOURCE,
ID_HIGHLIGHT,
ID_UNHIGHLIGHT,
ID_COPY,
};

class FunctionMenuWindow: public wxWindow
Expand All @@ -59,6 +62,7 @@ EVT_MENU(ID_FILTER_MODULE, FunctionMenuWindow::OnMenu)
EVT_MENU(ID_FILTER_SOURCE, FunctionMenuWindow::OnMenu)
EVT_MENU(ID_HIGHLIGHT, FunctionMenuWindow::OnMenu)
EVT_MENU(ID_UNHIGHLIGHT, FunctionMenuWindow::OnMenu)
EVT_MENU(ID_COPY, FunctionMenuWindow::OnMenu)
END_EVENT_TABLE()

void FunctionMenu(wxListCtrl *list, Database *database)
Expand Down Expand Up @@ -97,6 +101,9 @@ void FunctionMenu(wxListCtrl *list, Database *database)
wxString sourcefilename = database->getFileName (sym->sourcefile);
wxString modulename = database->getModuleName(sym->module );

menu->Append(ID_COPY, "&Copy");
menu->AppendSeparator();

if (selection.size() == 1)
{
wxString modUpper = modulename;
Expand All @@ -122,6 +129,30 @@ void FunctionMenu(wxListCtrl *list, Database *database)
funcWindow.PopupMenu(menu);
switch(funcWindow.option)
{
case ID_COPY:
{
std::wstringstream buf;
for (long item = -1;;)
{
item = list->GetNextItem(item,
wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED);
if (item == -1)
break;

for (int col = 0; col < list->GetColumnCount(); col++)
{
if (col)
buf << '\t';
buf << list->GetItemText(item, col);
}
buf << '\n';
}
wxTheClipboard->SetData(new wxTextDataObject(buf.str()));

break;
}

case ID_COLLAPSE_FUNC:
if (IsOsFunction(procname))
RemoveOsFunction(procname);
Expand Down

0 comments on commit ec519bf

Please sign in to comment.