Debugger: Add a "Code" menu that contains options from the code window right-click menu
This commit is contained in:
parent
d6222a8308
commit
90788e557e
5 changed files with 85 additions and 37 deletions
|
@ -29,6 +29,7 @@
|
|||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.contextMenuCode = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.mnuEditSelectedCode = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuEditSubroutine = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuShowNextStatement = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -47,7 +48,7 @@
|
|||
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuEditLabel = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuToggleBreakpoint = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.sepBreakpoint = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuAddToWatch = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuFindOccurrences = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuGoToLocation = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -68,7 +69,6 @@
|
|||
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.picCloseOccurrenceList = new System.Windows.Forms.PictureBox();
|
||||
this.lblSearchResult = new System.Windows.Forms.Label();
|
||||
this.mnuEditSelectedCode = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.contextMenuCode.SuspendLayout();
|
||||
this.contextMenuMargin.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
|
||||
|
@ -94,7 +94,7 @@
|
|||
this.toolStripMenuItem2,
|
||||
this.mnuEditLabel,
|
||||
this.mnuToggleBreakpoint,
|
||||
this.toolStripMenuItem4,
|
||||
this.sepBreakpoint,
|
||||
this.mnuAddToWatch,
|
||||
this.mnuFindOccurrences,
|
||||
this.mnuGoToLocation,
|
||||
|
@ -106,6 +106,14 @@
|
|||
this.contextMenuCode.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.contextMenuCode_Closed);
|
||||
this.contextMenuCode.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuCode_Opening);
|
||||
//
|
||||
// mnuEditSelectedCode
|
||||
//
|
||||
this.mnuEditSelectedCode.Image = global::Mesen.GUI.Properties.Resources.Edit;
|
||||
this.mnuEditSelectedCode.Name = "mnuEditSelectedCode";
|
||||
this.mnuEditSelectedCode.Size = new System.Drawing.Size(258, 22);
|
||||
this.mnuEditSelectedCode.Text = "Edit selected code";
|
||||
this.mnuEditSelectedCode.Click += new System.EventHandler(this.mnuEditSelectedCode_Click);
|
||||
//
|
||||
// mnuEditSubroutine
|
||||
//
|
||||
this.mnuEditSubroutine.Image = global::Mesen.GUI.Properties.Resources.Edit;
|
||||
|
@ -239,10 +247,10 @@
|
|||
this.mnuToggleBreakpoint.Text = "Toggle Breakpoint";
|
||||
this.mnuToggleBreakpoint.Click += new System.EventHandler(this.mnuToggleBreakpoint_Click);
|
||||
//
|
||||
// toolStripMenuItem4
|
||||
// sepBreakpoint
|
||||
//
|
||||
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
|
||||
this.toolStripMenuItem4.Size = new System.Drawing.Size(255, 6);
|
||||
this.sepBreakpoint.Name = "sepBreakpoint";
|
||||
this.sepBreakpoint.Size = new System.Drawing.Size(255, 6);
|
||||
//
|
||||
// mnuAddToWatch
|
||||
//
|
||||
|
@ -448,14 +456,6 @@
|
|||
this.lblSearchResult.TabIndex = 11;
|
||||
this.lblSearchResult.Text = "Search results for: ";
|
||||
//
|
||||
// mnuEditSelectedCode
|
||||
//
|
||||
this.mnuEditSelectedCode.Image = global::Mesen.GUI.Properties.Resources.Edit;
|
||||
this.mnuEditSelectedCode.Name = "mnuEditSelectedCode";
|
||||
this.mnuEditSelectedCode.Size = new System.Drawing.Size(258, 22);
|
||||
this.mnuEditSelectedCode.Text = "Edit selected code";
|
||||
this.mnuEditSelectedCode.Click += new System.EventHandler(this.mnuEditSelectedCode_Click);
|
||||
//
|
||||
// ctrlDebuggerCode
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -507,7 +507,7 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem mnuNavigateForward;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuNavigateBackward;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuEditLabel;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem4;
|
||||
private System.Windows.Forms.ToolStripSeparator sepBreakpoint;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuToggleBreakpoint;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuShowByteCodeOnLeft;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuShowByteCodeBelow;
|
||||
|
|
|
@ -48,6 +48,23 @@ namespace Mesen.GUI.Debugger
|
|||
splitContainer.Panel2Collapsed = true;
|
||||
}
|
||||
|
||||
public List<ToolStripItem> ContextMenuItems
|
||||
{
|
||||
get
|
||||
{
|
||||
List<ToolStripItem> items = new List<ToolStripItem>();
|
||||
foreach(ToolStripItem item in this.contextMenuCode.Items) {
|
||||
items.Add(item);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.contextMenuCode.Items.AddRange(value.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public void SetConfig(DebugViewInfo config)
|
||||
{
|
||||
_config = config;
|
||||
|
@ -437,6 +454,8 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
private bool UpdateContextMenu(Point mouseLocation)
|
||||
{
|
||||
UpdateContextMenuItemVisibility(true);
|
||||
|
||||
string word = GetWordUnderLocation(mouseLocation);
|
||||
if(word.StartsWith("$") || LabelManager.GetLabel(word) != null) {
|
||||
//Cursor is on a numeric value or label
|
||||
|
@ -494,6 +513,19 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
}
|
||||
|
||||
public void UpdateContextMenuItemVisibility(bool visible)
|
||||
{
|
||||
mnuShowNextStatement.Enabled = _currentActiveAddress.HasValue;
|
||||
mnuSetNextStatement.Enabled = _currentActiveAddress.HasValue;
|
||||
mnuEditSelectedCode.Enabled = mnuEditSubroutine.Enabled = InteropEmu.DebugIsExecutionStopped() && ctrlCodeViewer.CurrentLine >= 0;
|
||||
|
||||
mnuAddToWatch.Visible = visible;
|
||||
mnuFindOccurrences.Visible = visible;
|
||||
mnuEditLabel.Visible = visible;
|
||||
mnuGoToLocation.Visible = visible;
|
||||
sepBreakpoint.Visible = visible;
|
||||
}
|
||||
|
||||
int _lastClickedAddress = Int32.MaxValue;
|
||||
string _newWatchValue = string.Empty;
|
||||
string _lastWord = string.Empty;
|
||||
|
@ -587,13 +619,12 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
private void contextMenuCode_Opening(object sender, CancelEventArgs e)
|
||||
{
|
||||
mnuShowNextStatement.Enabled = _currentActiveAddress.HasValue;
|
||||
mnuSetNextStatement.Enabled = _currentActiveAddress.HasValue;
|
||||
mnuEditSubroutine.Enabled = InteropEmu.DebugIsExecutionStopped();
|
||||
UpdateContextMenuItemVisibility(true);
|
||||
}
|
||||
|
||||
private void contextMenuCode_Closed(object sender, ToolStripDropDownClosedEventArgs e)
|
||||
{
|
||||
mnuEditSelectedCode.Enabled = true;
|
||||
mnuEditSubroutine.Enabled = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -318,14 +318,6 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
}
|
||||
|
||||
public void ClearLineStyles()
|
||||
{
|
||||
_lineProperties.Clear();
|
||||
if(!this._updating) {
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void BeginUpdate()
|
||||
{
|
||||
this._updating = true;
|
||||
|
@ -342,7 +334,6 @@ namespace Mesen.GUI.Debugger
|
|||
LineProperties GetLineStyle(int cpuAddress);
|
||||
}
|
||||
|
||||
|
||||
public ILineStyleProvider StyleProvider { get; set; }
|
||||
|
||||
public LineProperties GetLineStyle(int lineNumber)
|
||||
|
|
31
GUI.NET/Debugger/frmDebugger.Designer.cs
generated
31
GUI.NET/Debugger/frmDebugger.Designer.cs
generated
|
@ -71,6 +71,7 @@ namespace Mesen.GUI.Debugger
|
|||
this.mnuDisableDefaultLabels = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuClose = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuCode = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuContinue = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuBreak = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -216,7 +217,7 @@ namespace Mesen.GUI.Debugger
|
|||
this.ctrlSplitContainerTop.Panel2.Controls.Add(this.tlpFunctionLabelLists);
|
||||
this.ctrlSplitContainerTop.Panel2MinSize = 150;
|
||||
this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1260, 390);
|
||||
this.ctrlSplitContainerTop.SplitterDistance = 894;
|
||||
this.ctrlSplitContainerTop.SplitterDistance = 885;
|
||||
this.ctrlSplitContainerTop.SplitterWidth = 7;
|
||||
this.ctrlSplitContainerTop.TabIndex = 3;
|
||||
this.ctrlSplitContainerTop.PanelCollapsed += new System.EventHandler(this.ctrlSplitContainerTop_PanelCollapsed);
|
||||
|
@ -237,7 +238,7 @@ namespace Mesen.GUI.Debugger
|
|||
this.tlpTop.Name = "tlpTop";
|
||||
this.tlpTop.RowCount = 1;
|
||||
this.tlpTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tlpTop.Size = new System.Drawing.Size(894, 390);
|
||||
this.tlpTop.Size = new System.Drawing.Size(885, 390);
|
||||
this.tlpTop.TabIndex = 2;
|
||||
//
|
||||
// ctrlDebuggerCode
|
||||
|
@ -246,7 +247,7 @@ namespace Mesen.GUI.Debugger
|
|||
this.ctrlDebuggerCode.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ctrlDebuggerCode.Location = new System.Drawing.Point(3, 3);
|
||||
this.ctrlDebuggerCode.Name = "ctrlDebuggerCode";
|
||||
this.ctrlDebuggerCode.Size = new System.Drawing.Size(456, 384);
|
||||
this.ctrlDebuggerCode.Size = new System.Drawing.Size(447, 384);
|
||||
this.ctrlDebuggerCode.TabIndex = 2;
|
||||
this.ctrlDebuggerCode.OnEditCode += new Mesen.GUI.Debugger.ctrlDebuggerCode.AssemblerEventHandler(this.ctrlDebuggerCode_OnEditCode);
|
||||
this.ctrlDebuggerCode.OnSetNextStatement += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnSetNextStatement);
|
||||
|
@ -255,7 +256,7 @@ namespace Mesen.GUI.Debugger
|
|||
// ctrlConsoleStatus
|
||||
//
|
||||
this.ctrlConsoleStatus.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ctrlConsoleStatus.Location = new System.Drawing.Point(462, 0);
|
||||
this.ctrlConsoleStatus.Location = new System.Drawing.Point(453, 0);
|
||||
this.ctrlConsoleStatus.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.ctrlConsoleStatus.Name = "ctrlConsoleStatus";
|
||||
this.ctrlConsoleStatus.Size = new System.Drawing.Size(432, 390);
|
||||
|
@ -266,7 +267,7 @@ namespace Mesen.GUI.Debugger
|
|||
//
|
||||
this.ctrlDebuggerCodeSplit.Code = null;
|
||||
this.ctrlDebuggerCodeSplit.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ctrlDebuggerCodeSplit.Location = new System.Drawing.Point(465, 3);
|
||||
this.ctrlDebuggerCodeSplit.Location = new System.Drawing.Point(456, 3);
|
||||
this.ctrlDebuggerCodeSplit.Name = "ctrlDebuggerCodeSplit";
|
||||
this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 384);
|
||||
this.ctrlDebuggerCodeSplit.TabIndex = 4;
|
||||
|
@ -288,7 +289,7 @@ namespace Mesen.GUI.Debugger
|
|||
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.Size = new System.Drawing.Size(359, 390);
|
||||
this.tlpFunctionLabelLists.Size = new System.Drawing.Size(368, 390);
|
||||
this.tlpFunctionLabelLists.TabIndex = 5;
|
||||
//
|
||||
// grpLabels
|
||||
|
@ -297,7 +298,7 @@ namespace Mesen.GUI.Debugger
|
|||
this.grpLabels.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.grpLabels.Location = new System.Drawing.Point(3, 198);
|
||||
this.grpLabels.Name = "grpLabels";
|
||||
this.grpLabels.Size = new System.Drawing.Size(353, 189);
|
||||
this.grpLabels.Size = new System.Drawing.Size(362, 189);
|
||||
this.grpLabels.TabIndex = 6;
|
||||
this.grpLabels.TabStop = false;
|
||||
this.grpLabels.Text = "Labels";
|
||||
|
@ -307,7 +308,7 @@ namespace Mesen.GUI.Debugger
|
|||
this.ctrlLabelList.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ctrlLabelList.Location = new System.Drawing.Point(3, 16);
|
||||
this.ctrlLabelList.Name = "ctrlLabelList";
|
||||
this.ctrlLabelList.Size = new System.Drawing.Size(347, 170);
|
||||
this.ctrlLabelList.Size = new System.Drawing.Size(356, 170);
|
||||
this.ctrlLabelList.TabIndex = 0;
|
||||
this.ctrlLabelList.OnFindOccurrence += new System.EventHandler(this.ctrlLabelList_OnFindOccurrence);
|
||||
this.ctrlLabelList.OnLabelSelected += new System.EventHandler(this.ctrlLabelList_OnLabelSelected);
|
||||
|
@ -318,7 +319,7 @@ namespace Mesen.GUI.Debugger
|
|||
this.grpFunctions.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.grpFunctions.Location = new System.Drawing.Point(3, 3);
|
||||
this.grpFunctions.Name = "grpFunctions";
|
||||
this.grpFunctions.Size = new System.Drawing.Size(353, 189);
|
||||
this.grpFunctions.Size = new System.Drawing.Size(362, 189);
|
||||
this.grpFunctions.TabIndex = 5;
|
||||
this.grpFunctions.TabStop = false;
|
||||
this.grpFunctions.Text = "Functions";
|
||||
|
@ -328,7 +329,7 @@ namespace Mesen.GUI.Debugger
|
|||
this.ctrlFunctionList.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ctrlFunctionList.Location = new System.Drawing.Point(3, 16);
|
||||
this.ctrlFunctionList.Name = "ctrlFunctionList";
|
||||
this.ctrlFunctionList.Size = new System.Drawing.Size(347, 170);
|
||||
this.ctrlFunctionList.Size = new System.Drawing.Size(356, 170);
|
||||
this.ctrlFunctionList.TabIndex = 0;
|
||||
this.ctrlFunctionList.OnFindOccurrence += new System.EventHandler(this.ctrlFunctionList_OnFindOccurrence);
|
||||
this.ctrlFunctionList.OnFunctionSelected += new System.EventHandler(this.ctrlFunctionList_OnFunctionSelected);
|
||||
|
@ -426,6 +427,7 @@ namespace Mesen.GUI.Debugger
|
|||
//
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.mnuCode,
|
||||
this.debugToolStripMenuItem,
|
||||
this.searchToolStripMenuItem,
|
||||
this.mnuOptions,
|
||||
|
@ -523,6 +525,14 @@ namespace Mesen.GUI.Debugger
|
|||
this.mnuClose.Text = "Close";
|
||||
this.mnuClose.Click += new System.EventHandler(this.mnuClose_Click);
|
||||
//
|
||||
// mnuCode
|
||||
//
|
||||
this.mnuCode.Name = "mnuCode";
|
||||
this.mnuCode.Size = new System.Drawing.Size(47, 20);
|
||||
this.mnuCode.Text = "Code";
|
||||
this.mnuCode.DropDownClosed += new System.EventHandler(this.mnuCode_DropDownClosed);
|
||||
this.mnuCode.DropDownOpening += new System.EventHandler(this.mnuCode_DropDownOpening);
|
||||
//
|
||||
// debugToolStripMenuItem
|
||||
//
|
||||
this.debugToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
|
@ -1329,5 +1339,6 @@ namespace Mesen.GUI.Debugger
|
|||
private System.Windows.Forms.ToolStripMenuItem mnuSaveRom;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem14;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuAssembler;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuCode;
|
||||
}
|
||||
}
|
|
@ -873,5 +873,20 @@ namespace Mesen.GUI.Debugger
|
|||
{
|
||||
OpenChildForm(new frmAssembler());
|
||||
}
|
||||
|
||||
private void mnuCode_DropDownOpening(object sender, EventArgs e)
|
||||
{
|
||||
this._lastCodeWindow.UpdateContextMenuItemVisibility(false);
|
||||
mnuCode.DropDownItems.AddRange(this._lastCodeWindow.ContextMenuItems.ToArray());
|
||||
}
|
||||
|
||||
private void mnuCode_DropDownClosed(object sender, EventArgs e)
|
||||
{
|
||||
List<ToolStripItem> items = new List<ToolStripItem>();
|
||||
foreach(ToolStripItem item in mnuCode.DropDownItems) {
|
||||
items.Add(item);
|
||||
}
|
||||
this._lastCodeWindow.ContextMenuItems = items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue