Debugger: Add move up/down shortcuts to watch list
This commit is contained in:
parent
bf160884db
commit
d58d1f39d1
10 changed files with 197 additions and 24 deletions
|
@ -195,6 +195,10 @@ namespace Mesen.GUI.Config
|
|||
|
||||
[ShortcutName("Watch List: Delete")]
|
||||
public XmlKeys WatchList_Delete = Keys.Delete;
|
||||
[ShortcutName("Watch List: Move Up")]
|
||||
public XmlKeys WatchList_MoveUp = Keys.Control | Keys.Up;
|
||||
[ShortcutName("Watch List: Move Down")]
|
||||
public XmlKeys WatchList_MoveDown = Keys.Control | Keys.Down;
|
||||
|
||||
[ShortcutName("Save Rom")]
|
||||
public XmlKeys SaveRom = Keys.Control | Keys.S;
|
||||
|
|
|
@ -44,7 +44,25 @@ namespace Mesen.GUI.Controls
|
|||
base.OnKeyDown(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class WatchListView : DoubleBufferedListView
|
||||
{
|
||||
public delegate void MoveUpDownHandler(Keys keyData, ref bool processed);
|
||||
public event MoveUpDownHandler OnMoveUpDown;
|
||||
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
if(keyData.HasFlag(Keys.Up) || keyData.HasFlag(Keys.Down)) {
|
||||
bool processed = false;
|
||||
OnMoveUpDown?.Invoke(keyData, ref processed);
|
||||
if(processed) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
}
|
||||
|
||||
public class DoubleBufferedListView : ListView
|
||||
{
|
||||
public DoubleBufferedListView()
|
||||
|
|
47
GUI.NET/Debugger/Controls/ctrlWatch.Designer.cs
generated
47
GUI.NET/Debugger/Controls/ctrlWatch.Designer.cs
generated
|
@ -30,7 +30,7 @@
|
|||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("");
|
||||
this.lstWatch = new Mesen.GUI.Controls.DoubleBufferedListView();
|
||||
this.lstWatch = new Mesen.GUI.Controls.WatchListView();
|
||||
this.colName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.colValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.contextMenuWatch = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
|
@ -38,8 +38,12 @@
|
|||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuEditInMemoryViewer = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuViewInDisassembly = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuMoveUp = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuMoveDown = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuHexDisplay = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.txtEdit = new System.Windows.Forms.TextBox();
|
||||
this.contextMenuWatch.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
|
@ -62,6 +66,7 @@
|
|||
this.lstWatch.TabIndex = 6;
|
||||
this.lstWatch.UseCompatibleStateImageBehavior = false;
|
||||
this.lstWatch.View = System.Windows.Forms.View.Details;
|
||||
this.lstWatch.OnMoveUpDown += new Mesen.GUI.Controls.WatchListView.MoveUpDownHandler(this.lstWatch_OnMoveUpDown);
|
||||
this.lstWatch.SelectedIndexChanged += new System.EventHandler(this.lstWatch_SelectedIndexChanged);
|
||||
this.lstWatch.Click += new System.EventHandler(this.lstWatch_Click);
|
||||
this.lstWatch.DoubleClick += new System.EventHandler(this.lstWatch_DoubleClick);
|
||||
|
@ -84,10 +89,14 @@
|
|||
this.toolStripMenuItem1,
|
||||
this.mnuEditInMemoryViewer,
|
||||
this.mnuViewInDisassembly,
|
||||
this.toolStripMenuItem4,
|
||||
this.mnuMoveUp,
|
||||
this.mnuMoveDown,
|
||||
this.toolStripMenuItem2,
|
||||
this.mnuHexDisplay});
|
||||
this.mnuHexDisplay,
|
||||
this.toolStripMenuItem3});
|
||||
this.contextMenuWatch.Name = "contextMenuWatch";
|
||||
this.contextMenuWatch.Size = new System.Drawing.Size(194, 104);
|
||||
this.contextMenuWatch.Size = new System.Drawing.Size(194, 160);
|
||||
this.contextMenuWatch.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuWatch_Opening);
|
||||
//
|
||||
// mnuRemoveWatch
|
||||
|
@ -119,6 +128,27 @@
|
|||
this.mnuViewInDisassembly.Text = "View in disassembly";
|
||||
this.mnuViewInDisassembly.Click += new System.EventHandler(this.mnuViewInDisassembly_Click);
|
||||
//
|
||||
// toolStripMenuItem4
|
||||
//
|
||||
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
|
||||
this.toolStripMenuItem4.Size = new System.Drawing.Size(190, 6);
|
||||
//
|
||||
// mnuMoveUp
|
||||
//
|
||||
this.mnuMoveUp.Image = global::Mesen.GUI.Properties.Resources.MoveUp;
|
||||
this.mnuMoveUp.Name = "mnuMoveUp";
|
||||
this.mnuMoveUp.Size = new System.Drawing.Size(193, 22);
|
||||
this.mnuMoveUp.Text = "Move up";
|
||||
this.mnuMoveUp.Click += new System.EventHandler(this.mnuMoveUp_Click);
|
||||
//
|
||||
// mnuMoveDown
|
||||
//
|
||||
this.mnuMoveDown.Image = global::Mesen.GUI.Properties.Resources.MoveDown;
|
||||
this.mnuMoveDown.Name = "mnuMoveDown";
|
||||
this.mnuMoveDown.Size = new System.Drawing.Size(193, 22);
|
||||
this.mnuMoveDown.Text = "Move down";
|
||||
this.mnuMoveDown.Click += new System.EventHandler(this.mnuMoveDown_Click);
|
||||
//
|
||||
// toolStripMenuItem2
|
||||
//
|
||||
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
|
||||
|
@ -134,6 +164,11 @@
|
|||
this.mnuHexDisplay.Text = "Hexadecimal Display";
|
||||
this.mnuHexDisplay.Click += new System.EventHandler(this.mnuHexDisplay_Click);
|
||||
//
|
||||
// toolStripMenuItem3
|
||||
//
|
||||
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
|
||||
this.toolStripMenuItem3.Size = new System.Drawing.Size(190, 6);
|
||||
//
|
||||
// txtEdit
|
||||
//
|
||||
this.txtEdit.AcceptsReturn = true;
|
||||
|
@ -160,7 +195,7 @@
|
|||
|
||||
#endregion
|
||||
|
||||
private Mesen.GUI.Controls.DoubleBufferedListView lstWatch;
|
||||
private Mesen.GUI.Controls.WatchListView lstWatch;
|
||||
private System.Windows.Forms.ColumnHeader colName;
|
||||
private System.Windows.Forms.ColumnHeader colValue;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuWatch;
|
||||
|
@ -171,5 +206,9 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem mnuViewInDisassembly;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
|
||||
private System.Windows.Forms.TextBox txtEdit;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem4;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuMoveUp;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuMoveDown;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ namespace Mesen.GUI.Debugger
|
|||
mnuRemoveWatch.InitShortcut(this, nameof(DebuggerShortcutsConfig.WatchList_Delete));
|
||||
mnuEditInMemoryViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_EditInMemoryViewer));
|
||||
mnuViewInDisassembly.InitShortcut(this, nameof(DebuggerShortcutsConfig.MemoryViewer_ViewInDisassembly));
|
||||
mnuMoveUp.InitShortcut(this, nameof(DebuggerShortcutsConfig.WatchList_MoveUp));
|
||||
mnuMoveDown.InitShortcut(this, nameof(DebuggerShortcutsConfig.WatchList_MoveDown));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,22 +53,22 @@ namespace Mesen.GUI.Debugger
|
|||
if(lstWatch.SelectedItems.Count > 0) {
|
||||
//Used to prevent a Mono issue where pressing a key will change the selected item before we get a chance to edit it
|
||||
_keyDownItem = lstWatch.SelectedItems[0];
|
||||
|
||||
if((_isEditing && keyData == Keys.Escape) || keyData == Keys.Enter) {
|
||||
if(keyData == Keys.Enter) {
|
||||
if(_isEditing) {
|
||||
ApplyEdit();
|
||||
} else {
|
||||
StartEdit(lstWatch.SelectedItems[0].Text);
|
||||
}
|
||||
} else if(keyData == Keys.Escape) {
|
||||
CancelEdit();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
_keyDownItem = null;
|
||||
}
|
||||
|
||||
if((_isEditing && keyData == Keys.Escape) || keyData == Keys.Enter) {
|
||||
if(keyData == Keys.Enter) {
|
||||
if(_isEditing) {
|
||||
ApplyEdit();
|
||||
} else {
|
||||
StartEdit(lstWatch.SelectedItems[0].Text);
|
||||
}
|
||||
} else if(keyData == Keys.Escape) {
|
||||
CancelEdit();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
UpdateActions();
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
|
@ -90,7 +92,7 @@ namespace Mesen.GUI.Debugger
|
|||
{
|
||||
List<WatchValueInfo> watchContent = WatchManager.GetWatchContent(mnuHexDisplay.Checked);
|
||||
|
||||
int currentSelection = lstWatch.SelectedIndices.Count > 0 ? lstWatch.SelectedIndices[0] : -1;
|
||||
int currentSelection = lstWatch.FocusedItem?.Index ?? -1;
|
||||
|
||||
bool updating = false;
|
||||
if(watchContent.Count != lstWatch.Items.Count - 1) {
|
||||
|
@ -143,8 +145,7 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
|
||||
if(currentSelection >= 0 && lstWatch.Items.Count > currentSelection) {
|
||||
lstWatch.FocusedItem = lstWatch.Items[currentSelection];
|
||||
lstWatch.Items[currentSelection].Selected = true;
|
||||
SetSelectedItem(currentSelection);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,6 +166,8 @@ namespace Mesen.GUI.Debugger
|
|||
{
|
||||
mnuEditInMemoryViewer.Enabled = false;
|
||||
mnuViewInDisassembly.Enabled = false;
|
||||
mnuMoveUp.Enabled = false;
|
||||
mnuMoveDown.Enabled = false;
|
||||
|
||||
if(lstWatch.SelectedItems.Count == 1) {
|
||||
Match match = _watchAddressOrLabel.Match(lstWatch.SelectedItems[0].Text);
|
||||
|
@ -187,6 +190,9 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
mnuMoveUp.Enabled = lstWatch.SelectedIndices[0] > 0 && lstWatch.SelectedIndices[0] < lstWatch.Items.Count - 1;
|
||||
mnuMoveDown.Enabled = lstWatch.SelectedIndices[0] < lstWatch.Items.Count - 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,14 +273,18 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
private void ApplyEdit()
|
||||
{
|
||||
lstWatch.SelectedItems[0].Text = txtEdit.Text;
|
||||
WatchManager.UpdateWatch(lstWatch.SelectedIndices[0], txtEdit.Text);
|
||||
if(lstWatch.SelectedItems.Count > 0) {
|
||||
lstWatch.SelectedItems[0].Text = txtEdit.Text;
|
||||
WatchManager.UpdateWatch(lstWatch.SelectedIndices[0], txtEdit.Text);
|
||||
}
|
||||
lstWatch.Focus();
|
||||
}
|
||||
|
||||
private void CancelEdit()
|
||||
{
|
||||
txtEdit.Text = lstWatch.SelectedItems[0].Text;
|
||||
if(lstWatch.SelectedItems.Count > 0) {
|
||||
txtEdit.Text = lstWatch.SelectedItems[0].Text;
|
||||
}
|
||||
lstWatch.Focus();
|
||||
}
|
||||
|
||||
|
@ -294,5 +304,77 @@ namespace Mesen.GUI.Debugger
|
|||
lstWatch.Focus();
|
||||
ApplyEdit();
|
||||
}
|
||||
|
||||
private void mnuMoveUp_Click(object sender, EventArgs e)
|
||||
{
|
||||
MoveUp(false);
|
||||
}
|
||||
|
||||
private void mnuMoveDown_Click(object sender, EventArgs e)
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
|
||||
private void SetSelectedItem(int index)
|
||||
{
|
||||
if(index < lstWatch.Items.Count) {
|
||||
lstWatch.FocusedItem = lstWatch.Items[index];
|
||||
foreach(ListViewItem item in lstWatch.Items) {
|
||||
item.Selected = lstWatch.FocusedItem == item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveUp(bool fromUpDownArrow)
|
||||
{
|
||||
if(lstWatch.SelectedIndices.Count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = lstWatch.SelectedIndices[0];
|
||||
if(Program.IsMono && fromUpDownArrow) {
|
||||
//Mono appears to move the selection up before processing this
|
||||
index++;
|
||||
}
|
||||
|
||||
if(index > 0 && index < lstWatch.Items.Count - 1) {
|
||||
string currentEntry = lstWatch.Items[index].SubItems[0].Text;
|
||||
string entryAbove = lstWatch.Items[index - 1].SubItems[0].Text;
|
||||
SetSelectedItem(index - 1);
|
||||
WatchManager.UpdateWatch(index - 1, currentEntry);
|
||||
WatchManager.UpdateWatch(index, entryAbove);
|
||||
} else {
|
||||
SetSelectedItem(index);
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveDown()
|
||||
{
|
||||
if(lstWatch.SelectedIndices.Count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = lstWatch.SelectedIndices[0];
|
||||
if(index < lstWatch.Items.Count - 2) {
|
||||
string currentEntry = lstWatch.Items[index].SubItems[0].Text;
|
||||
string entryBelow = lstWatch.Items[index + 1].SubItems[0].Text;
|
||||
SetSelectedItem(index + 1);
|
||||
WatchManager.UpdateWatch(index + 1, currentEntry);
|
||||
WatchManager.UpdateWatch(index, entryBelow);
|
||||
} else {
|
||||
SetSelectedItem(index);
|
||||
}
|
||||
}
|
||||
|
||||
private void lstWatch_OnMoveUpDown(Keys keyData, ref bool processed)
|
||||
{
|
||||
if(keyData == ConfigManager.Config.DebugInfo.Shortcuts.WatchList_MoveUp) {
|
||||
MoveUp(true);
|
||||
processed = true;
|
||||
} else if(keyData == ConfigManager.Config.DebugInfo.Shortcuts.WatchList_MoveDown) {
|
||||
MoveDown();
|
||||
processed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,6 +121,8 @@ namespace Mesen.GUI.Debugger
|
|||
GetMember(nameof(DebuggerShortcutsConfig.BreakpointList_GoToLocation)),
|
||||
GetMember(nameof(DebuggerShortcutsConfig.BreakpointList_Delete)),
|
||||
GetMember(nameof(DebuggerShortcutsConfig.WatchList_Delete)),
|
||||
GetMember(nameof(DebuggerShortcutsConfig.WatchList_MoveUp)),
|
||||
GetMember(nameof(DebuggerShortcutsConfig.WatchList_MoveDown)),
|
||||
GetMember(nameof(DebuggerShortcutsConfig.SaveRom)),
|
||||
GetMember(nameof(DebuggerShortcutsConfig.SaveRomAs)),
|
||||
GetMember(nameof(DebuggerShortcutsConfig.SaveEditAsIps)),
|
||||
|
|
|
@ -1262,6 +1262,8 @@
|
|||
<Compile Include="RuntimeChecker.cs" />
|
||||
<Compile Include="SingleInstance.cs" />
|
||||
<Compile Include="TestRunner.cs" />
|
||||
<None Include="Resources\MoveDown.png" />
|
||||
<None Include="Resources\MoveUp.png" />
|
||||
<None Include="Resources\NudDownArrowDarkTheme.png" />
|
||||
<None Include="Resources\DownArrowDarkTheme.png" />
|
||||
<None Include="Resources\NudUpArrowDarkTheme.png" />
|
||||
|
|
20
GUI.NET/Properties/Resources.Designer.cs
generated
20
GUI.NET/Properties/Resources.Designer.cs
generated
|
@ -580,6 +580,26 @@ namespace Mesen.GUI.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap MoveDown {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("MoveDown", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap MoveUp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("MoveUp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
|
|
@ -454,4 +454,10 @@
|
|||
<data name="NudUpArrowDarkTheme" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\NudUpArrowDarkTheme.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="MoveDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\MoveDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="MoveUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\MoveUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
GUI.NET/Resources/MoveDown.png
Normal file
BIN
GUI.NET/Resources/MoveDown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 543 B |
BIN
GUI.NET/Resources/MoveUp.png
Normal file
BIN
GUI.NET/Resources/MoveUp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 533 B |
Loading…
Add table
Reference in a new issue