debugger: Muti-byte hex strings can now be pasted into the memory view. (#2960)

You can now paste a hex string into the memory view (with Ctrl+V).
This commit is contained in:
Thomas Evans 2019-06-01 12:30:03 +01:00 committed by lightningterror
parent fbafd44209
commit 1f1b68a9b4
3 changed files with 45 additions and 0 deletions

View File

@ -32,6 +32,7 @@ memory view:
right click open context menu
ctrl+wheel zoom memory view
esc return to previous goto address
ctrl+v paste a hex string into memory
breakpoint list:

View File

@ -489,6 +489,10 @@ void CtrlMemView::keydownEvent(wxKeyEvent& evt)
}
}
break;
case 'v':
case 'V':
pasteHex();
break;
default:
evt.Skip();
break;
@ -729,3 +733,42 @@ void CtrlMemView::updateReference(u32 address) {
referencedAddress = address;
redraw();
}
void CtrlMemView::pasteHex()
{
if (wxTheClipboard->Open())
{
if (wxTheClipboard->IsSupported(wxDF_TEXT))
{
wxTextDataObject data;
wxTheClipboard->GetData(data);
wxString str = data.GetText();
str.Replace(" ", "");
str.Replace("\n", "");
str.Replace("\r", "");
str.Replace("\t", "");
bool active = !cpu->isCpuPaused();
if (active)
cpu->pauseCpu();
std::size_t i;
for (i = 0; i < str.size() / 2; i++)
{
long byte;
if (str.Mid(i * 2, 2).ToLong(&byte, 16))
{
cpu->write8(curAddress + i, static_cast<u8>(byte));
}
else {
break;
}
}
scrollCursor(i);
if(active)
cpu->resumeCpu();
}
wxTheClipboard->Close();
}
}

View File

@ -46,6 +46,7 @@ private:
void scrollCursor(int bytes);
void onPopupClick(wxCommandEvent& evt);
void focusEvent(wxFocusEvent& evt) { Refresh(); };
void pasteHex();
DebugInterface* cpu;
int rowHeight;