Add option to copy bytes as Go literal
This commit is contained in:
parent
fb21b775b0
commit
4d27035fa6
|
@ -34,6 +34,14 @@ void DataPrinter::toClipboard(DataPrinter::DumpType type, IDataPrintable * print
|
|||
|
||||
switch(type)
|
||||
{
|
||||
case DP_GoLiteral:
|
||||
clipboard_text += QString("[]byte{");
|
||||
for (int i = 0; i < printData.length(); i++) {
|
||||
if (i>0) clipboard_text += ", ";
|
||||
clipboard_text += QString("0x%1").arg((uint8_t) printData[i], 1, 16, QChar('0'));
|
||||
}
|
||||
clipboard_text += QString("}");
|
||||
break;
|
||||
case DP_CString:
|
||||
// Beginning quote
|
||||
clipboard_text += QString("\"");
|
||||
|
@ -239,6 +247,11 @@ QActionGroup * DataPrinter::copyActions(QObject * copyClass, QObject * data)
|
|||
action->setProperty("printertype", DataPrinter::DP_CString);
|
||||
connect(action, &QAction::triggered, dpi, &DataPrinter::copyIDataBytes);
|
||||
|
||||
action = new QAction(tr("…as Go literal"), actions);
|
||||
action->setToolTip(tr("Copy packet bytes as Go literal."));
|
||||
action->setProperty("printertype", DataPrinter::DP_GoLiteral);
|
||||
connect(action, &QAction::triggered, dpi, &DataPrinter::copyIDataBytes);
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
DP_HexOnly,
|
||||
DP_HexStream,
|
||||
DP_CString,
|
||||
DP_GoLiteral,
|
||||
DP_MimeData,
|
||||
DP_Base64
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue