From 13d4a0fc72fd4821ab247bdf34047acd5343acb7 Mon Sep 17 00:00:00 2001 From: Sour Date: Sat, 3 Mar 2018 12:01:16 -0500 Subject: [PATCH] Debugger: Added prg address inline compact display option --- GUI.NET/Config/DebugInfo.cs | 3 +- .../Controls/ctrlDebuggerCode.Designer.cs | 39 ++++++++++++------- GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs | 17 ++++++++ .../Controls/ctrlScrollableTextbox.cs | 2 + GUI.NET/Debugger/Controls/ctrlTextbox.cs | 23 ++++++++++- 5 files changed, 67 insertions(+), 17 deletions(-) diff --git a/GUI.NET/Config/DebugInfo.cs b/GUI.NET/Config/DebugInfo.cs index a57acfbe..0d5f839e 100644 --- a/GUI.NET/Config/DebugInfo.cs +++ b/GUI.NET/Config/DebugInfo.cs @@ -24,7 +24,8 @@ namespace Mesen.GUI.Config { Hidden, Replace, - Below + Below, + Inline } public class DebugViewInfo diff --git a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.Designer.cs b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.Designer.cs index a4c65e62..bae6d53d 100644 --- a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.Designer.cs +++ b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.Designer.cs @@ -36,6 +36,7 @@ this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator(); this.mnuEditSelectedCode = new System.Windows.Forms.ToolStripMenuItem(); this.mnuEditSubroutine = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuUndoPrgChrEdit = new System.Windows.Forms.ToolStripMenuItem(); this.copySelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripSeparator(); this.mnuShowNextStatement = new System.Windows.Forms.ToolStripMenuItem(); @@ -47,6 +48,7 @@ this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator(); this.mnuHideByteCode = new System.Windows.Forms.ToolStripMenuItem(); this.mnuShowLineNotes = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuPrgShowInline = new System.Windows.Forms.ToolStripMenuItem(); this.mnuPrgAddressReplace = new System.Windows.Forms.ToolStripMenuItem(); this.mnuPrgAddressBelow = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator(); @@ -78,7 +80,6 @@ this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.picCloseOccurrenceList = new System.Windows.Forms.PictureBox(); this.lblSearchResult = new System.Windows.Forms.Label(); - this.mnuUndoPrgChrEdit = new System.Windows.Forms.ToolStripMenuItem(); this.contextMenuCode.SuspendLayout(); this.contextMenuMargin.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); @@ -179,6 +180,15 @@ this.mnuEditSubroutine.Text = "Edit Subroutine"; this.mnuEditSubroutine.Click += new System.EventHandler(this.mnuEditSubroutine_Click); // + // mnuUndoPrgChrEdit + // + this.mnuUndoPrgChrEdit.Image = global::Mesen.GUI.Properties.Resources.Undo; + this.mnuUndoPrgChrEdit.Name = "mnuUndoPrgChrEdit"; + this.mnuUndoPrgChrEdit.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z))); + this.mnuUndoPrgChrEdit.Size = new System.Drawing.Size(258, 22); + this.mnuUndoPrgChrEdit.Text = "Undo PRG/CHR Edit"; + this.mnuUndoPrgChrEdit.Click += new System.EventHandler(this.mnuUndoPrgChrEdit_Click); + // // copySelectionToolStripMenuItem // this.copySelectionToolStripMenuItem.Image = global::Mesen.GUI.Properties.Resources.Copy; @@ -256,6 +266,7 @@ // mnuShowLineNotes // this.mnuShowLineNotes.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuPrgShowInline, this.mnuPrgAddressReplace, this.mnuPrgAddressBelow, this.toolStripMenuItem6, @@ -265,29 +276,36 @@ this.mnuShowLineNotes.Text = "PRG Address Display"; this.mnuShowLineNotes.Click += new System.EventHandler(this.mnuShowLineNotes_Click); // + // mnuPrgShowInline + // + this.mnuPrgShowInline.Name = "mnuPrgShowInline"; + this.mnuPrgShowInline.Size = new System.Drawing.Size(196, 22); + this.mnuPrgShowInline.Text = "Inline Compact Display"; + this.mnuPrgShowInline.Click += new System.EventHandler(this.mnuShowInlineCompactDisplay_Click); + // // mnuPrgAddressReplace // this.mnuPrgAddressReplace.Name = "mnuPrgAddressReplace"; - this.mnuPrgAddressReplace.Size = new System.Drawing.Size(184, 22); + this.mnuPrgAddressReplace.Size = new System.Drawing.Size(196, 22); this.mnuPrgAddressReplace.Text = "Replace CPU address"; this.mnuPrgAddressReplace.Click += new System.EventHandler(this.mnuReplaceCpuAddress_Click); // // mnuPrgAddressBelow // this.mnuPrgAddressBelow.Name = "mnuPrgAddressBelow"; - this.mnuPrgAddressBelow.Size = new System.Drawing.Size(184, 22); + this.mnuPrgAddressBelow.Size = new System.Drawing.Size(196, 22); this.mnuPrgAddressBelow.Text = "Below CPU address"; this.mnuPrgAddressBelow.Click += new System.EventHandler(this.mnuBelowCpuAddress_Click); // // toolStripMenuItem6 // this.toolStripMenuItem6.Name = "toolStripMenuItem6"; - this.toolStripMenuItem6.Size = new System.Drawing.Size(181, 6); + this.toolStripMenuItem6.Size = new System.Drawing.Size(193, 6); // // mnuHidePrgAddresses // this.mnuHidePrgAddresses.Name = "mnuHidePrgAddresses"; - this.mnuHidePrgAddresses.Size = new System.Drawing.Size(184, 22); + this.mnuHidePrgAddresses.Size = new System.Drawing.Size(196, 22); this.mnuHidePrgAddresses.Text = "Hidden"; this.mnuHidePrgAddresses.Click += new System.EventHandler(this.mnuHidePrgAddresses_Click); // @@ -396,6 +414,7 @@ this.ctrlCodeViewer.HideSelection = false; this.ctrlCodeViewer.Location = new System.Drawing.Point(0, 0); this.ctrlCodeViewer.Name = "ctrlCodeViewer"; + this.ctrlCodeViewer.ShowCompactPrgAddresses = false; this.ctrlCodeViewer.ShowContentNotes = false; this.ctrlCodeViewer.ShowLineNumberNotes = false; this.ctrlCodeViewer.ShowMemoryValues = false; @@ -551,15 +570,6 @@ this.lblSearchResult.TabIndex = 11; this.lblSearchResult.Text = "Search results for: "; // - // mnuUndoPrgChrEdit - // - this.mnuUndoPrgChrEdit.Image = global::Mesen.GUI.Properties.Resources.Undo; - this.mnuUndoPrgChrEdit.Name = "mnuUndoPrgChrEdit"; - this.mnuUndoPrgChrEdit.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z))); - this.mnuUndoPrgChrEdit.Size = new System.Drawing.Size(258, 22); - this.mnuUndoPrgChrEdit.Text = "Undo PRG/CHR Edit"; - this.mnuUndoPrgChrEdit.Click += new System.EventHandler(this.mnuUndoPrgChrEdit_Click); - // // ctrlDebuggerCode // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -634,5 +644,6 @@ private System.Windows.Forms.ToolStripMenuItem mnuMarkAsUnidentifiedData; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem4; private System.Windows.Forms.ToolStripMenuItem mnuUndoPrgChrEdit; + private System.Windows.Forms.ToolStripMenuItem mnuPrgShowInline; } } diff --git a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs index 32c8fddf..918e48e2 100644 --- a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs +++ b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs @@ -72,6 +72,7 @@ namespace Mesen.GUI.Debugger { _config = config; + mnuPrgShowInline.Checked = false; mnuPrgAddressReplace.Checked = false; mnuPrgAddressBelow.Checked = false; mnuHidePrgAddresses.Checked = false; @@ -101,19 +102,29 @@ namespace Mesen.GUI.Debugger } switch(config.PrgAddressPosition) { + case PrgAddressPosition.Inline: + this.ctrlCodeViewer.ShowCompactPrgAddresses = true; + this.ctrlCodeViewer.ShowLineNumberNotes = false; + this.ctrlCodeViewer.ShowSingleLineLineNumberNotes = false; + this.mnuPrgShowInline.Checked = true; + break; + case PrgAddressPosition.Replace: + this.ctrlCodeViewer.ShowCompactPrgAddresses = false; this.ctrlCodeViewer.ShowLineNumberNotes = true; this.ctrlCodeViewer.ShowSingleLineLineNumberNotes = true; this.mnuPrgAddressReplace.Checked = true; break; case PrgAddressPosition.Below: + this.ctrlCodeViewer.ShowCompactPrgAddresses = false; this.ctrlCodeViewer.ShowLineNumberNotes = true; this.ctrlCodeViewer.ShowSingleLineLineNumberNotes = false; this.mnuPrgAddressBelow.Checked = true; break; case PrgAddressPosition.Hidden: + this.ctrlCodeViewer.ShowCompactPrgAddresses = false; this.ctrlCodeViewer.ShowLineNumberNotes = false; this.ctrlCodeViewer.ShowSingleLineLineNumberNotes = false; this.mnuHidePrgAddresses.Checked = true; @@ -884,6 +895,12 @@ namespace Mesen.GUI.Debugger _config.ByteCodePosition = ByteCodePosition.Hidden; this.UpdateConfig(); } + + private void mnuShowInlineCompactDisplay_Click(object sender, EventArgs e) + { + _config.PrgAddressPosition = PrgAddressPosition.Inline; + this.UpdateConfig(); + } private void mnuReplaceCpuAddress_Click(object sender, EventArgs e) { diff --git a/GUI.NET/Debugger/Controls/ctrlScrollableTextbox.cs b/GUI.NET/Debugger/Controls/ctrlScrollableTextbox.cs index ad176447..cd5579ee 100644 --- a/GUI.NET/Debugger/Controls/ctrlScrollableTextbox.cs +++ b/GUI.NET/Debugger/Controls/ctrlScrollableTextbox.cs @@ -382,6 +382,8 @@ namespace Mesen.GUI.Debugger set { this.ctrlTextbox.ShowContentNotes = value; } } + public bool ShowCompactPrgAddresses { get => this.ctrlTextbox.ShowCompactPrgAddresses; set => this.ctrlTextbox.ShowCompactPrgAddresses = value; } + public bool ShowLineNumberNotes { get { return this.ctrlTextbox.ShowLineNumberNotes; } diff --git a/GUI.NET/Debugger/Controls/ctrlTextbox.cs b/GUI.NET/Debugger/Controls/ctrlTextbox.cs index 47f681b1..03fd7dc2 100644 --- a/GUI.NET/Debugger/Controls/ctrlTextbox.cs +++ b/GUI.NET/Debugger/Controls/ctrlTextbox.cs @@ -67,6 +67,7 @@ namespace Mesen.GUI.Debugger private bool _showSingleLineLineNumberNotes = false; private bool _showContentNotes = false; private bool _showSingleLineContentNotes = true; + private bool _showCompactPrgAddresses = false; private int _selectionStart = 0; private int _selectionLength = 0; private int _scrollPosition = 0; @@ -181,6 +182,16 @@ namespace Mesen.GUI.Debugger } } + public bool ShowCompactPrgAddresses + { + get { return _showCompactPrgAddresses; } + set + { + _showCompactPrgAddresses = value; + this.Invalidate(); + } + } + public bool ShowContentNotes { get { return _showContentNotes; } @@ -483,10 +494,13 @@ namespace Mesen.GUI.Debugger } } } - + private int GetMargin(Graphics g, bool getExtendedMargin) { int marginWidth = getExtendedMargin && this.ShowContentNotes && this.ShowSingleContentLineNotes ? _marginWidth + _extendedMarginWidth : _marginWidth; + if(ShowCompactPrgAddresses) { + marginWidth += 4; + } return (this.ShowLineNumbers ? (int)(g.MeasureString("".PadLeft(marginWidth, 'W'), this.Font, int.MaxValue, StringFormat.GenericTypographic).Width) : 0) - 1; } @@ -965,9 +979,14 @@ namespace Mesen.GUI.Debugger } else { //Display line number string lineNumber = _lineNumbers[currentLine] >= 0 ? _lineNumbers[currentLine].ToString(_showLineInHex ? "X4" : "") : ".."; + + if(ShowCompactPrgAddresses && _lineNumberNotes[currentLine].Length > 3) { + lineNumber += " [" + _lineNumberNotes[currentLine].Substring(0, _lineNumberNotes[currentLine].Length - 3) + "]"; + } + float width = g.MeasureString(lineNumber, this.Font, int.MaxValue, StringFormat.GenericTypographic).Width; g.DrawString(lineNumber, this.Font, numberBrush, marginLeft - width, positionY, StringFormat.GenericTypographic); - + if(this.ShowLineNumberNotes && !this.ShowSingleLineLineNumberNotes) { //Display line note below line number width = g.MeasureString(_lineNumberNotes[currentLine], _noteFont, int.MaxValue, StringFormat.GenericTypographic).Width;