Debugger: Trace Logger - Fixed copy to clipboard format and added context menu (copy + select all)

This commit is contained in:
Sour 2018-12-15 13:10:51 -05:00
parent 2a2717b125
commit d3384b75dd
3 changed files with 55 additions and 16 deletions

View file

@ -81,6 +81,9 @@
this.mnuAutoRefresh = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.mnuRefresh = new System.Windows.Forms.ToolStripMenuItem();
this.ctxMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.mnuCopy = new System.Windows.Forms.ToolStripMenuItem();
this.mnuSelectAll = new System.Windows.Forms.ToolStripMenuItem();
this.tableLayoutPanel1.SuspendLayout();
this.grpLogOptions.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
@ -92,6 +95,7 @@
this.tableLayoutPanel3.SuspendLayout();
this.grpExecutionLog.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.ctxMenu.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
@ -548,6 +552,7 @@
//
this.txtTraceLog.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtTraceLog.CodeHighlightingEnabled = true;
this.txtTraceLog.ContextMenuStrip = this.ctxMenu;
this.txtTraceLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtTraceLog.HideSelection = false;
this.txtTraceLog.Location = new System.Drawing.Point(3, 16);
@ -717,6 +722,30 @@
this.mnuRefresh.Text = "Refresh";
this.mnuRefresh.Click += new System.EventHandler(this.mnuRefresh_Click);
//
// ctxMenu
//
this.ctxMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuCopy,
this.mnuSelectAll});
this.ctxMenu.Name = "ctxMenu";
this.ctxMenu.Size = new System.Drawing.Size(123, 48);
//
// mnuCopy
//
this.mnuCopy.Image = global::Mesen.GUI.Properties.Resources.Copy;
this.mnuCopy.Name = "mnuCopy";
this.mnuCopy.Size = new System.Drawing.Size(122, 22);
this.mnuCopy.Text = "Copy";
this.mnuCopy.Click += new System.EventHandler(this.mnuCopy_Click);
//
// mnuSelectAll
//
this.mnuSelectAll.Image = global::Mesen.GUI.Properties.Resources.SelectAll;
this.mnuSelectAll.Name = "mnuSelectAll";
this.mnuSelectAll.Size = new System.Drawing.Size(122, 22);
this.mnuSelectAll.Text = "Select All";
this.mnuSelectAll.Click += new System.EventHandler(this.mnuSelectAll_Click);
//
// frmTraceLogger
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -743,6 +772,7 @@
this.grpExecutionLog.ResumeLayout(false);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ctxMenu.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -803,5 +833,8 @@
private System.Windows.Forms.CheckBox chkExtendZeroPage;
private System.Windows.Forms.ToolStripMenuItem mnu5000Lines;
private System.Windows.Forms.ToolStripMenuItem mnu15000Lines;
private System.Windows.Forms.ContextMenuStrip ctxMenu;
private System.Windows.Forms.ToolStripMenuItem mnuCopy;
private System.Windows.Forms.ToolStripMenuItem mnuSelectAll;
}
}

View file

@ -94,6 +94,8 @@ namespace Mesen.GUI.Debugger
mnuDecreaseFontSize.InitShortcut(this, nameof(DebuggerShortcutsConfig.DecreaseFontSize));
mnuResetFontSize.InitShortcut(this, nameof(DebuggerShortcutsConfig.ResetFontSize));
mnuRefresh.InitShortcut(this, nameof(DebuggerShortcutsConfig.Refresh));
mnuCopy.InitShortcut(this, nameof(DebuggerShortcutsConfig.Copy));
mnuSelectAll.InitShortcut(this, nameof(DebuggerShortcutsConfig.SelectAll));
}
protected override void OnLoad(EventArgs e)
@ -251,22 +253,6 @@ namespace Mesen.GUI.Debugger
} catch { }
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if(keyData == ConfigManager.Config.DebugInfo.Shortcuts.Copy) {
if(_previousTrace != null && !this.txtCondition.Focused && txtTraceLog.SelectionStart >= 0) {
string[] lines = _previousTrace.Split('\n');
StringBuilder sb = new StringBuilder();
for(int i = txtTraceLog.SelectionStart, end = txtTraceLog.SelectionStart + txtTraceLog.SelectionLength; i <= end && i < lines.Length; i++) {
sb.AppendLine(lines[i]);
}
Clipboard.SetText(sb.ToString());
return true;
}
}
return base.ProcessCmdKey(ref msg, keyData);
}
private void RefreshLog(bool scrollToBottom, bool forceUpdate)
{
if(_refreshRunning) {
@ -469,5 +455,22 @@ namespace Mesen.GUI.Debugger
}
UpdateFormatOptions();
}
private void mnuCopy_Click(object sender, EventArgs e)
{
string[] lines = _previousTrace.Split('\n');
StringBuilder sb = new StringBuilder();
for(int i = txtTraceLog.SelectionStart, end = txtTraceLog.SelectionStart + txtTraceLog.SelectionLength; i <= end && i < lines.Length; i++) {
sb.Append(lines[i]);
}
Clipboard.SetText(sb.ToString());
txtTraceLog.CopySelection(true, true, false);
}
private void mnuSelectAll_Click(object sender, EventArgs e)
{
txtTraceLog.SelectAll();
}
}
}

View file

@ -120,6 +120,9 @@
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="ctxMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>353, 17</value>
</metadata>
<metadata name="tmrUpdateLog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>107, 17</value>
</metadata>