`Trim()` when copying Log Window selection to clipboard

see e269bfd49
This commit is contained in:
YoshiRulz 2023-01-03 23:26:17 +10:00
parent e7d95aa07d
commit 5827cbd829
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 25 additions and 9 deletions

View File

@ -7,6 +7,7 @@ using System.Windows.Forms;
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Common.StringExtensions;
// todo - perks - pause, copy to clipboard, backlog length limiting // todo - perks - pause, copy to clipboard, backlog length limiting
@ -149,13 +150,28 @@ namespace BizHawk.Client.EmuHawk
private void ButtonCopy_Click(object sender, EventArgs e) private void ButtonCopy_Click(object sender, EventArgs e)
{ {
var sb = new StringBuilder(); string s;
lock(_lines) lock (_lines)
foreach (int i in virtualListView1.SelectedIndices) {
sb.AppendLine(_lines[i].Replace("MD5:", "").Replace("SHA1:", "")); if (virtualListView1.SelectedIndices.Count > 1)
{
if (sb.Length > 0) StringBuilder sb = new();
Clipboard.SetText(sb.ToString(), TextDataFormat.Text); foreach (int i in virtualListView1.SelectedIndices) sb.AppendLine(_lines[i]);
s = sb.ToString();
}
else if (virtualListView1.SelectedIndices.Count is 1)
{
s = _lines[virtualListView1.SelectedIndices[0]]
.RemovePrefix(SHA1Checksum.PREFIX + ":")
.RemovePrefix(MD5Checksum.PREFIX + ":");
}
else
{
return;
}
}
s = s.Trim();
if (!string.IsNullOrWhiteSpace(s)) Clipboard.SetText(s, TextDataFormat.Text);
} }
private void ButtonCopyAll_Click(object sender, EventArgs e) private void ButtonCopyAll_Click(object sender, EventArgs e)

View File

@ -15,7 +15,7 @@ namespace BizHawk.Common
/// <remarks>in bits</remarks> /// <remarks>in bits</remarks>
internal const int EXPECTED_LENGTH = 128; internal const int EXPECTED_LENGTH = 128;
internal const string PREFIX = "MD5"; public const string PREFIX = "MD5";
public /*static readonly*/const string EmptyFile = "D41D8CD98F00B204E9800998ECF8427E"; public /*static readonly*/const string EmptyFile = "D41D8CD98F00B204E9800998ECF8427E";

View File

@ -17,7 +17,7 @@ namespace BizHawk.Common
/// <remarks>in bits</remarks> /// <remarks>in bits</remarks>
internal const int EXPECTED_LENGTH = 160; internal const int EXPECTED_LENGTH = 160;
internal const string PREFIX = "SHA1"; public const string PREFIX = "SHA1";
public /*static readonly*/const string Dummy = "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"; public /*static readonly*/const string Dummy = "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE";