Debugger: Reworked "Code" menu and enabled it on Linux, fixed issues where some shortcuts didn't work (e.g Mark As...)

This commit is contained in:
Sour 2018-12-16 13:58:33 -05:00
parent c54fad0325
commit 0b7660a3fa
5 changed files with 171 additions and 119 deletions

View file

@ -257,18 +257,20 @@ namespace Mesen.GUI.Config
} }
} }
private static void ClearProcessCmdKeyHandler(ToolStripMenuItem item, Control parent) public static void ClearProcessCmdKeyHandler(ToolStripMenuItem item, Control parent)
{ {
Form parentForm = parent.FindForm(); Form parentForm = parent.FindForm();
if(parentForm is BaseForm) { if(parentForm is BaseForm) {
(parentForm as BaseForm).OnProcessCmdKey -= (ProcessCmdKeyHandler)item.Tag; (parentForm as BaseForm).OnProcessCmdKey -= ((ShortcutInfo)item.Tag).KeyHandler;
} }
item.Tag = null; ((ShortcutInfo)item.Tag).KeyHandler = null;
} }
public static void UpdateShortcutItem(ToolStripMenuItem item, Control parent, string fieldName) public static void UpdateShortcutItem(ToolStripMenuItem item, Control parent, string fieldName)
{ {
if(item.Tag is ProcessCmdKeyHandler) { if(item.Tag == null) {
item.Tag = new ShortcutInfo() { KeyHandler = null, ShortcutKey = fieldName };
} else if(((ShortcutInfo)item.Tag).KeyHandler != null) {
ClearProcessCmdKeyHandler(item, parent); ClearProcessCmdKeyHandler(item, parent);
} }
@ -288,7 +290,7 @@ namespace Mesen.GUI.Config
return false; return false;
}; };
item.Tag = onProcessCmdKeyHandler; ((ShortcutInfo)item.Tag).KeyHandler = onProcessCmdKeyHandler;
(parentForm as BaseForm).OnProcessCmdKey += onProcessCmdKeyHandler; (parentForm as BaseForm).OnProcessCmdKey += onProcessCmdKeyHandler;
} }
} else { } else {
@ -307,6 +309,12 @@ namespace Mesen.GUI.Config
} }
} }
public class ShortcutInfo
{
public string ShortcutKey;
public ProcessCmdKeyHandler KeyHandler;
}
public class XmlKeys public class XmlKeys
{ {
private Keys _keys = Keys.None; private Keys _keys = Keys.None;

View file

@ -140,7 +140,7 @@ namespace Mesen.GUI.Debugger.Controls
private void contextMenuCode_Opening(object sender, CancelEventArgs e) private void contextMenuCode_Opening(object sender, CancelEventArgs e)
{ {
UpdateContextMenuItemVisibility(true); UpdateContextMenuItemVisibility(contextMenu.Items, true);
int startAddress, endAddress; int startAddress, endAddress;
string range; string range;
@ -413,48 +413,38 @@ namespace Mesen.GUI.Debugger.Controls
mnuEditSubroutine.Enabled = true; mnuEditSubroutine.Enabled = true;
} }
public void UpdateContextMenuItemVisibility(bool? visible = null) public void UpdateContextMenuItemVisibility(ToolStripItemCollection items, bool? visible = null)
{ {
mnuUndoPrgChrEdit.Enabled = InteropEmu.DebugHasUndoHistory(); items[nameof(mnuUndoPrgChrEdit)].Enabled = InteropEmu.DebugHasUndoHistory();
mnuShowNextStatement.Enabled = Viewer.ActiveAddress.HasValue; items[nameof(mnuShowNextStatement)].Enabled = Viewer.ActiveAddress.HasValue;
mnuSetNextStatement.Enabled = Viewer.ActiveAddress.HasValue; items[nameof(mnuSetNextStatement)].Enabled = Viewer.ActiveAddress.HasValue;
mnuEditSelectedCode.Enabled = mnuEditSubroutine.Enabled = InteropEmu.DebugIsExecutionStopped() && Viewer.CodeViewer.CurrentLine >= 0; items[nameof(mnuEditSelectedCode)].Enabled = items[nameof(mnuEditSubroutine)].Enabled = InteropEmu.DebugIsExecutionStopped() && Viewer.CodeViewer.CurrentLine >= 0;
if(visible.HasValue) {
mnuAddToWatch.Visible = visible.Value;
mnuEditLabel.Visible = visible.Value;
mnuGoToLocation.Visible = visible.Value;
mnuToggleBreakpoint.Visible = visible.Value;
sepAddToWatch.Visible = visible.Value;
sepEditLabel.Visible = visible.Value;
mnuFindOccurrences.Visible = visible.Value;
}
if(SourceView) { if(SourceView) {
mnuMarkSelectionAs.Visible = false; items[nameof(mnuMarkSelectionAs)].Visible = false;
mnuShowCodeNotes.Visible = false; items[nameof(mnuShowCodeNotes)].Visible = false;
mnuFindOccurrences.Visible = false; items[nameof(mnuFindOccurrences)].Visible = false;
mnuEditSubroutine.Visible = false; items[nameof(mnuEditSubroutine)].Visible = false;
mnuEditSelectedCode.Visible = false; items[nameof(mnuEditSelectedCode)].Visible = false;
mnuNavigateForward.Visible = false; items[nameof(mnuNavigateForward)].Visible = false;
mnuNavigateBackward.Visible = false; items[nameof(mnuNavigateBackward)].Visible = false;
mnuEditLabel.Visible = false; items[nameof(mnuEditLabel)].Visible = false;
sepNavigation.Visible = false; items[nameof(sepNavigation)].Visible = false;
mnuShowSourceAsComments.Visible = false; items[nameof(mnuShowSourceAsComments)].Visible = false;
} }
bool hasSymbolProvider = Viewer.SymbolProvider != null; bool hasSymbolProvider = Viewer.SymbolProvider != null;
mnuShowSourceAsComments.Visible = hasSymbolProvider; items[nameof(mnuShowSourceAsComments)].Visible = hasSymbolProvider;
mnuSwitchView.Visible = hasSymbolProvider; items[nameof(mnuSwitchView)].Visible = hasSymbolProvider;
sepSwitchView.Visible = hasSymbolProvider; items[nameof(sepSwitchView)].Visible = hasSymbolProvider;
} }
private bool UpdateContextMenu(Point mouseLocation) private bool UpdateContextMenu(Point mouseLocation)
{ {
_lastLocation = mouseLocation; _lastLocation = mouseLocation;
UpdateContextMenuItemVisibility(true); UpdateContextMenuItemVisibility(contextMenu.Items, true);
mnuSwitchView.Text = SourceView ? "Switch to Disassembly View" : "Switch to Source View"; mnuSwitchView.Text = SourceView ? "Switch to Disassembly View" : "Switch to Source View";

View file

@ -246,7 +246,7 @@ namespace Mesen.GUI.Debugger
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{ {
_codeViewerActions.UpdateContextMenuItemVisibility(); _codeViewerActions.UpdateContextMenuItemVisibility(_codeViewerActions.contextMenu.Items);
return base.ProcessCmdKey(ref msg, keyData); return base.ProcessCmdKey(ref msg, keyData);
} }

View file

@ -167,6 +167,8 @@ namespace Mesen.GUI.Debugger
this.mnuSplitView = new System.Windows.Forms.ToolStripMenuItem(); this.mnuSplitView = new System.Windows.Forms.ToolStripMenuItem();
this.mnuUseVerticalLayout = new System.Windows.Forms.ToolStripMenuItem(); this.mnuUseVerticalLayout = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem11 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem11 = new System.Windows.Forms.ToolStripSeparator();
this.mnuAutoCreateJumpLabels = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem25 = new System.Windows.Forms.ToolStripSeparator();
this.mnuHidePauseIcon = new System.Windows.Forms.ToolStripMenuItem(); this.mnuHidePauseIcon = new System.Windows.Forms.ToolStripMenuItem();
this.mnuPpuPartialDraw = new System.Windows.Forms.ToolStripMenuItem(); this.mnuPpuPartialDraw = new System.Windows.Forms.ToolStripMenuItem();
this.mnuPpuShowPreviousFrame = new System.Windows.Forms.ToolStripMenuItem(); this.mnuPpuShowPreviousFrame = new System.Windows.Forms.ToolStripMenuItem();
@ -208,8 +210,6 @@ namespace Mesen.GUI.Debugger
this.ctrlPpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping(); this.ctrlPpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping();
this.ctrlCpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping(); this.ctrlCpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping();
this.tsToolbar = new Mesen.GUI.Controls.ctrlMesenToolStrip(); this.tsToolbar = new Mesen.GUI.Controls.ctrlMesenToolStrip();
this.mnuAutoCreateJumpLabels = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem25 = new System.Windows.Forms.ToolStripSeparator();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout(); this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout(); this.splitContainer.Panel2.SuspendLayout();
@ -254,7 +254,7 @@ namespace Mesen.GUI.Debugger
this.splitContainer.Panel2.Controls.Add(this.tableLayoutPanel10); this.splitContainer.Panel2.Controls.Add(this.tableLayoutPanel10);
this.splitContainer.Panel2MinSize = 100; this.splitContainer.Panel2MinSize = 100;
this.splitContainer.Size = new System.Drawing.Size(1075, 570); this.splitContainer.Size = new System.Drawing.Size(1075, 570);
this.splitContainer.SplitterDistance = 411; this.splitContainer.SplitterDistance = 425;
this.splitContainer.SplitterWidth = 7; this.splitContainer.SplitterWidth = 7;
this.splitContainer.TabIndex = 1; this.splitContainer.TabIndex = 1;
this.splitContainer.TabStop = false; this.splitContainer.TabStop = false;
@ -278,7 +278,7 @@ namespace Mesen.GUI.Debugger
// //
this.ctrlSplitContainerTop.Panel2.Controls.Add(this.tlpFunctionLabelLists); this.ctrlSplitContainerTop.Panel2.Controls.Add(this.tlpFunctionLabelLists);
this.ctrlSplitContainerTop.Panel2MinSize = 150; this.ctrlSplitContainerTop.Panel2MinSize = 150;
this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1075, 411); this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1075, 425);
this.ctrlSplitContainerTop.SplitterDistance = 750; this.ctrlSplitContainerTop.SplitterDistance = 750;
this.ctrlSplitContainerTop.SplitterWidth = 7; this.ctrlSplitContainerTop.SplitterWidth = 7;
this.ctrlSplitContainerTop.TabIndex = 3; this.ctrlSplitContainerTop.TabIndex = 3;
@ -299,8 +299,8 @@ namespace Mesen.GUI.Debugger
this.tlpTop.Name = "tlpTop"; this.tlpTop.Name = "tlpTop";
this.tlpTop.RowCount = 1; this.tlpTop.RowCount = 1;
this.tlpTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tlpTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tlpTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 411F)); this.tlpTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 408F));
this.tlpTop.Size = new System.Drawing.Size(750, 411); this.tlpTop.Size = new System.Drawing.Size(750, 425);
this.tlpTop.TabIndex = 2; this.tlpTop.TabIndex = 2;
// //
// panel1 // panel1
@ -311,7 +311,7 @@ namespace Mesen.GUI.Debugger
this.panel1.Location = new System.Drawing.Point(3, 0); this.panel1.Location = new System.Drawing.Point(3, 0);
this.panel1.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0); this.panel1.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(286, 411); this.panel1.Size = new System.Drawing.Size(286, 425);
this.panel1.TabIndex = 5; this.panel1.TabIndex = 5;
// //
// ctrlSourceViewer // ctrlSourceViewer
@ -320,7 +320,7 @@ namespace Mesen.GUI.Debugger
this.ctrlSourceViewer.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlSourceViewer.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlSourceViewer.Location = new System.Drawing.Point(0, 0); this.ctrlSourceViewer.Location = new System.Drawing.Point(0, 0);
this.ctrlSourceViewer.Name = "ctrlSourceViewer"; this.ctrlSourceViewer.Name = "ctrlSourceViewer";
this.ctrlSourceViewer.Size = new System.Drawing.Size(286, 411); this.ctrlSourceViewer.Size = new System.Drawing.Size(286, 425);
this.ctrlSourceViewer.SymbolProvider = null; this.ctrlSourceViewer.SymbolProvider = null;
this.ctrlSourceViewer.TabIndex = 7; this.ctrlSourceViewer.TabIndex = 7;
this.ctrlSourceViewer.Visible = false; this.ctrlSourceViewer.Visible = false;
@ -333,7 +333,7 @@ namespace Mesen.GUI.Debugger
this.ctrlDebuggerCode.Location = new System.Drawing.Point(0, 0); this.ctrlDebuggerCode.Location = new System.Drawing.Point(0, 0);
this.ctrlDebuggerCode.Name = "ctrlDebuggerCode"; this.ctrlDebuggerCode.Name = "ctrlDebuggerCode";
this.ctrlDebuggerCode.ShowMemoryValues = false; this.ctrlDebuggerCode.ShowMemoryValues = false;
this.ctrlDebuggerCode.Size = new System.Drawing.Size(286, 411); this.ctrlDebuggerCode.Size = new System.Drawing.Size(286, 425);
this.ctrlDebuggerCode.SymbolProvider = null; this.ctrlDebuggerCode.SymbolProvider = null;
this.ctrlDebuggerCode.TabIndex = 2; this.ctrlDebuggerCode.TabIndex = 2;
this.ctrlDebuggerCode.OnEditCode += new Mesen.GUI.Debugger.ctrlDebuggerCode.AssemblerEventHandler(this.ctrlDebuggerCode_OnEditCode); this.ctrlDebuggerCode.OnEditCode += new Mesen.GUI.Debugger.ctrlDebuggerCode.AssemblerEventHandler(this.ctrlDebuggerCode_OnEditCode);
@ -347,7 +347,7 @@ namespace Mesen.GUI.Debugger
this.panel2.Location = new System.Drawing.Point(292, 0); this.panel2.Location = new System.Drawing.Point(292, 0);
this.panel2.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0); this.panel2.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.panel2.Name = "panel2"; this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1, 411); this.panel2.Size = new System.Drawing.Size(1, 425);
this.panel2.TabIndex = 6; this.panel2.TabIndex = 6;
// //
// ctrlSourceViewerSplit // ctrlSourceViewerSplit
@ -356,7 +356,7 @@ namespace Mesen.GUI.Debugger
this.ctrlSourceViewerSplit.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlSourceViewerSplit.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlSourceViewerSplit.Location = new System.Drawing.Point(0, 0); this.ctrlSourceViewerSplit.Location = new System.Drawing.Point(0, 0);
this.ctrlSourceViewerSplit.Name = "ctrlSourceViewerSplit"; this.ctrlSourceViewerSplit.Name = "ctrlSourceViewerSplit";
this.ctrlSourceViewerSplit.Size = new System.Drawing.Size(1, 411); this.ctrlSourceViewerSplit.Size = new System.Drawing.Size(1, 425);
this.ctrlSourceViewerSplit.SymbolProvider = null; this.ctrlSourceViewerSplit.SymbolProvider = null;
this.ctrlSourceViewerSplit.TabIndex = 8; this.ctrlSourceViewerSplit.TabIndex = 8;
this.ctrlSourceViewerSplit.Visible = false; this.ctrlSourceViewerSplit.Visible = false;
@ -369,7 +369,7 @@ namespace Mesen.GUI.Debugger
this.ctrlDebuggerCodeSplit.Location = new System.Drawing.Point(0, 0); this.ctrlDebuggerCodeSplit.Location = new System.Drawing.Point(0, 0);
this.ctrlDebuggerCodeSplit.Name = "ctrlDebuggerCodeSplit"; this.ctrlDebuggerCodeSplit.Name = "ctrlDebuggerCodeSplit";
this.ctrlDebuggerCodeSplit.ShowMemoryValues = false; this.ctrlDebuggerCodeSplit.ShowMemoryValues = false;
this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 411); this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 425);
this.ctrlDebuggerCodeSplit.SymbolProvider = null; this.ctrlDebuggerCodeSplit.SymbolProvider = null;
this.ctrlDebuggerCodeSplit.TabIndex = 4; this.ctrlDebuggerCodeSplit.TabIndex = 4;
this.ctrlDebuggerCodeSplit.Visible = false; this.ctrlDebuggerCodeSplit.Visible = false;
@ -389,7 +389,7 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel1.RowCount = 2; this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(458, 411); this.tableLayoutPanel1.Size = new System.Drawing.Size(458, 425);
this.tableLayoutPanel1.TabIndex = 7; this.tableLayoutPanel1.TabIndex = 7;
// //
// ctrlConsoleStatus // ctrlConsoleStatus
@ -413,7 +413,7 @@ namespace Mesen.GUI.Debugger
this.tlpVerticalLayout.Name = "tlpVerticalLayout"; this.tlpVerticalLayout.Name = "tlpVerticalLayout";
this.tlpVerticalLayout.RowCount = 1; this.tlpVerticalLayout.RowCount = 1;
this.tlpVerticalLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tlpVerticalLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tlpVerticalLayout.Size = new System.Drawing.Size(458, 11); this.tlpVerticalLayout.Size = new System.Drawing.Size(458, 25);
this.tlpVerticalLayout.TabIndex = 4; this.tlpVerticalLayout.TabIndex = 4;
// //
// tlpFunctionLabelLists // tlpFunctionLabelLists
@ -429,16 +429,16 @@ namespace Mesen.GUI.Debugger
this.tlpFunctionLabelLists.RowCount = 2; this.tlpFunctionLabelLists.RowCount = 2;
this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tlpFunctionLabelLists.Size = new System.Drawing.Size(318, 411); this.tlpFunctionLabelLists.Size = new System.Drawing.Size(318, 425);
this.tlpFunctionLabelLists.TabIndex = 5; this.tlpFunctionLabelLists.TabIndex = 5;
// //
// grpLabels // grpLabels
// //
this.grpLabels.Controls.Add(this.ctrlLabelList); this.grpLabels.Controls.Add(this.ctrlLabelList);
this.grpLabels.Dock = System.Windows.Forms.DockStyle.Fill; this.grpLabels.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpLabels.Location = new System.Drawing.Point(3, 208); this.grpLabels.Location = new System.Drawing.Point(3, 215);
this.grpLabels.Name = "grpLabels"; this.grpLabels.Name = "grpLabels";
this.grpLabels.Size = new System.Drawing.Size(312, 200); this.grpLabels.Size = new System.Drawing.Size(312, 207);
this.grpLabels.TabIndex = 6; this.grpLabels.TabIndex = 6;
this.grpLabels.TabStop = false; this.grpLabels.TabStop = false;
this.grpLabels.Text = "Labels"; this.grpLabels.Text = "Labels";
@ -448,7 +448,7 @@ namespace Mesen.GUI.Debugger
this.ctrlLabelList.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlLabelList.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlLabelList.Location = new System.Drawing.Point(3, 16); this.ctrlLabelList.Location = new System.Drawing.Point(3, 16);
this.ctrlLabelList.Name = "ctrlLabelList"; this.ctrlLabelList.Name = "ctrlLabelList";
this.ctrlLabelList.Size = new System.Drawing.Size(306, 181); this.ctrlLabelList.Size = new System.Drawing.Size(306, 188);
this.ctrlLabelList.TabIndex = 0; this.ctrlLabelList.TabIndex = 0;
this.ctrlLabelList.OnFindOccurrence += new System.EventHandler(this.ctrlLabelList_OnFindOccurrence); this.ctrlLabelList.OnFindOccurrence += new System.EventHandler(this.ctrlLabelList_OnFindOccurrence);
this.ctrlLabelList.OnLabelSelected += new System.EventHandler(this.ctrlLabelList_OnLabelSelected); this.ctrlLabelList.OnLabelSelected += new System.EventHandler(this.ctrlLabelList_OnLabelSelected);
@ -459,7 +459,7 @@ namespace Mesen.GUI.Debugger
this.grpFunctions.Dock = System.Windows.Forms.DockStyle.Fill; this.grpFunctions.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpFunctions.Location = new System.Drawing.Point(3, 3); this.grpFunctions.Location = new System.Drawing.Point(3, 3);
this.grpFunctions.Name = "grpFunctions"; this.grpFunctions.Name = "grpFunctions";
this.grpFunctions.Size = new System.Drawing.Size(312, 199); this.grpFunctions.Size = new System.Drawing.Size(312, 206);
this.grpFunctions.TabIndex = 5; this.grpFunctions.TabIndex = 5;
this.grpFunctions.TabStop = false; this.grpFunctions.TabStop = false;
this.grpFunctions.Text = "Functions"; this.grpFunctions.Text = "Functions";
@ -469,7 +469,7 @@ namespace Mesen.GUI.Debugger
this.ctrlFunctionList.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlFunctionList.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlFunctionList.Location = new System.Drawing.Point(3, 16); this.ctrlFunctionList.Location = new System.Drawing.Point(3, 16);
this.ctrlFunctionList.Name = "ctrlFunctionList"; this.ctrlFunctionList.Name = "ctrlFunctionList";
this.ctrlFunctionList.Size = new System.Drawing.Size(306, 180); this.ctrlFunctionList.Size = new System.Drawing.Size(306, 187);
this.ctrlFunctionList.TabIndex = 0; this.ctrlFunctionList.TabIndex = 0;
this.ctrlFunctionList.OnFindOccurrence += new System.EventHandler(this.ctrlFunctionList_OnFindOccurrence); this.ctrlFunctionList.OnFindOccurrence += new System.EventHandler(this.ctrlFunctionList_OnFindOccurrence);
this.ctrlFunctionList.OnFunctionSelected += new System.EventHandler(this.ctrlFunctionList_OnFunctionSelected); this.ctrlFunctionList.OnFunctionSelected += new System.EventHandler(this.ctrlFunctionList_OnFunctionSelected);
@ -500,7 +500,7 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel10.Size = new System.Drawing.Size(1075, 152); this.tableLayoutPanel10.Size = new System.Drawing.Size(1075, 138);
this.tableLayoutPanel10.TabIndex = 0; this.tableLayoutPanel10.TabIndex = 0;
// //
// grpWatch // grpWatch
@ -509,7 +509,7 @@ namespace Mesen.GUI.Debugger
this.grpWatch.Dock = System.Windows.Forms.DockStyle.Fill; this.grpWatch.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpWatch.Location = new System.Drawing.Point(3, 3); this.grpWatch.Location = new System.Drawing.Point(3, 3);
this.grpWatch.Name = "grpWatch"; this.grpWatch.Name = "grpWatch";
this.grpWatch.Size = new System.Drawing.Size(352, 146); this.grpWatch.Size = new System.Drawing.Size(352, 132);
this.grpWatch.TabIndex = 2; this.grpWatch.TabIndex = 2;
this.grpWatch.TabStop = false; this.grpWatch.TabStop = false;
this.grpWatch.Text = "Watch"; this.grpWatch.Text = "Watch";
@ -519,7 +519,7 @@ namespace Mesen.GUI.Debugger
this.ctrlWatch.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlWatch.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlWatch.Location = new System.Drawing.Point(3, 16); this.ctrlWatch.Location = new System.Drawing.Point(3, 16);
this.ctrlWatch.Name = "ctrlWatch"; this.ctrlWatch.Name = "ctrlWatch";
this.ctrlWatch.Size = new System.Drawing.Size(346, 127); this.ctrlWatch.Size = new System.Drawing.Size(346, 113);
this.ctrlWatch.TabIndex = 0; this.ctrlWatch.TabIndex = 0;
// //
// grpBreakpoints // grpBreakpoints
@ -528,7 +528,7 @@ namespace Mesen.GUI.Debugger
this.grpBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill; this.grpBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpBreakpoints.Location = new System.Drawing.Point(361, 3); this.grpBreakpoints.Location = new System.Drawing.Point(361, 3);
this.grpBreakpoints.Name = "grpBreakpoints"; this.grpBreakpoints.Name = "grpBreakpoints";
this.grpBreakpoints.Size = new System.Drawing.Size(352, 146); this.grpBreakpoints.Size = new System.Drawing.Size(352, 132);
this.grpBreakpoints.TabIndex = 3; this.grpBreakpoints.TabIndex = 3;
this.grpBreakpoints.TabStop = false; this.grpBreakpoints.TabStop = false;
this.grpBreakpoints.Text = "Breakpoints"; this.grpBreakpoints.Text = "Breakpoints";
@ -538,7 +538,7 @@ namespace Mesen.GUI.Debugger
this.ctrlBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlBreakpoints.Location = new System.Drawing.Point(3, 16); this.ctrlBreakpoints.Location = new System.Drawing.Point(3, 16);
this.ctrlBreakpoints.Name = "ctrlBreakpoints"; this.ctrlBreakpoints.Name = "ctrlBreakpoints";
this.ctrlBreakpoints.Size = new System.Drawing.Size(346, 127); this.ctrlBreakpoints.Size = new System.Drawing.Size(346, 113);
this.ctrlBreakpoints.TabIndex = 0; this.ctrlBreakpoints.TabIndex = 0;
this.ctrlBreakpoints.BreakpointNavigation += new System.EventHandler(this.ctrlBreakpoints_BreakpointNavigation); this.ctrlBreakpoints.BreakpointNavigation += new System.EventHandler(this.ctrlBreakpoints_BreakpointNavigation);
// //
@ -548,7 +548,7 @@ namespace Mesen.GUI.Debugger
this.grpCallstack.Dock = System.Windows.Forms.DockStyle.Fill; this.grpCallstack.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpCallstack.Location = new System.Drawing.Point(719, 3); this.grpCallstack.Location = new System.Drawing.Point(719, 3);
this.grpCallstack.Name = "grpCallstack"; this.grpCallstack.Name = "grpCallstack";
this.grpCallstack.Size = new System.Drawing.Size(353, 146); this.grpCallstack.Size = new System.Drawing.Size(353, 132);
this.grpCallstack.TabIndex = 4; this.grpCallstack.TabIndex = 4;
this.grpCallstack.TabStop = false; this.grpCallstack.TabStop = false;
this.grpCallstack.Text = "Call Stack"; this.grpCallstack.Text = "Call Stack";
@ -558,7 +558,7 @@ namespace Mesen.GUI.Debugger
this.ctrlCallstack.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlCallstack.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlCallstack.Location = new System.Drawing.Point(3, 16); this.ctrlCallstack.Location = new System.Drawing.Point(3, 16);
this.ctrlCallstack.Name = "ctrlCallstack"; this.ctrlCallstack.Name = "ctrlCallstack";
this.ctrlCallstack.Size = new System.Drawing.Size(347, 127); this.ctrlCallstack.Size = new System.Drawing.Size(347, 113);
this.ctrlCallstack.TabIndex = 0; this.ctrlCallstack.TabIndex = 0;
this.ctrlCallstack.FunctionSelected += new System.EventHandler(this.ctrlCallstack_FunctionSelected); this.ctrlCallstack.FunctionSelected += new System.EventHandler(this.ctrlCallstack_FunctionSelected);
// //
@ -736,7 +736,6 @@ namespace Mesen.GUI.Debugger
this.mnuCode.Name = "mnuCode"; this.mnuCode.Name = "mnuCode";
this.mnuCode.Size = new System.Drawing.Size(47, 20); this.mnuCode.Size = new System.Drawing.Size(47, 20);
this.mnuCode.Text = "Code"; this.mnuCode.Text = "Code";
this.mnuCode.DropDownClosed += new System.EventHandler(this.mnuCode_DropDownClosed);
this.mnuCode.DropDownOpening += new System.EventHandler(this.mnuCode_DropDownOpening); this.mnuCode.DropDownOpening += new System.EventHandler(this.mnuCode_DropDownOpening);
// //
// debugToolStripMenuItem // debugToolStripMenuItem
@ -1517,6 +1516,19 @@ namespace Mesen.GUI.Debugger
this.toolStripMenuItem11.Name = "toolStripMenuItem11"; this.toolStripMenuItem11.Name = "toolStripMenuItem11";
this.toolStripMenuItem11.Size = new System.Drawing.Size(263, 6); this.toolStripMenuItem11.Size = new System.Drawing.Size(263, 6);
// //
// mnuAutoCreateJumpLabels
//
this.mnuAutoCreateJumpLabels.CheckOnClick = true;
this.mnuAutoCreateJumpLabels.Name = "mnuAutoCreateJumpLabels";
this.mnuAutoCreateJumpLabels.Size = new System.Drawing.Size(266, 22);
this.mnuAutoCreateJumpLabels.Text = "Auto-create jump labels";
this.mnuAutoCreateJumpLabels.Click += new System.EventHandler(this.mnuAutoCreateJumpLabels_Click);
//
// toolStripMenuItem25
//
this.toolStripMenuItem25.Name = "toolStripMenuItem25";
this.toolStripMenuItem25.Size = new System.Drawing.Size(263, 6);
//
// mnuHidePauseIcon // mnuHidePauseIcon
// //
this.mnuHidePauseIcon.CheckOnClick = true; this.mnuHidePauseIcon.CheckOnClick = true;
@ -1848,19 +1860,6 @@ namespace Mesen.GUI.Debugger
this.tsToolbar.Text = "toolStrip1"; this.tsToolbar.Text = "toolStrip1";
this.tsToolbar.Visible = false; this.tsToolbar.Visible = false;
// //
// mnuAutoCreateJumpLabels
//
this.mnuAutoCreateJumpLabels.CheckOnClick = true;
this.mnuAutoCreateJumpLabels.Name = "mnuAutoCreateJumpLabels";
this.mnuAutoCreateJumpLabels.Size = new System.Drawing.Size(266, 22);
this.mnuAutoCreateJumpLabels.Text = "Auto-create jump labels";
this.mnuAutoCreateJumpLabels.Click += new System.EventHandler(this.mnuAutoCreateJumpLabels_Click);
//
// toolStripMenuItem25
//
this.toolStripMenuItem25.Name = "toolStripMenuItem25";
this.toolStripMenuItem25.Size = new System.Drawing.Size(263, 6);
//
// frmDebugger // frmDebugger
// //
this.AllowDrop = true; this.AllowDrop = true;

View file

@ -28,6 +28,16 @@ namespace Mesen.GUI.Debugger
private Size _minimumSize; private Size _minimumSize;
private int _topPanelMinSize; private int _topPanelMinSize;
public ICodeViewer LastCodeWindow
{
get { return _lastCodeWindow; }
set
{
_lastCodeWindow = value;
UpdateCodeMenu();
}
}
public frmDebugger() public frmDebugger()
{ {
InitializeComponent(); InitializeComponent();
@ -40,11 +50,6 @@ namespace Mesen.GUI.Debugger
_minimumSize = this.MinimumSize; _minimumSize = this.MinimumSize;
_topPanelMinSize = splitContainer.Panel1MinSize; _topPanelMinSize = splitContainer.Panel1MinSize;
if(Program.IsMono) {
//This doesn't work in Mono (menu is blank) - hide it for now
mnuCode.Visible = false;
}
_wasPaused = InteropEmu.IsPaused(); _wasPaused = InteropEmu.IsPaused();
bool debuggerAlreadyRunning = InteropEmu.DebugIsDebuggerRunning(); bool debuggerAlreadyRunning = InteropEmu.DebugIsDebuggerRunning();
@ -154,7 +159,7 @@ namespace Mesen.GUI.Debugger
this.mnuUseVerticalLayout.Checked = ConfigManager.Config.DebugInfo.VerticalLayout; this.mnuUseVerticalLayout.Checked = ConfigManager.Config.DebugInfo.VerticalLayout;
_lastCodeWindow = ctrlDebuggerCode; LastCodeWindow = ctrlDebuggerCode;
this.toolTip.SetToolTip(this.picWatchHelp, this.toolTip.SetToolTip(this.picWatchHelp,
frmBreakpoint.GetConditionTooltip(true) + Environment.NewLine + Environment.NewLine + frmBreakpoint.GetConditionTooltip(true) + Environment.NewLine + Environment.NewLine +
@ -292,6 +297,14 @@ namespace Mesen.GUI.Debugger
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{ {
if(ctrlWatch.ContainsFocus) {
//Allow Ctrl+C, etc to work normally while editing watch
CleanupMenu(mnuCode.DropDownItems);
mnuCode.DropDownItems.Clear();
} else {
this.LastCodeWindow.CodeViewerActions.UpdateContextMenuItemVisibility(mnuCode.DropDownItems);
}
if(keyData == ConfigManager.Config.DebugInfo.Shortcuts.ToggleBreakContinue) { if(keyData == ConfigManager.Config.DebugInfo.Shortcuts.ToggleBreakContinue) {
if(mnuBreak.Enabled) { if(mnuBreak.Enabled) {
ctrlConsoleStatus.ApplyChanges(); ctrlConsoleStatus.ApplyChanges();
@ -318,7 +331,7 @@ namespace Mesen.GUI.Debugger
int relativeAddress = InteropEmu.DebugGetRelativeAddress((UInt32)sender, AddressType.PrgRom); int relativeAddress = InteropEmu.DebugGetRelativeAddress((UInt32)sender, AddressType.PrgRom);
if(relativeAddress >= 0) { if(relativeAddress >= 0) {
BringToFront(); BringToFront();
_lastCodeWindow.ScrollToLineNumber(relativeAddress); LastCodeWindow.ScrollToLineNumber(relativeAddress);
} }
} }
@ -610,11 +623,11 @@ namespace Mesen.GUI.Debugger
ctrlDebuggerCodeSplit.Code = ctrlDebuggerCode.Code; ctrlDebuggerCodeSplit.Code = ctrlDebuggerCode.Code;
} }
} else { } else {
_lastCodeWindow = ctrlSourceViewer.Visible ? (ICodeViewer)ctrlSourceViewer : (ICodeViewer)ctrlDebuggerCode; LastCodeWindow = ctrlSourceViewer.Visible ? (ICodeViewer)ctrlSourceViewer : (ICodeViewer)ctrlDebuggerCode;
} }
if(updateActiveAddress) { if(updateActiveAddress) {
_lastCodeWindow.SelectActiveAddress(state.CPU.DebugPC); LastCodeWindow.SelectActiveAddress(state.CPU.DebugPC);
} }
ctrlDebuggerCode.SetActiveAddress(state.CPU.DebugPC); ctrlDebuggerCode.SetActiveAddress(state.CPU.DebugPC);
@ -671,7 +684,7 @@ namespace Mesen.GUI.Debugger
private void ToggleBreakpoint(bool toggleEnabled) private void ToggleBreakpoint(bool toggleEnabled)
{ {
_lastCodeWindow.CodeViewerActions.ToggleBreakpoint(toggleEnabled); LastCodeWindow.CodeViewerActions.ToggleBreakpoint(toggleEnabled);
} }
private void ResumeExecution() private void ResumeExecution()
@ -830,17 +843,17 @@ namespace Mesen.GUI.Debugger
private void mnuFind_Click(object sender, EventArgs e) private void mnuFind_Click(object sender, EventArgs e)
{ {
_lastCodeWindow.CodeViewer.OpenSearchBox(); LastCodeWindow.CodeViewer.OpenSearchBox();
} }
private void mnuFindNext_Click(object sender, EventArgs e) private void mnuFindNext_Click(object sender, EventArgs e)
{ {
_lastCodeWindow.CodeViewer.FindNext(); LastCodeWindow.CodeViewer.FindNext();
} }
private void mnuFindPrev_Click(object sender, EventArgs e) private void mnuFindPrev_Click(object sender, EventArgs e)
{ {
_lastCodeWindow.CodeViewer.FindPrevious(); LastCodeWindow.CodeViewer.FindPrevious();
} }
private void mnuSplitView_Click(object sender, EventArgs e) private void mnuSplitView_Click(object sender, EventArgs e)
@ -873,55 +886,55 @@ namespace Mesen.GUI.Debugger
public void ScrollToAddress(int address) public void ScrollToAddress(int address)
{ {
_lastCodeWindow.ScrollToLineNumber(address); LastCodeWindow.ScrollToLineNumber(address);
} }
private void ctrlDebuggerCode_Enter(object sender, EventArgs e) private void ctrlDebuggerCode_Enter(object sender, EventArgs e)
{ {
_lastCodeWindow = (ICodeViewer)sender; LastCodeWindow = (ICodeViewer)sender;
} }
private void mnuGoToAddress_Click(object sender, EventArgs e) private void mnuGoToAddress_Click(object sender, EventArgs e)
{ {
_lastCodeWindow.CodeViewer.GoToAddress(); LastCodeWindow.CodeViewer.GoToAddress();
} }
private void mnuGoToIrqHandler_Click(object sender, EventArgs e) private void mnuGoToIrqHandler_Click(object sender, EventArgs e)
{ {
int address = (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFF) << 8) | InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFE); int address = (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFF) << 8) | InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFE);
_lastCodeWindow.ScrollToLineNumber(address); LastCodeWindow.ScrollToLineNumber(address);
} }
private void mnuGoToNmiHandler_Click(object sender, EventArgs e) private void mnuGoToNmiHandler_Click(object sender, EventArgs e)
{ {
int address = (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFB) << 8) | InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFA); int address = (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFB) << 8) | InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFA);
_lastCodeWindow.ScrollToLineNumber(address); LastCodeWindow.ScrollToLineNumber(address);
} }
private void mnuGoToResetHandler_Click(object sender, EventArgs e) private void mnuGoToResetHandler_Click(object sender, EventArgs e)
{ {
int address = (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFD) << 8) | InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFC); int address = (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFD) << 8) | InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFC);
_lastCodeWindow.ScrollToLineNumber(address); LastCodeWindow.ScrollToLineNumber(address);
} }
private void mnuGoToProgramCount_Click(object sender, EventArgs e) private void mnuGoToProgramCount_Click(object sender, EventArgs e)
{ {
_lastCodeWindow.CodeViewerActions.ScrollToActiveAddress(); LastCodeWindow.CodeViewerActions.ScrollToActiveAddress();
} }
private void mnuIncreaseFontSize_Click(object sender, EventArgs e) private void mnuIncreaseFontSize_Click(object sender, EventArgs e)
{ {
_lastCodeWindow.CodeViewer.TextZoom += 10; LastCodeWindow.CodeViewer.TextZoom += 10;
} }
private void mnuDecreaseFontSize_Click(object sender, EventArgs e) private void mnuDecreaseFontSize_Click(object sender, EventArgs e)
{ {
_lastCodeWindow.CodeViewer.TextZoom -= 10; LastCodeWindow.CodeViewer.TextZoom -= 10;
} }
private void mnuResetFontSize_Click(object sender, EventArgs e) private void mnuResetFontSize_Click(object sender, EventArgs e)
{ {
_lastCodeWindow.CodeViewer.TextZoom = 100; LastCodeWindow.CodeViewer.TextZoom = 100;
} }
private void mnuClose_Click(object sender, EventArgs e) private void mnuClose_Click(object sender, EventArgs e)
@ -974,7 +987,7 @@ namespace Mesen.GUI.Debugger
private void ctrlCallstack_FunctionSelected(object sender, EventArgs e) private void ctrlCallstack_FunctionSelected(object sender, EventArgs e)
{ {
_lastCodeWindow.ScrollToLineNumber((int)sender); LastCodeWindow.ScrollToLineNumber((int)sender);
} }
private void ctrlConsoleStatus_OnStateChanged(object sender, EventArgs e) private void ctrlConsoleStatus_OnStateChanged(object sender, EventArgs e)
@ -1017,7 +1030,7 @@ namespace Mesen.GUI.Debugger
if(bp.IsCpuBreakpoint) { if(bp.IsCpuBreakpoint) {
int relAddress = bp.GetRelativeAddress(); int relAddress = bp.GetRelativeAddress();
if(relAddress >= 0) { if(relAddress >= 0) {
_lastCodeWindow.ScrollToLineNumber(relAddress); LastCodeWindow.ScrollToLineNumber(relAddress);
} }
} }
} }
@ -1237,7 +1250,7 @@ namespace Mesen.GUI.Debugger
private void ctrlFunctionList_OnFunctionSelected(object relativeAddress, EventArgs e) private void ctrlFunctionList_OnFunctionSelected(object relativeAddress, EventArgs e)
{ {
_lastCodeWindow.ScrollToLineNumber((Int32)relativeAddress); LastCodeWindow.ScrollToLineNumber((Int32)relativeAddress);
} }
private void LabelManager_OnLabelUpdated(object sender, EventArgs e) private void LabelManager_OnLabelUpdated(object sender, EventArgs e)
@ -1250,7 +1263,7 @@ namespace Mesen.GUI.Debugger
private void ctrlLabelList_OnLabelSelected(object relativeAddress, EventArgs e) private void ctrlLabelList_OnLabelSelected(object relativeAddress, EventArgs e)
{ {
_lastCodeWindow.ScrollToLineNumber((Int32)relativeAddress); LastCodeWindow.ScrollToLineNumber((Int32)relativeAddress);
} }
private void mnuResetWorkspace_Click(object sender, EventArgs e) private void mnuResetWorkspace_Click(object sender, EventArgs e)
@ -1312,12 +1325,12 @@ namespace Mesen.GUI.Debugger
private void ctrlLabelList_OnFindOccurrence(object sender, EventArgs e) private void ctrlLabelList_OnFindOccurrence(object sender, EventArgs e)
{ {
CodeLabel label = sender as CodeLabel; CodeLabel label = sender as CodeLabel;
_lastCodeWindow.FindAllOccurrences(label.Label, true, true); LastCodeWindow.FindAllOccurrences(label.Label, true, true);
} }
private void ctrlFunctionList_OnFindOccurrence(object sender, EventArgs e) private void ctrlFunctionList_OnFindOccurrence(object sender, EventArgs e)
{ {
_lastCodeWindow.FindAllOccurrences(sender as string, true, true); LastCodeWindow.FindAllOccurrences(sender as string, true, true);
} }
private void mnuBreakIn_Click(object sender, EventArgs e) private void mnuBreakIn_Click(object sender, EventArgs e)
@ -1338,7 +1351,7 @@ namespace Mesen.GUI.Debugger
{ {
frmFindOccurrences frm = new Debugger.frmFindOccurrences(); frmFindOccurrences frm = new Debugger.frmFindOccurrences();
if(frm.ShowDialog() == DialogResult.OK) { if(frm.ShowDialog() == DialogResult.OK) {
_lastCodeWindow.FindAllOccurrences(frm.SearchString, frm.MatchWholeWord, frm.MatchCase); LastCodeWindow.FindAllOccurrences(frm.SearchString, frm.MatchWholeWord, frm.MatchCase);
} }
} }
@ -1362,7 +1375,7 @@ namespace Mesen.GUI.Debugger
private void ctrlConsoleStatus_OnGotoLocation(object sender, EventArgs e) private void ctrlConsoleStatus_OnGotoLocation(object sender, EventArgs e)
{ {
_lastCodeWindow.ScrollToLineNumber((int)sender); LastCodeWindow.ScrollToLineNumber((int)sender);
} }
private void UpdateDisassembleFlags() private void UpdateDisassembleFlags()
@ -1511,24 +1524,66 @@ namespace Mesen.GUI.Debugger
DebugWindowManager.OpenAssembler(args.Code, args.StartAddress, args.BlockLength); DebugWindowManager.OpenAssembler(args.Code, args.StartAddress, args.BlockLength);
} }
private void mnuCode_DropDownOpening(object sender, EventArgs e) private void CopyMenu(ToolStripItemCollection source, ToolStripItemCollection dest)
{ {
this._lastCodeWindow.CodeViewerActions.UpdateContextMenuItemVisibility(false);
List<ToolStripItem> items = new List<ToolStripItem>(); List<ToolStripItem> items = new List<ToolStripItem>();
foreach(ToolStripItem item in this._lastCodeWindow.CodeViewerActions.contextMenu.Items) { foreach(ToolStripItem item in source) {
items.Add(item); if(item is ToolStripSeparator) {
ToolStripSeparator sep = new ToolStripSeparator();
sep.Name = item.Name;
sep.Visible = true;
items.Add(sep);
} else if(item is ToolStripMenuItem) {
ToolStripMenuItem copy = new ToolStripMenuItem(item.Text, item.Image);
copy.Name = item.Name;
copy.Enabled = item.Enabled;
copy.CheckOnClick = ((ToolStripMenuItem)item).CheckOnClick;
copy.Checked = ((ToolStripMenuItem)item).Checked;
copy.Visible = true;
copy.Click += (s, e) => {
item.PerformClick();
};
if(((ToolStripMenuItem)item).DropDownItems.Count > 0) {
CopyMenu(((ToolStripMenuItem)item).DropDownItems, copy.DropDownItems);
}
if(item.Tag is ShortcutInfo) {
copy.InitShortcut(this, ((ShortcutInfo)item.Tag).ShortcutKey);
}
items.Add(copy);
} else {
//Not used
}
} }
mnuCode.DropDownItems.AddRange(items.ToArray()); dest.AddRange(items.ToArray());
} }
private void mnuCode_DropDownClosed(object sender, EventArgs e) private void CleanupMenu(ToolStripItemCollection items)
{ {
List<ToolStripItem> items = new List<ToolStripItem>(); foreach(ToolStripItem item in items) {
foreach(ToolStripItem item in mnuCode.DropDownItems) { if(item.Tag is ShortcutInfo && ((ShortcutInfo)item.Tag).KeyHandler != null) {
items.Add(item); DebuggerShortcutsConfig.ClearProcessCmdKeyHandler((ToolStripMenuItem)item, this);
}
if(item is ToolStripMenuItem && ((ToolStripMenuItem)item).HasDropDownItems) {
CleanupMenu(((ToolStripMenuItem)item).DropDownItems);
}
} }
this._lastCodeWindow.CodeViewerActions.contextMenu.Items.AddRange(items.ToArray()); }
private void UpdateCodeMenu()
{
CleanupMenu(mnuCode.DropDownItems);
mnuCode.DropDownItems.Clear();
CopyMenu(this.LastCodeWindow.CodeViewerActions.contextMenu.Items, mnuCode.DropDownItems);
this.LastCodeWindow.CodeViewerActions.UpdateContextMenuItemVisibility(mnuCode.DropDownItems, false);
}
private void mnuCode_DropDownOpening(object sender, EventArgs e)
{
UpdateCodeMenu();
} }
private void mnuCdlStripUsedData_Click(object sender, EventArgs e) private void mnuCdlStripUsedData_Click(object sender, EventArgs e)